[PATCH] D38520: [sanitizer] Move cxx-abi library earlier in link flags.
Evgenii Stepanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 3 16:25:23 PDT 2017
eugenis created this revision.
Herald added subscribers: kristof.beyls, mgorny, kubamracek, aemerson.
This change moves cxx-abi library in asan/ubsan/dd link command line
ahead of other libraries, such as pthread/rt/dl/c/gcc. Given that
cxx-abi may be the full libstdc++/libc++, it makes sense for it to be
ahead of libc and libgcc, at least.
The real motivation is Android, where in the arm32 NDK toolchain
libstdc++.a is actually a linker script that tries to sneak LLVM's
libunwind ahead of libgcc's. Wrong library order breaks unwinding.
https://reviews.llvm.org/D38520
Files:
compiler-rt/lib/asan/CMakeLists.txt
compiler-rt/lib/tsan/dd/CMakeLists.txt
compiler-rt/lib/ubsan/CMakeLists.txt
Index: compiler-rt/lib/ubsan/CMakeLists.txt
===================================================================
--- compiler-rt/lib/ubsan/CMakeLists.txt
+++ compiler-rt/lib/ubsan/CMakeLists.txt
@@ -35,15 +35,13 @@
append_rtti_flag(ON UBSAN_CXXFLAGS)
append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CXXFLAGS)
-set(UBSAN_DYNAMIC_LIBS ${SANITIZER_COMMON_LINK_LIBS})
+set(UBSAN_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARY} ${SANITIZER_COMMON_LINK_LIBS})
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)
-list(APPEND UBSAN_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARY})
-
add_compiler_rt_component(ubsan)
if(APPLE)
Index: compiler-rt/lib/tsan/dd/CMakeLists.txt
===================================================================
--- compiler-rt/lib/tsan/dd/CMakeLists.txt
+++ compiler-rt/lib/tsan/dd/CMakeLists.txt
@@ -10,14 +10,12 @@
dd_interceptors.cc
)
-set(DD_LINKLIBS ${SANITIZER_COMMON_LINK_LIBS})
+set(DD_LINKLIBS ${SANITIZER_CXX_ABI_LIBRARY} ${SANITIZER_COMMON_LINK_LIBS})
append_list_if(COMPILER_RT_HAS_LIBDL dl DD_LINKLIBS)
append_list_if(COMPILER_RT_HAS_LIBRT rt DD_LINKLIBS)
append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread DD_LINKLIBS)
-list(APPEND DD_LINKLIBS ${SANITIZER_CXX_ABI_LIBRARY})
-
add_custom_target(dd)
# Deadlock detector is currently supported on 64-bit Linux only.
if(CAN_TARGET_x86_64 AND UNIX AND NOT APPLE AND NOT ANDROID)
Index: compiler-rt/lib/asan/CMakeLists.txt
===================================================================
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -67,16 +67,14 @@
-ftls-model=initial-exec ASAN_DYNAMIC_CFLAGS)
append_list_if(MSVC /DEBUG ASAN_DYNAMIC_LINK_FLAGS)
-set(ASAN_DYNAMIC_LIBS ${SANITIZER_COMMON_LINK_LIBS})
+set(ASAN_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARY} ${SANITIZER_COMMON_LINK_LIBS})
append_list_if(COMPILER_RT_HAS_LIBDL dl ASAN_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBRT rt ASAN_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBM m ASAN_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread ASAN_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBLOG log ASAN_DYNAMIC_LIBS)
-list(APPEND ASAN_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARY})
-
# Compile ASan sources into an object library.
add_compiler_rt_object_libraries(RTAsan_dynamic
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38520.117598.patch
Type: text/x-patch
Size: 2527 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171003/3debd718/attachment.bin>
More information about the llvm-commits
mailing list