diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt index f9e96563b88090..73a2ee46291ee5 100644 --- a/compiler-rt/lib/CMakeLists.txt +++ b/compiler-rt/lib/CMakeLists.txt @@ -47,11 +47,11 @@ if(COMPILER_RT_BUILD_SANITIZERS) endforeach() endif() -if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE) +if(COMPILER_RT_BUILD_PROFILE) compiler_rt_build_runtime(profile) endif() -if(COMPILER_RT_BUILD_CTX_PROFILE AND COMPILER_RT_HAS_CTX_PROFILE) +if(COMPILER_RT_BUILD_CTX_PROFILE) compiler_rt_build_runtime(ctx_profile) endif() diff --git a/compiler-rt/lib/gwp_asan/CMakeLists.txt b/compiler-rt/lib/gwp_asan/CMakeLists.txt index bb5b2902f99dbf..fdb6a95fe14043 100644 --- a/compiler-rt/lib/gwp_asan/CMakeLists.txt +++ b/compiler-rt/lib/gwp_asan/CMakeLists.txt @@ -65,48 +65,46 @@ set(GWP_ASAN_SEGV_HANDLER_HEADERS set(GWP_ASAN_OPTIONS_PARSER_CFLAGS ${GWP_ASAN_CFLAGS}) -if (COMPILER_RT_HAS_GWP_ASAN) - foreach(arch ${GWP_ASAN_SUPPORTED_ARCH}) - add_compiler_rt_runtime( - clang_rt.gwp_asan - STATIC - ARCHS ${arch} - SOURCES ${GWP_ASAN_SOURCES} - ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS} - CFLAGS ${GWP_ASAN_CFLAGS} - PARENT_TARGET gwp_asan - ) - endforeach() +foreach(arch ${GWP_ASAN_SUPPORTED_ARCH}) + add_compiler_rt_runtime( + clang_rt.gwp_asan + STATIC + ARCHS ${arch} + SOURCES ${GWP_ASAN_SOURCES} + ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS} + CFLAGS ${GWP_ASAN_CFLAGS} + PARENT_TARGET gwp_asan + ) +endforeach() - add_compiler_rt_object_libraries(RTGwpAsan - ARCHS ${GWP_ASAN_SUPPORTED_ARCH} - SOURCES ${GWP_ASAN_SOURCES} - ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS} - CFLAGS ${GWP_ASAN_CFLAGS}) +add_compiler_rt_object_libraries(RTGwpAsan + ARCHS ${GWP_ASAN_SUPPORTED_ARCH} + SOURCES ${GWP_ASAN_SOURCES} + ADDITIONAL_HEADERS ${GWP_ASAN_HEADERS} + CFLAGS ${GWP_ASAN_CFLAGS}) - add_compiler_rt_object_libraries(RTGwpAsanOptionsParser - ARCHS ${GWP_ASAN_SUPPORTED_ARCH} - SOURCES ${GWP_ASAN_OPTIONS_PARSER_SOURCES} - ADDITIONAL_HEADERS ${GWP_ASAN_OPTIONS_PARSER_HEADERS} - CFLAGS ${GWP_ASAN_OPTIONS_PARSER_CFLAGS}) +add_compiler_rt_object_libraries(RTGwpAsanOptionsParser + ARCHS ${GWP_ASAN_SUPPORTED_ARCH} + SOURCES ${GWP_ASAN_OPTIONS_PARSER_SOURCES} + ADDITIONAL_HEADERS ${GWP_ASAN_OPTIONS_PARSER_HEADERS} + CFLAGS ${GWP_ASAN_OPTIONS_PARSER_CFLAGS}) - # As above, build the pre-implemented optional backtrace support libraries. - add_compiler_rt_object_libraries(RTGwpAsanBacktraceLibc - ARCHS ${GWP_ASAN_SUPPORTED_ARCH} - SOURCES optional/backtrace_linux_libc.cpp - ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS} - CFLAGS ${GWP_ASAN_CFLAGS}) - add_compiler_rt_object_libraries(RTGwpAsanSegvHandler - ARCHS ${GWP_ASAN_SUPPORTED_ARCH} - SOURCES optional/segv_handler_posix.cpp - ADDITIONAL_HEADERS ${GWP_ASAN_SEGV_HANDLER_HEADERS} - CFLAGS ${GWP_ASAN_CFLAGS}) - add_compiler_rt_object_libraries(RTGwpAsanBacktraceSanitizerCommon - ARCHS ${GWP_ASAN_SUPPORTED_ARCH} - SOURCES optional/backtrace_sanitizer_common.cpp - ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS} - CFLAGS ${GWP_ASAN_CFLAGS} ${SANITIZER_COMMON_CFLAGS}) -endif() +# As above, build the pre-implemented optional backtrace support libraries. +add_compiler_rt_object_libraries(RTGwpAsanBacktraceLibc + ARCHS ${GWP_ASAN_SUPPORTED_ARCH} + SOURCES optional/backtrace_linux_libc.cpp + ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS} + CFLAGS ${GWP_ASAN_CFLAGS}) +add_compiler_rt_object_libraries(RTGwpAsanSegvHandler + ARCHS ${GWP_ASAN_SUPPORTED_ARCH} + SOURCES optional/segv_handler_posix.cpp + ADDITIONAL_HEADERS ${GWP_ASAN_SEGV_HANDLER_HEADERS} + CFLAGS ${GWP_ASAN_CFLAGS}) +add_compiler_rt_object_libraries(RTGwpAsanBacktraceSanitizerCommon + ARCHS ${GWP_ASAN_SUPPORTED_ARCH} + SOURCES optional/backtrace_sanitizer_common.cpp + ADDITIONAL_HEADERS ${GWP_ASAN_BACKTRACE_HEADERS} + CFLAGS ${GWP_ASAN_CFLAGS} ${SANITIZER_COMMON_CFLAGS}) if(COMPILER_RT_INCLUDE_TESTS) add_subdirectory(tests) diff --git a/compiler-rt/lib/lsan/CMakeLists.txt b/compiler-rt/lib/lsan/CMakeLists.txt index 8e9861cd6b7c09..c7bb6449982c20 100644 --- a/compiler-rt/lib/lsan/CMakeLists.txt +++ b/compiler-rt/lib/lsan/CMakeLists.txt @@ -43,46 +43,44 @@ add_compiler_rt_object_libraries(RTLSanCommon ADDITIONAL_HEADERS ${LSAN_HEADERS} CFLAGS ${LSAN_CFLAGS}) -if(COMPILER_RT_HAS_LSAN) - add_compiler_rt_component(lsan) - if(APPLE) - set(LSAN_LINK_LIBS ${SANITIZER_COMMON_LINK_LIBS}) +add_compiler_rt_component(lsan) +if(APPLE) + set(LSAN_LINK_LIBS ${SANITIZER_COMMON_LINK_LIBS}) - add_weak_symbols("lsan" WEAK_SYMBOL_LINK_FLAGS) - add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS) + add_weak_symbols("lsan" WEAK_SYMBOL_LINK_FLAGS) + add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS) + add_compiler_rt_runtime(clang_rt.lsan + SHARED + OS ${LSAN_SUPPORTED_OS} + ARCHS ${LSAN_SUPPORTED_ARCH} + SOURCES ${LSAN_SOURCES} + ADDITIONAL_HEADERS ${LSAN_HEADERS} + OBJECT_LIBS RTLSanCommon + RTInterception + RTSanitizerCommon + RTSanitizerCommonLibc + RTSanitizerCommonCoverage + RTSanitizerCommonSymbolizer + CFLAGS ${LSAN_CFLAGS} + LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS} + LINK_LIBS ${LSAN_LINK_LIBS} + PARENT_TARGET lsan) +else() + foreach(arch ${LSAN_SUPPORTED_ARCH}) add_compiler_rt_runtime(clang_rt.lsan - SHARED - OS ${LSAN_SUPPORTED_OS} - ARCHS ${LSAN_SUPPORTED_ARCH} + STATIC + ARCHS ${arch} SOURCES ${LSAN_SOURCES} + $ + $ + $ + $ + $ + $ + $ ADDITIONAL_HEADERS ${LSAN_HEADERS} - OBJECT_LIBS RTLSanCommon - RTInterception - RTSanitizerCommon - RTSanitizerCommonLibc - RTSanitizerCommonCoverage - RTSanitizerCommonSymbolizer CFLAGS ${LSAN_CFLAGS} - LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS} - LINK_LIBS ${LSAN_LINK_LIBS} PARENT_TARGET lsan) - else() - foreach(arch ${LSAN_SUPPORTED_ARCH}) - add_compiler_rt_runtime(clang_rt.lsan - STATIC - ARCHS ${arch} - SOURCES ${LSAN_SOURCES} - $ - $ - $ - $ - $ - $ - $ - ADDITIONAL_HEADERS ${LSAN_HEADERS} - CFLAGS ${LSAN_CFLAGS} - PARENT_TARGET lsan) - endforeach() - endif() + endforeach() endif() diff --git a/compiler-rt/lib/nsan/CMakeLists.txt b/compiler-rt/lib/nsan/CMakeLists.txt index 36c7b2b9dfada4..aef9b651ab2ec8 100644 --- a/compiler-rt/lib/nsan/CMakeLists.txt +++ b/compiler-rt/lib/nsan/CMakeLists.txt @@ -25,31 +25,29 @@ set(NSAN_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS}) set(NSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS}) -if (COMPILER_RT_HAS_NSAN) - foreach(arch ${NSAN_SUPPORTED_ARCH}) - add_compiler_rt_runtime( - clang_rt.nsan - STATIC - ARCHS ${arch} - SOURCES ${NSAN_SOURCES} - $ - $ - $ - $ - $ - $ - ADDITIONAL_HEADERS ${NSAN_HEADERS} - CFLAGS ${NSAN_CFLAGS} - PARENT_TARGET nsan - ) - endforeach() - - add_compiler_rt_object_libraries(RTNsan - ARCHS ${NSAN_SUPPORTED_ARCH} - SOURCES ${NSAN_SOURCES} - ADDITIONAL_HEADERS ${NSAN_HEADERS} - CFLAGS ${NSAN_CFLAGS}) -endif() +foreach(arch ${NSAN_SUPPORTED_ARCH}) + add_compiler_rt_runtime( + clang_rt.nsan + STATIC + ARCHS ${arch} + SOURCES ${NSAN_SOURCES} + $ + $ + $ + $ + $ + $ + ADDITIONAL_HEADERS ${NSAN_HEADERS} + CFLAGS ${NSAN_CFLAGS} + PARENT_TARGET nsan + ) +endforeach() + +add_compiler_rt_object_libraries(RTNsan + ARCHS ${NSAN_SUPPORTED_ARCH} + SOURCES ${NSAN_SOURCES} + ADDITIONAL_HEADERS ${NSAN_HEADERS} + CFLAGS ${NSAN_CFLAGS}) if(COMPILER_RT_INCLUDE_TESTS) add_subdirectory(tests) diff --git a/compiler-rt/lib/scudo/standalone/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/CMakeLists.txt index 6fb4e88de3155f..8fc245eb2cf389 100644 --- a/compiler-rt/lib/scudo/standalone/CMakeLists.txt +++ b/compiler-rt/lib/scudo/standalone/CMakeLists.txt @@ -195,60 +195,58 @@ if(COMPILER_RT_DEFAULT_TARGET_ARCH MATCHES "mips|mips64|mipsel|mips64el") list(APPEND SCUDO_LINK_LIBS atomic) endif() -if(COMPILER_RT_HAS_SCUDO_STANDALONE) - add_compiler_rt_object_libraries(RTScudoStandalone - ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} - SOURCES ${SCUDO_SOURCES} - ADDITIONAL_HEADERS ${SCUDO_HEADERS} - CFLAGS ${SCUDO_CFLAGS} - DEPS ${SCUDO_DEPS}) - add_compiler_rt_object_libraries(RTScudoStandaloneCWrappers - ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} - SOURCES ${SCUDO_SOURCES_C_WRAPPERS} - ADDITIONAL_HEADERS ${SCUDO_HEADERS} - CFLAGS ${SCUDO_CFLAGS} - DEPS ${SCUDO_DEPS}) - add_compiler_rt_object_libraries(RTScudoStandaloneCxxWrappers - ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} - SOURCES ${SCUDO_SOURCES_CXX_WRAPPERS} - ADDITIONAL_HEADERS ${SCUDO_HEADERS} - CFLAGS ${SCUDO_CFLAGS} - DEPS ${SCUDO_DEPS}) - +add_compiler_rt_object_libraries(RTScudoStandalone + ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} + SOURCES ${SCUDO_SOURCES} + ADDITIONAL_HEADERS ${SCUDO_HEADERS} + CFLAGS ${SCUDO_CFLAGS} + DEPS ${SCUDO_DEPS}) +add_compiler_rt_object_libraries(RTScudoStandaloneCWrappers + ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} + SOURCES ${SCUDO_SOURCES_C_WRAPPERS} + ADDITIONAL_HEADERS ${SCUDO_HEADERS} + CFLAGS ${SCUDO_CFLAGS} + DEPS ${SCUDO_DEPS}) +add_compiler_rt_object_libraries(RTScudoStandaloneCxxWrappers + ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} + SOURCES ${SCUDO_SOURCES_CXX_WRAPPERS} + ADDITIONAL_HEADERS ${SCUDO_HEADERS} + CFLAGS ${SCUDO_CFLAGS} + DEPS ${SCUDO_DEPS}) + +add_compiler_rt_runtime(clang_rt.scudo_standalone + STATIC + ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} + SOURCES ${SCUDO_SOURCES} ${SCUDO_SOURCES_C_WRAPPERS} + ADDITIONAL_HEADERS ${SCUDO_HEADERS} + CFLAGS ${SCUDO_CFLAGS} + DEPS ${SCUDO_DEPS} + OBJECT_LIBS ${SCUDO_OBJECT_LIBS} + PARENT_TARGET scudo_standalone) +add_compiler_rt_runtime(clang_rt.scudo_standalone_cxx + STATIC + ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} + SOURCES ${SCUDO_SOURCES_CXX_WRAPPERS} + ADDITIONAL_HEADERS ${SCUDO_HEADERS} + CFLAGS ${SCUDO_CFLAGS} + DEPS ${SCUDO_DEPS} + PARENT_TARGET scudo_standalone) + +if(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED) add_compiler_rt_runtime(clang_rt.scudo_standalone - STATIC + SHARED ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} - SOURCES ${SCUDO_SOURCES} ${SCUDO_SOURCES_C_WRAPPERS} + SOURCES ${SCUDO_SOURCES} ${SCUDO_SOURCES_C_WRAPPERS} ${SCUDO_SOURCES_CXX_WRAPPERS} ADDITIONAL_HEADERS ${SCUDO_HEADERS} CFLAGS ${SCUDO_CFLAGS} DEPS ${SCUDO_DEPS} OBJECT_LIBS ${SCUDO_OBJECT_LIBS} + LINK_FLAGS ${SCUDO_LINK_FLAGS} + LINK_LIBS ${SCUDO_LINK_LIBS} PARENT_TARGET scudo_standalone) - add_compiler_rt_runtime(clang_rt.scudo_standalone_cxx - STATIC - ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} - SOURCES ${SCUDO_SOURCES_CXX_WRAPPERS} - ADDITIONAL_HEADERS ${SCUDO_HEADERS} - CFLAGS ${SCUDO_CFLAGS} - DEPS ${SCUDO_DEPS} - PARENT_TARGET scudo_standalone) - - if(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED) - add_compiler_rt_runtime(clang_rt.scudo_standalone - SHARED - ARCHS ${SCUDO_STANDALONE_SUPPORTED_ARCH} - SOURCES ${SCUDO_SOURCES} ${SCUDO_SOURCES_C_WRAPPERS} ${SCUDO_SOURCES_CXX_WRAPPERS} - ADDITIONAL_HEADERS ${SCUDO_HEADERS} - CFLAGS ${SCUDO_CFLAGS} - DEPS ${SCUDO_DEPS} - OBJECT_LIBS ${SCUDO_OBJECT_LIBS} - LINK_FLAGS ${SCUDO_LINK_FLAGS} - LINK_LIBS ${SCUDO_LINK_LIBS} - PARENT_TARGET scudo_standalone) - endif() +endif() - add_subdirectory(benchmarks) - if(COMPILER_RT_INCLUDE_TESTS) - add_subdirectory(tests) - endif() +add_subdirectory(benchmarks) +if(COMPILER_RT_INCLUDE_TESTS) + add_subdirectory(tests) endif() diff --git a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt index 1786756fa5ea68..672cdc0ba655ea 100644 --- a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt +++ b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt @@ -66,27 +66,25 @@ macro(add_scudo_unittest testname) RTGwpAsan RTGwpAsanBacktraceLibc RTGwpAsanSegvHandler) endif() - if(COMPILER_RT_HAS_SCUDO_STANDALONE) - foreach(arch ${SCUDO_TEST_ARCH}) - # Additional runtime objects get added along RTScudoStandalone - set(SCUDO_TEST_RTOBJECTS $) - foreach(rtobject ${TEST_ADDITIONAL_RTOBJECTS}) - list(APPEND SCUDO_TEST_RTOBJECTS $) - endforeach() - # Add the static runtime library made of all the runtime objects - set(RUNTIME RT${testname}.${arch}) - add_library(${RUNTIME} STATIC ${SCUDO_TEST_RTOBJECTS}) - set(ScudoUnitTestsObjects) - generate_compiler_rt_tests(ScudoUnitTestsObjects ScudoUnitTests - "${testname}-${arch}-Test" ${arch} - SOURCES ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE} - COMPILE_DEPS ${SCUDO_TEST_HEADERS} - DEPS scudo_standalone - RUNTIME ${RUNTIME} - CFLAGS ${SCUDO_UNITTEST_CFLAGS} - LINK_FLAGS ${SCUDO_UNITTEST_LINK_FLAGS}) + foreach(arch ${SCUDO_TEST_ARCH}) + # Additional runtime objects get added along RTScudoStandalone + set(SCUDO_TEST_RTOBJECTS $) + foreach(rtobject ${TEST_ADDITIONAL_RTOBJECTS}) + list(APPEND SCUDO_TEST_RTOBJECTS $) endforeach() - endif() + # Add the static runtime library made of all the runtime objects + set(RUNTIME RT${testname}.${arch}) + add_library(${RUNTIME} STATIC ${SCUDO_TEST_RTOBJECTS}) + set(ScudoUnitTestsObjects) + generate_compiler_rt_tests(ScudoUnitTestsObjects ScudoUnitTests + "${testname}-${arch}-Test" ${arch} + SOURCES ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE} + COMPILE_DEPS ${SCUDO_TEST_HEADERS} + DEPS scudo_standalone + RUNTIME ${RUNTIME} + CFLAGS ${SCUDO_UNITTEST_CFLAGS} + LINK_FLAGS ${SCUDO_UNITTEST_LINK_FLAGS}) + endforeach() endmacro() set(SCUDO_UNIT_TEST_SOURCES diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt index db0b33f1276ef2..a1cfbe93b068d0 100644 --- a/compiler-rt/lib/ubsan/CMakeLists.txt +++ b/compiler-rt/lib/ubsan/CMakeLists.txt @@ -92,47 +92,45 @@ if(APPLE) ADDITIONAL_HEADERS ${UBSAN_HEADERS} CFLAGS ${UBSAN_CXXFLAGS}) - if(COMPILER_RT_HAS_UBSAN) - # Initializer of standalone UBSan runtime. - add_compiler_rt_object_libraries(RTUbsan_standalone - OS ${UBSAN_SUPPORTED_OS} - ARCHS ${UBSAN_SUPPORTED_ARCH} - SOURCES ${UBSAN_STANDALONE_SOURCES} - ADDITIONAL_HEADERS ${UBSAN_HEADERS} - CFLAGS ${UBSAN_STANDALONE_CFLAGS}) + # Initializer of standalone UBSan runtime. + add_compiler_rt_object_libraries(RTUbsan_standalone + OS ${UBSAN_SUPPORTED_OS} + ARCHS ${UBSAN_SUPPORTED_ARCH} + SOURCES ${UBSAN_STANDALONE_SOURCES} + ADDITIONAL_HEADERS ${UBSAN_HEADERS} + CFLAGS ${UBSAN_STANDALONE_CFLAGS}) + + add_weak_symbols("ubsan" WEAK_SYMBOL_LINK_FLAGS) + add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS) - add_weak_symbols("ubsan" WEAK_SYMBOL_LINK_FLAGS) - add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS) + add_compiler_rt_runtime(clang_rt.ubsan + SHARED + OS ${UBSAN_SUPPORTED_OS} + ARCHS ${UBSAN_SUPPORTED_ARCH} + OBJECT_LIBS RTUbsan + RTUbsan_standalone + RTSanitizerCommon + RTSanitizerCommonLibc + RTSanitizerCommonCoverage + RTSanitizerCommonSymbolizer + RTInterception + LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} + PARENT_TARGET ubsan) + if (NOT APPLE) add_compiler_rt_runtime(clang_rt.ubsan - SHARED + STATIC OS ${UBSAN_SUPPORTED_OS} ARCHS ${UBSAN_SUPPORTED_ARCH} OBJECT_LIBS RTUbsan RTUbsan_standalone - RTSanitizerCommon - RTSanitizerCommonLibc + RTSanitizerCommonNoHooks + RTSanitizerCommonLibcNoHooks RTSanitizerCommonCoverage - RTSanitizerCommonSymbolizer + RTSanitizerCommonSymbolizerNoHooks RTInterception LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} PARENT_TARGET ubsan) - - if (NOT APPLE) - add_compiler_rt_runtime(clang_rt.ubsan - STATIC - OS ${UBSAN_SUPPORTED_OS} - ARCHS ${UBSAN_SUPPORTED_ARCH} - OBJECT_LIBS RTUbsan - RTUbsan_standalone - RTSanitizerCommonNoHooks - RTSanitizerCommonLibcNoHooks - RTSanitizerCommonCoverage - RTSanitizerCommonSymbolizerNoHooks - RTInterception - LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} - PARENT_TARGET ubsan) - endif() endif() else() @@ -190,91 +188,89 @@ else() DEFS ${UBSAN_COMMON_DEFINITIONS}) endif() - if(COMPILER_RT_HAS_UBSAN) - add_compiler_rt_object_libraries(RTUbsan_standalone - ARCHS ${UBSAN_SUPPORTED_ARCH} - SOURCES ${UBSAN_STANDALONE_SOURCES} - ADDITIONAL_HEADERS ${UBSAN_HEADERS} - CFLAGS ${UBSAN_STANDALONE_CFLAGS}) - - # Standalone UBSan runtimes. - add_compiler_rt_runtime(clang_rt.ubsan_standalone - STATIC + add_compiler_rt_object_libraries(RTUbsan_standalone + ARCHS ${UBSAN_SUPPORTED_ARCH} + SOURCES ${UBSAN_STANDALONE_SOURCES} + ADDITIONAL_HEADERS ${UBSAN_HEADERS} + CFLAGS ${UBSAN_STANDALONE_CFLAGS}) + + # Standalone UBSan runtimes. + add_compiler_rt_runtime(clang_rt.ubsan_standalone + STATIC + ARCHS ${UBSAN_SUPPORTED_ARCH} + SOURCES + ubsan_init_standalone_preinit.cpp + ADDITIONAL_HEADERS ${UBSAN_HEADERS} + OBJECT_LIBS RTSanitizerCommon + RTSanitizerCommonLibc + RTSanitizerCommonCoverage + RTSanitizerCommonSymbolizer + RTSanitizerCommonSymbolizerInternal + RTUbsan + RTUbsan_standalone + RTInterception + CFLAGS ${UBSAN_CFLAGS} + PARENT_TARGET ubsan) + + add_compiler_rt_runtime(clang_rt.ubsan_standalone_cxx + STATIC + ARCHS ${UBSAN_SUPPORTED_ARCH} + OBJECT_LIBS RTUbsan_cxx + CFLAGS ${UBSAN_CXXFLAGS} + PARENT_TARGET ubsan) + + if (COMPILER_RT_HAS_VERSION_SCRIPT) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp "") + add_compiler_rt_object_libraries(RTUbsan_dynamic_version_script_dummy ARCHS ${UBSAN_SUPPORTED_ARCH} - SOURCES - ubsan_init_standalone_preinit.cpp - ADDITIONAL_HEADERS ${UBSAN_HEADERS} - OBJECT_LIBS RTSanitizerCommon + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp + CFLAGS ${UBSAN_CFLAGS}) + + foreach(arch ${UBSAN_SUPPORTED_ARCH}) + add_sanitizer_rt_version_list(clang_rt.ubsan_standalone-dynamic-${arch} + LIBS clang_rt.ubsan_standalone-${arch} + clang_rt.ubsan_standalone_cxx-${arch} + EXTRA ubsan.syms.extra) + set(VERSION_SCRIPT_FLAG + -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.ubsan_standalone-dynamic-${arch}.vers) + # The Solaris 11.4 linker supports a subset of GNU ld version scripts, + # but requires a special option to enable it. + if (COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT) + list(APPEND VERSION_SCRIPT_FLAG -Wl,-z,gnu-version-script-compat) + endif() + set_property(SOURCE + ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp + APPEND PROPERTY + OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.ubsan_standalone-dynamic-${arch}.vers) + + add_compiler_rt_runtime(clang_rt.ubsan_standalone + SHARED + ARCHS ${arch} + OBJECT_LIBS RTSanitizerCommon RTSanitizerCommonLibc RTSanitizerCommonCoverage RTSanitizerCommonSymbolizer RTSanitizerCommonSymbolizerInternal RTUbsan + RTUbsan_cxx RTUbsan_standalone RTInterception - CFLAGS ${UBSAN_CFLAGS} - PARENT_TARGET ubsan) - - add_compiler_rt_runtime(clang_rt.ubsan_standalone_cxx - STATIC - ARCHS ${UBSAN_SUPPORTED_ARCH} - OBJECT_LIBS RTUbsan_cxx - CFLAGS ${UBSAN_CXXFLAGS} - PARENT_TARGET ubsan) - - if (COMPILER_RT_HAS_VERSION_SCRIPT) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp "") - add_compiler_rt_object_libraries(RTUbsan_dynamic_version_script_dummy - ARCHS ${UBSAN_SUPPORTED_ARCH} - SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp - CFLAGS ${UBSAN_CFLAGS}) - - foreach(arch ${UBSAN_SUPPORTED_ARCH}) - add_sanitizer_rt_version_list(clang_rt.ubsan_standalone-dynamic-${arch} - LIBS clang_rt.ubsan_standalone-${arch} - clang_rt.ubsan_standalone_cxx-${arch} - EXTRA ubsan.syms.extra) - set(VERSION_SCRIPT_FLAG - -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.ubsan_standalone-dynamic-${arch}.vers) - # The Solaris 11.4 linker supports a subset of GNU ld version scripts, - # but requires a special option to enable it. - if (COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT) - list(APPEND VERSION_SCRIPT_FLAG -Wl,-z,gnu-version-script-compat) - endif() - set_property(SOURCE - ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp - APPEND PROPERTY - OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.ubsan_standalone-dynamic-${arch}.vers) - - add_compiler_rt_runtime(clang_rt.ubsan_standalone - SHARED - ARCHS ${arch} - OBJECT_LIBS RTSanitizerCommon - RTSanitizerCommonLibc - RTSanitizerCommonCoverage - RTSanitizerCommonSymbolizer - RTSanitizerCommonSymbolizerInternal - RTUbsan - RTUbsan_cxx - RTUbsan_standalone - RTInterception - RTUbsan_dynamic_version_script_dummy - CFLAGS ${UBSAN_CFLAGS} - LINK_FLAGS ${UBSAN_LINK_FLAGS} ${VERSION_SCRIPT_FLAG} - LINK_LIBS ${UBSAN_DYNAMIC_LIBS} - PARENT_TARGET ubsan) - endforeach() - - set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH}) - list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386) - add_sanitizer_rt_symbols(clang_rt.ubsan_standalone - ARCHS ${ARCHS_FOR_SYMBOLS} - PARENT_TARGET ubsan - EXTRA ubsan.syms.extra) - add_sanitizer_rt_symbols(clang_rt.ubsan_standalone_cxx - ARCHS ${ARCHS_FOR_SYMBOLS} - PARENT_TARGET ubsan - EXTRA ubsan.syms.extra) - endif() + RTUbsan_dynamic_version_script_dummy + CFLAGS ${UBSAN_CFLAGS} + LINK_FLAGS ${UBSAN_LINK_FLAGS} ${VERSION_SCRIPT_FLAG} + LINK_LIBS ${UBSAN_DYNAMIC_LIBS} + PARENT_TARGET ubsan) + endforeach() + + set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH}) + list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386) + add_sanitizer_rt_symbols(clang_rt.ubsan_standalone + ARCHS ${ARCHS_FOR_SYMBOLS} + PARENT_TARGET ubsan + EXTRA ubsan.syms.extra) + add_sanitizer_rt_symbols(clang_rt.ubsan_standalone_cxx + ARCHS ${ARCHS_FOR_SYMBOLS} + PARENT_TARGET ubsan + EXTRA ubsan.syms.extra) endif() endif() diff --git a/compiler-rt/lib/ubsan_minimal/CMakeLists.txt b/compiler-rt/lib/ubsan_minimal/CMakeLists.txt index 07e96a70a49dce..1f6e50857e9dd6 100644 --- a/compiler-rt/lib/ubsan_minimal/CMakeLists.txt +++ b/compiler-rt/lib/ubsan_minimal/CMakeLists.txt @@ -24,32 +24,30 @@ add_compiler_rt_object_libraries(RTUbsan_minimal SOURCES ${UBSAN_MINIMAL_SOURCES} CFLAGS ${UBSAN_CFLAGS}) -if(COMPILER_RT_HAS_UBSAN_MINIMAL) - # Standalone minimal UBSan runtimes. - add_compiler_rt_runtime(clang_rt.ubsan_minimal - STATIC - OS ${UBSAN_SUPPORTED_OS} - ARCHS ${UBSAN_SUPPORTED_ARCH} - OBJECT_LIBS RTUbsan_minimal - CFLAGS ${UBSAN_CFLAGS} - PARENT_TARGET ubsan-minimal) - - add_compiler_rt_runtime(clang_rt.ubsan_minimal - SHARED - OS ${UBSAN_SUPPORTED_OS} - ARCHS ${UBSAN_SUPPORTED_ARCH} - OBJECT_LIBS RTUbsan_minimal - CFLAGS ${UBSAN_CFLAGS} - LINK_FLAGS ${UBSAN_LINK_FLAGS} - LINK_LIBS ${UBSAN_DYNAMIC_LIBS} - PARENT_TARGET ubsan-minimal) - - if (SANITIZER_USE_SYMBOLS AND NOT APPLE) - set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH}) - list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386 i686) - add_sanitizer_rt_symbols(clang_rt.ubsan_minimal - ARCHS ${ARCHS_FOR_SYMBOLS} - PARENT_TARGET ubsan-minimal - EXTRA ubsan.syms.extra) - endif() +# Standalone minimal UBSan runtimes. +add_compiler_rt_runtime(clang_rt.ubsan_minimal + STATIC + OS ${UBSAN_SUPPORTED_OS} + ARCHS ${UBSAN_SUPPORTED_ARCH} + OBJECT_LIBS RTUbsan_minimal + CFLAGS ${UBSAN_CFLAGS} + PARENT_TARGET ubsan-minimal) + +add_compiler_rt_runtime(clang_rt.ubsan_minimal + SHARED + OS ${UBSAN_SUPPORTED_OS} + ARCHS ${UBSAN_SUPPORTED_ARCH} + OBJECT_LIBS RTUbsan_minimal + CFLAGS ${UBSAN_CFLAGS} + LINK_FLAGS ${UBSAN_LINK_FLAGS} + LINK_LIBS ${UBSAN_DYNAMIC_LIBS} + PARENT_TARGET ubsan-minimal) + +if (SANITIZER_USE_SYMBOLS AND NOT APPLE) + set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH}) + list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386 i686) + add_sanitizer_rt_symbols(clang_rt.ubsan_minimal + ARCHS ${ARCHS_FOR_SYMBOLS} + PARENT_TARGET ubsan-minimal + EXTRA ubsan.syms.extra) endif() diff --git a/compiler-rt/test/cfi/CMakeLists.txt b/compiler-rt/test/cfi/CMakeLists.txt index 88def444d7dda1..98c328fdcf1152 100644 --- a/compiler-rt/test/cfi/CMakeLists.txt +++ b/compiler-rt/test/cfi/CMakeLists.txt @@ -59,9 +59,7 @@ list(APPEND CFI_TEST_DEPS ubsan stats ) -if(COMPILER_RT_HAS_CFI) - list(APPEND CFI_TEST_DEPS cfi) -endif() +list(APPEND CFI_TEST_DEPS cfi) if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND CFI_TEST_DEPS diff --git a/compiler-rt/test/gwp_asan/CMakeLists.txt b/compiler-rt/test/gwp_asan/CMakeLists.txt index 2a043cbae1c646..f9580e2592b2fe 100644 --- a/compiler-rt/test/gwp_asan/CMakeLists.txt +++ b/compiler-rt/test/gwp_asan/CMakeLists.txt @@ -14,7 +14,7 @@ set(GWP_ASAN_TEST_DEPS # exported libc++ from the Android NDK is x86-64, even though it's part of the # ARM[64] toolchain... See similar measures for ASan and sanitizer-common that # disable unit tests for Android. -if (COMPILER_RT_INCLUDE_TESTS AND COMPILER_RT_HAS_GWP_ASAN AND NOT ANDROID) +if (COMPILER_RT_INCLUDE_TESTS AND NOT ANDROID) list(APPEND GWP_ASAN_TEST_DEPS GwpAsanUnitTests) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.py.in @@ -22,7 +22,7 @@ if (COMPILER_RT_INCLUDE_TESTS AND COMPILER_RT_HAS_GWP_ASAN AND NOT ANDROID) list(APPEND GWP_ASAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/unit) endif() -if (COMPILER_RT_INCLUDE_TESTS AND COMPILER_RT_HAS_SCUDO_STANDALONE AND COMPILER_RT_HAS_GWP_ASAN) +if (COMPILER_RT_INCLUDE_TESTS AND COMPILER_RT_HAS_SCUDO_STANDALONE) foreach(arch ${GWP_ASAN_SUPPORTED_ARCH}) set(GWP_ASAN_TEST_TARGET_ARCH ${arch}) string(TOLOWER "-${arch}" GWP_ASAN_TEST_CONFIG_SUFFIX) diff --git a/compiler-rt/test/orc/CMakeLists.txt b/compiler-rt/test/orc/CMakeLists.txt index 944753bf5c33c9..927a8dac1cbd44 100644 --- a/compiler-rt/test/orc/CMakeLists.txt +++ b/compiler-rt/test/orc/CMakeLists.txt @@ -13,7 +13,7 @@ if (NOT ANDROID AND NOT COMPILER_RT_STANDALONE_BUILD AND endif() set(ORC_TEST_ARCH ${ORC_SUPPORTED_ARCH}) -if (COMPILER_RT_BUILD_ORC AND COMPILER_RT_HAS_ORC) +if (COMPILER_RT_BUILD_ORC) list(APPEND ORC_TEST_DEPS orc) foreach(arch ${ORC_TEST_ARCH}) set(ORC_TEST_TARGET_ARCH ${arch}) diff --git a/compiler-rt/test/rtsan/CMakeLists.txt b/compiler-rt/test/rtsan/CMakeLists.txt index ba1070467f1a37..2a59a57f273720 100644 --- a/compiler-rt/test/rtsan/CMakeLists.txt +++ b/compiler-rt/test/rtsan/CMakeLists.txt @@ -21,20 +21,18 @@ if(APPLE) darwin_filter_host_archs(RTSAN_SUPPORTED_ARCH RTSAN_TEST_ARCH) endif() -if (COMPILER_RT_HAS_RTSAN) - foreach(arch ${RTSAN_TEST_ARCH}) - set(RTSAN_TEST_TARGET_ARCH ${arch}) - string(TOLOWER "-${arch}-${OS_NAME}" RTSAN_TEST_CONFIG_SUFFIX) - get_test_cc_for_arch(${arch} RTSAN_TEST_TARGET_CC RTSAN_TEST_TARGET_CFLAGS) - string(TOUPPER ${arch} ARCH_UPPER_CASE) - set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) +foreach(arch ${RTSAN_TEST_ARCH}) + set(RTSAN_TEST_TARGET_ARCH ${arch}) + string(TOLOWER "-${arch}-${OS_NAME}" RTSAN_TEST_CONFIG_SUFFIX) + get_test_cc_for_arch(${arch} RTSAN_TEST_TARGET_CC RTSAN_TEST_TARGET_CFLAGS) + string(TOUPPER ${arch} ARCH_UPPER_CASE) + set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) - configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in - ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) - list(APPEND RTSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) - endforeach() -endif() + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py) + list(APPEND RTSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) +endforeach() if(COMPILER_RT_INCLUDE_TESTS) configure_lit_site_cfg( diff --git a/compiler-rt/test/scudo/standalone/CMakeLists.txt b/compiler-rt/test/scudo/standalone/CMakeLists.txt index aba057e677e28b..0034cea360f377 100644 --- a/compiler-rt/test/scudo/standalone/CMakeLists.txt +++ b/compiler-rt/test/scudo/standalone/CMakeLists.txt @@ -1,4 +1,4 @@ -if(COMPILER_RT_INCLUDE_TESTS AND COMPILER_RT_HAS_SCUDO_STANDALONE) +if(COMPILER_RT_INCLUDE_TESTS) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.py.in ${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg.py) diff --git a/compiler-rt/test/xray/CMakeLists.txt b/compiler-rt/test/xray/CMakeLists.txt index fd2a2f43e195dd..8c352d1fcfcb2e 100644 --- a/compiler-rt/test/xray/CMakeLists.txt +++ b/compiler-rt/test/xray/CMakeLists.txt @@ -5,13 +5,12 @@ set(XRAY_FDR_TESTSUITES) set(XRAY_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS} xray) -if(NOT COMPILER_RT_STANDALONE_BUILD AND COMPILER_RT_BUILD_XRAY AND - COMPILER_RT_HAS_XRAY) +if(NOT COMPILER_RT_STANDALONE_BUILD AND COMPILER_RT_BUILD_XRAY) list(APPEND XRAY_TEST_DEPS llvm-xray) endif() set(XRAY_TEST_ARCH ${XRAY_SUPPORTED_ARCH}) -if (COMPILER_RT_BUILD_XRAY AND COMPILER_RT_HAS_XRAY) +if (COMPILER_RT_BUILD_XRAY) foreach(arch ${XRAY_TEST_ARCH}) set(XRAY_TEST_TARGET_ARCH ${arch}) string(TOLOWER "-${arch}-${OS_NAME}" XRAY_TEST_CONFIG_SUFFIX)