[compiler-rt] [𝘀𝗽𝗿] initial version (PR #98245)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 16:44:32 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-xray

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>

Created using spr 1.3.4


---

Patch is 31.63 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/98245.diff


14 Files Affected:

- (modified) compiler-rt/lib/CMakeLists.txt (+2-2) 
- (modified) compiler-rt/lib/gwp_asan/CMakeLists.txt (+37-39) 
- (modified) compiler-rt/lib/lsan/CMakeLists.txt (+33-35) 
- (modified) compiler-rt/lib/nsan/CMakeLists.txt (+23-25) 
- (modified) compiler-rt/lib/scudo/standalone/CMakeLists.txt (+46-48) 
- (modified) compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt (+18-20) 
- (modified) compiler-rt/lib/ubsan/CMakeLists.txt (+104-108) 
- (modified) compiler-rt/lib/ubsan_minimal/CMakeLists.txt (+26-28) 
- (modified) compiler-rt/test/cfi/CMakeLists.txt (+1-3) 
- (modified) compiler-rt/test/gwp_asan/CMakeLists.txt (+2-2) 
- (modified) compiler-rt/test/orc/CMakeLists.txt (+1-1) 
- (modified) compiler-rt/test/rtsan/CMakeLists.txt (+11-13) 
- (modified) compiler-rt/test/scudo/standalone/CMakeLists.txt (+1-1) 
- (modified) compiler-rt/test/xray/CMakeLists.txt (+2-3) 


``````````diff
diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt
index f9e96563b8809..73a2ee46291ee 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 bb5b2902f99db..fdb6a95fe1404 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 8e9861cd6b7c0..c7bb6449982c2 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}
+              $<TARGET_OBJECTS:RTInterception.${arch}>
+              $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+              $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
+              $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
+              $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
+              $<TARGET_OBJECTS:RTSanitizerCommonSymbolizerInternal.${arch}>
+              $<TARGET_OBJECTS:RTLSanCommon.${arch}>
       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}
-                $<TARGET_OBJECTS:RTInterception.${arch}>
-                $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
-                $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
-                $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
-                $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
-                $<TARGET_OBJECTS:RTSanitizerCommonSymbolizerInternal.${arch}>
-                $<TARGET_OBJECTS:RTLSanCommon.${arch}>
-        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 36c7b2b9dfada..aef9b651ab2ec 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}
-              $<TARGET_OBJECTS:RTInterception.${arch}>
-              $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
-              $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
-              $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
-              $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
-              $<TARGET_OBJECTS:RTUbsan.${arch}>
-      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}
+            $<TARGET_OBJECTS:RTInterception.${arch}>
+            $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+            $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
+            $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
+            $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
+            $<TARGET_OBJECTS:RTUbsan.${arch}>
+    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 6fb4e88de3155..8fc245eb2cf38 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 1786756fa5ea6..672cdc0ba655e 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 $<TARGET_OBJECTS:RTScudoStandalone.${arch}>)
-      foreach(rtobject ${TEST_ADDITIONAL_RTOBJECTS})
-        list(APPEND SCUDO_TEST_RTOBJECTS $<TARGET_OBJECTS:${rtobject}.${arch}>)
-      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 $<TARGET_OBJECTS:RTScudoStandalone.${arch}>)
+    foreach(rtobject ${TEST_ADDITIONAL_RTOBJECTS})
+      list(APPEND SCUDO_TEST_RTOBJECTS $<TARGET_OBJECTS:${rtobject}.${arch}>)
     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 db0b33f1276ef..a1cfbe93b068d 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 ${...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/98245


More information about the llvm-commits mailing list