[compiler-rt] Undo lsan part of #98240 (PR #98409)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 16:05:18 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>

And 388c55a3e676a75ac242ff4f2db3fa39e5f0b0a3

Note: compiler_rt_build_runtime(ubsan) is coverad by the loop below.


---
Full diff: https://github.com/llvm/llvm-project/pull/98409.diff


2 Files Affected:

- (modified) compiler-rt/lib/CMakeLists.txt (+2-2) 
- (modified) compiler-rt/lib/lsan/CMakeLists.txt (+36-33) 


``````````diff
diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt
index 0e494bfa5939d..68352d1931f7c 100644
--- a/compiler-rt/lib/CMakeLists.txt
+++ b/compiler-rt/lib/CMakeLists.txt
@@ -38,8 +38,8 @@ endif()
 if(COMPILER_RT_BUILD_SANITIZERS)
   if(COMPILER_RT_HAS_SANITIZER_COMMON)
     add_subdirectory(stats)
-    compiler_rt_build_runtime(lsan)
-    compiler_rt_build_runtime(ubsan)
+    # Contains LSanCommon used even without COMPILER_RT_HAS_LSAN.
+    add_subdirectory(lsan)
   endif()
 
   foreach(sanitizer ${COMPILER_RT_SANITIZERS_TO_BUILD})
diff --git a/compiler-rt/lib/lsan/CMakeLists.txt b/compiler-rt/lib/lsan/CMakeLists.txt
index c7bb6449982c2..cece6238a7901 100644
--- a/compiler-rt/lib/lsan/CMakeLists.txt
+++ b/compiler-rt/lib/lsan/CMakeLists.txt
@@ -36,6 +36,7 @@ set(LSAN_HEADERS
 
 set(LSAN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
+# Used by asan/hwasan even without COMPILER_RT_HAS_LSAN.
 add_compiler_rt_object_libraries(RTLSanCommon
     OS ${SANITIZER_COMMON_SUPPORTED_OS}
     ARCHS ${LSAN_COMMON_SUPPORTED_ARCH}
@@ -43,44 +44,46 @@ add_compiler_rt_object_libraries(RTLSanCommon
     ADDITIONAL_HEADERS ${LSAN_HEADERS}
     CFLAGS ${LSAN_CFLAGS})
 
-add_compiler_rt_component(lsan)
-if(APPLE)
-  set(LSAN_LINK_LIBS ${SANITIZER_COMMON_LINK_LIBS})
+if(COMPILER_RT_HAS_LSAN)
+  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
-      STATIC
-      ARCHS ${arch}
+      SHARED
+      OS ${LSAN_SUPPORTED_OS}
+      ARCHS ${LSAN_SUPPORTED_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)
-  endforeach()
+  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()
 endif()

``````````

</details>


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


More information about the llvm-commits mailing list