[compiler-rt] d38a8e9 - Undo lsan part of #98240 (#98409)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 16:34:58 PDT 2024
Author: Vitaly Buka
Date: 2024-07-10T16:34:55-07:00
New Revision: d38a8e937b51f52ab4c324b99d984d3031833b63
URL: https://github.com/llvm/llvm-project/commit/d38a8e937b51f52ab4c324b99d984d3031833b63
DIFF: https://github.com/llvm/llvm-project/commit/d38a8e937b51f52ab4c324b99d984d3031833b63.diff
LOG: Undo lsan part of #98240 (#98409)
Undo lsan, ubsan from #98240 and
388c55a3e676a75ac242ff4f2db3fa39e5f0b0a3
There are parts which do not check COMPILER_RT_HAS_*.
Added:
Modified:
compiler-rt/lib/CMakeLists.txt
compiler-rt/lib/lsan/CMakeLists.txt
compiler-rt/lib/ubsan/CMakeLists.txt
Removed:
################################################################################
diff --git a/compiler-rt/lib/CMakeLists.txt b/compiler-rt/lib/CMakeLists.txt
index 0e494bfa5939d..5b2395ea8eba3 100644
--- a/compiler-rt/lib/CMakeLists.txt
+++ b/compiler-rt/lib/CMakeLists.txt
@@ -38,8 +38,10 @@ 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 RTLSanCommon used even without COMPILER_RT_HAS_LSAN.
+ add_subdirectory(lsan)
+ # Contains RTUbsan used even without COMPILER_RT_HAS_UBSAN.
+ 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()
diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt
index a1cfbe93b068d..db0b33f1276ef 100644
--- a/compiler-rt/lib/ubsan/CMakeLists.txt
+++ b/compiler-rt/lib/ubsan/CMakeLists.txt
@@ -92,45 +92,47 @@ if(APPLE)
ADDITIONAL_HEADERS ${UBSAN_HEADERS}
CFLAGS ${UBSAN_CXXFLAGS})
- # 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)
+ 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})
- 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)
+ add_weak_symbols("ubsan" WEAK_SYMBOL_LINK_FLAGS)
+ add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)
- if (NOT APPLE)
add_compiler_rt_runtime(clang_rt.ubsan
- STATIC
+ SHARED
OS ${UBSAN_SUPPORTED_OS}
ARCHS ${UBSAN_SUPPORTED_ARCH}
OBJECT_LIBS RTUbsan
RTUbsan_standalone
- RTSanitizerCommonNoHooks
- RTSanitizerCommonLibcNoHooks
+ RTSanitizerCommon
+ RTSanitizerCommonLibc
RTSanitizerCommonCoverage
- RTSanitizerCommonSymbolizerNoHooks
+ RTSanitizerCommonSymbolizer
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()
@@ -188,89 +190,91 @@ else()
DEFS ${UBSAN_COMMON_DEFINITIONS})
endif()
- 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
+ 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
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
+ SOURCES
+ ubsan_init_standalone_preinit.cpp
+ ADDITIONAL_HEADERS ${UBSAN_HEADERS}
+ 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)
+ 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()
endif()
endif()
More information about the llvm-commits
mailing list