[compiler-rt] 0f50d01 - Revert RTSanitizerCommonSymbolizerInternal changes
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 8 08:03:39 PDT 2023
Author: Jonas Devlieghere
Date: 2023-09-08T08:03:34-07:00
New Revision: 0f50d0108c7ee8b081574a76816a428e30c6701a
URL: https://github.com/llvm/llvm-project/commit/0f50d0108c7ee8b081574a76816a428e30c6701a
DIFF: https://github.com/llvm/llvm-project/commit/0f50d0108c7ee8b081574a76816a428e30c6701a.diff
LOG: Revert RTSanitizerCommonSymbolizerInternal changes
This reverts the following commits:
- 5d7b75e2a5846f72f04a6fdb25a0df338f1825a1
[NFC][memprof] Temporarly remove RTSanitizerCommonSymbolizerInternal
- edb211cb78317ad73aa4bd2d3df75194b7f23a72
[NFC][memprof] Temporarly remove RTSanitizerCommonSymbolizerInternal
- 4d14b4a872577bf7ab5ef5bb6f8a2f10781a5f18
[sanitizer] Add CMake flag to build with internal symbolizer
They break macOS nodes because CMake can't evaluate generator expressions:
Error evaluating generator expression:
$<TARGET_OBJECTS:RTSanitizerCommonSymbolizerInternal.osx>
$<TARGET_OBJECTS:RTSanitizerCommonSymbolizerInternal.ios>
$<TARGET_OBJECTS:RTSanitizerCommonSymbolizerInternal.iossim>
Added:
Modified:
compiler-rt/CMakeLists.txt
compiler-rt/lib/hwasan/CMakeLists.txt
compiler-rt/lib/memprof/CMakeLists.txt
compiler-rt/lib/sanitizer_common/CMakeLists.txt
compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
compiler-rt/lib/stats/CMakeLists.txt
compiler-rt/lib/ubsan/CMakeLists.txt
Removed:
compiler-rt/lib/sanitizer_common/symbolizer/CMakeLists.txt
################################################################################
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt
index 737ba774a172805..3888995811d8945 100644
--- a/compiler-rt/CMakeLists.txt
+++ b/compiler-rt/CMakeLists.txt
@@ -727,9 +727,6 @@ endif()
pythonize_bool(COMPILER_RT_HAS_LLD)
pythonize_bool(COMPILER_RT_TEST_USE_LLD)
-option(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER "Build Compiler RT linked with in LLVM symbolizer" OFF)
-mark_as_advanced(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
-
add_subdirectory(lib)
if(COMPILER_RT_INCLUDE_TESTS)
diff --git a/compiler-rt/lib/hwasan/CMakeLists.txt b/compiler-rt/lib/hwasan/CMakeLists.txt
index e7b3f5e005f8e2e..1b5775d9435d7e0 100644
--- a/compiler-rt/lib/hwasan/CMakeLists.txt
+++ b/compiler-rt/lib/hwasan/CMakeLists.txt
@@ -164,8 +164,6 @@ function(add_hwasan_runtimes arch use_aliases)
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
- # FIXME: disable tagging when in symbolizer.
- # RTSanitizerCommonSymbolizerInternal
RTLSanCommon
RTUbsan
CFLAGS ${hwasan_rtl_flags}
@@ -203,8 +201,6 @@ function(add_hwasan_runtimes arch use_aliases)
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
- # FIXME: disable tagging when in symbolizer.
- # RTSanitizerCommonSymbolizerInternal
RTLSanCommon
RTUbsan
RTUbsan_cxx
diff --git a/compiler-rt/lib/memprof/CMakeLists.txt b/compiler-rt/lib/memprof/CMakeLists.txt
index 3f55c2f5e075eed..2459ce13ab743cb 100644
--- a/compiler-rt/lib/memprof/CMakeLists.txt
+++ b/compiler-rt/lib/memprof/CMakeLists.txt
@@ -127,10 +127,7 @@ set(MEMPROF_COMMON_RUNTIME_OBJECT_LIBS
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
- RTSanitizerCommonSymbolizer
- # FIXME: hangs.
- # RTSanitizerCommonSymbolizerInternal
-)
+ RTSanitizerCommonSymbolizer)
add_compiler_rt_runtime(clang_rt.memprof
STATIC
diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index 25304b71c0c7061..d8517f3de06a493 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -362,7 +362,3 @@ foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH})
add_library(RTSanitizerCommonSymbolizerInternal.${arch}
OBJECT IMPORTED GLOBAL)
endforeach()
-
-if (COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
- add_subdirectory(symbolizer)
-endif()
diff --git a/compiler-rt/lib/sanitizer_common/symbolizer/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/symbolizer/CMakeLists.txt
deleted file mode 100644
index 49ff201066bcf92..000000000000000
--- a/compiler-rt/lib/sanitizer_common/symbolizer/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-foreach(arch ${SANITIZER_COMMON_SUPPORTED_ARCH})
- get_target_flags_for_arch(${arch} TARGET_CFLAGS)
-
- set(RTSanitizerCommonSymbolizerInternalDir
- "${CMAKE_CURRENT_BINARY_DIR}/RTSanitizerCommonSymbolizerInternal.${arch}")
- add_custom_command(OUTPUT ${RTSanitizerCommonSymbolizerInternalDir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${RTSanitizerCommonSymbolizerInternalDir})
-
- add_custom_command(OUTPUT RTSanitizerCommonSymbolizerInternal.${arch}.o
- DEPENDS ${RTSanitizerCommonSymbolizerInternalDir}
- clang lld llvm-tblgen opt llvm-ar llvm-link llvm-ranlib llvm-symbolizer
- sanitizer_wrappers.cpp
- sanitizer_symbolize.cpp
- scripts/build_symbolizer.sh
- WORKING_DIRECTORY ${RTSanitizerCommonSymbolizerInternalDir}
- COMMAND FLAGS=${TARGET_CFLAGS}
- CLANG=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
- ${CMAKE_CURRENT_SOURCE_DIR}/scripts/build_symbolizer.sh
- ${CMAKE_CURRENT_BINARY_DIR}/RTSanitizerCommonSymbolizerInternal.${arch}.o
- USES_TERMINAL)
-
- add_custom_target(RTSanitizerCommonSymbolizerInternalObj.${arch}
- DEPENDS RTSanitizerCommonSymbolizerInternal.${arch}.o)
-
- set_property(TARGET RTSanitizerCommonSymbolizerInternal.${arch}
- PROPERTY IMPORTED_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/RTSanitizerCommonSymbolizerInternal.${arch}.o)
-endforeach()
diff --git a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
index 524ddca1b9f3e4f..ec3f73ab21fb4b2 100755
--- a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
+++ b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
@@ -3,16 +3,26 @@
# Run as: CLANG=bin/clang build_symbolizer.sh out.o
# zlib can be downloaded from http://www.zlib.net.
#
-# Script compiles self-contained object file with symbolization code.
+# Script compiles self-contained object file with symbolization code and injects
+# it into the given set of runtime libraries. Script updates only libraries
+# which has unresolved __sanitizer_symbolize_* symbols and matches architecture.
+# Object file is be compiled from LLVM sources with dependencies like libc++ and
+# zlib. Then it internalizes symbols in the file, so that it can be linked
+# into arbitrary programs, avoiding conflicts with the program own symbols and
+# avoiding dependencies on any program symbols. The only acceptable dependencies
+# are libc and __sanitizer::internal_* from sanitizer runtime.
#
# Symbols exported by the object file will be used by Sanitizer runtime
# libraries to symbolize code/data in-process.
#
+# The script will modify the output directory which is given as the first
+# argument to the script.
+#
# FIXME: We should really be using a simpler approach to building this object
# file, and it should be available as a regular cmake rule. Conceptually, we
# want to be doing "ld -r" followed by "objcopy -G" to create a relocatable
# object file with only our entry points exposed. However, this does not work at
-# present, see https://github.com/llvm/llvm-project/issues/30098.
+# present, see PR30750.
set -x
set -e
@@ -20,7 +30,7 @@ set -u
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
SRC_DIR=$(readlink -f $SCRIPT_DIR/..)
-OUTPUT=$(readlink -f $1)
+TARGE_DIR=$(readlink -f $1)
COMPILER_RT_SRC=$(readlink -f ${SCRIPT_DIR}/../../../..)
LLVM_SRC=${LLVM_SRC:-${COMPILER_RT_SRC}/../llvm}
LLVM_SRC=$(readlink -f $LLVM_SRC)
@@ -176,6 +186,20 @@ nm -f posix -g symbolizer.o | cut -f 1,2 -d \ | LC_COLLATE=C sort -u > undefine
(
diff -u $SCRIPT_DIR/global_symbols.txt undefined.new | grep -E "^\+[^+]") && \
(echo "Failed: unexpected symbols"; exit 1)
-cp -f symbolizer.o $OUTPUT
+arch() {
+ objdump -f $1 | grep -m1 -Po "(?<=file format ).*$"
+}
+
+SYMBOLIZER_FORMAT=$(arch symbolizer.o)
+echo "Injecting $SYMBOLIZER_FORMAT symbolizer..."
+for A in $TARGE_DIR/libclang_rt.*san*.a; do
+ A_FORMAT=$(arch $A)
+ if [[ "$A_FORMAT" != "$SYMBOLIZER_FORMAT" ]] ; then
+ continue
+ fi
+ (nm -u $A 2>/dev/null | grep -E "__sanitizer_symbolize_code" >/dev/null) || continue
+ echo "$A"
+ $AR rcs $A symbolizer.o
+done
echo "Success!"
diff --git a/compiler-rt/lib/stats/CMakeLists.txt b/compiler-rt/lib/stats/CMakeLists.txt
index 61b5b4524896cbb..60c02556f80d615 100644
--- a/compiler-rt/lib/stats/CMakeLists.txt
+++ b/compiler-rt/lib/stats/CMakeLists.txt
@@ -29,7 +29,6 @@ add_compiler_rt_runtime(clang_rt.stats
OBJECT_LIBS RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonSymbolizer
- RTSanitizerCommonSymbolizerInternal
CFLAGS ${SANITIZER_COMMON_CFLAGS}
LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
LINK_LIBS ${STATS_LINK_LIBS}
diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt
index 93730561523a94c..520a024fbedee59 100644
--- a/compiler-rt/lib/ubsan/CMakeLists.txt
+++ b/compiler-rt/lib/ubsan/CMakeLists.txt
@@ -71,9 +71,6 @@ append_list_if(COMPILER_RT_HAS_LIBDL dl UBSAN_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBLOG log UBSAN_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBRT rt UBSAN_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread UBSAN_DYNAMIC_LIBS)
-if (COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
- append_list_if(COMPILER_RT_HAS_LIBM m UBSAN_DYNAMIC_LIBS)
-endif()
add_compiler_rt_component(ubsan)
@@ -207,8 +204,6 @@ else()
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
- # FIXME: Some wrong with C++ demangling.
- # RTSanitizerCommonSymbolizerInternal
RTUbsan
RTUbsan_standalone
RTInterception
@@ -253,8 +248,6 @@ else()
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
- # FIXME: Some wrong with C++ demangling.
- # RTSanitizerCommonSymbolizerInternal
RTUbsan
RTUbsan_cxx
RTUbsan_standalone
More information about the llvm-commits
mailing list