[PATCH] D139782: [scudo][standalone] Use CheckAtomic to decide to link to libatomic
Ben Wolsieffer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 28 19:48:51 PDT 2023
benwolsieffer updated this revision to Diff 554141.
benwolsieffer added a comment.
Rebased on main
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139782/new/
https://reviews.llvm.org/D139782
Files:
compiler-rt/lib/scudo/standalone/CMakeLists.txt
compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
llvm/cmake/modules/CheckAtomic.cmake
Index: llvm/cmake/modules/CheckAtomic.cmake
===================================================================
--- llvm/cmake/modules/CheckAtomic.cmake
+++ llvm/cmake/modules/CheckAtomic.cmake
@@ -2,6 +2,7 @@
INCLUDE(CheckCXXSourceCompiles)
INCLUDE(CheckLibraryExists)
+INCLUDE(DetermineGCCCompatible)
# Sometimes linking against libatomic is required for atomic ops, if
# the platform doesn't support lock-free atomics.
Index: compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
===================================================================
--- compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
+++ compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
@@ -43,13 +43,9 @@
set(SCUDO_UNITTEST_LINK_FLAGS
${COMPILER_RT_UNITTEST_LINK_FLAGS}
${COMPILER_RT_UNWINDER_LINK_LIBS}
- ${SANITIZER_TEST_CXX_LIBRARIES})
+ ${SANITIZER_TEST_CXX_LIBRARIES}
+ ${LLVM_ATOMIC_LIB})
list(APPEND SCUDO_UNITTEST_LINK_FLAGS -pthread -no-pie)
-# Linking against libatomic is required with some compilers
-check_library_exists(atomic __atomic_load_8 "" COMPILER_RT_HAS_LIBATOMIC)
-if (COMPILER_RT_HAS_LIBATOMIC)
- list(APPEND SCUDO_UNITTEST_LINK_FLAGS -latomic)
-endif()
set(SCUDO_TEST_HEADERS
scudo_unit_test.h
Index: compiler-rt/lib/scudo/standalone/CMakeLists.txt
===================================================================
--- compiler-rt/lib/scudo/standalone/CMakeLists.txt
+++ compiler-rt/lib/scudo/standalone/CMakeLists.txt
@@ -1,5 +1,7 @@
add_compiler_rt_component(scudo_standalone)
+include(CheckAtomic)
+
include_directories(../.. include)
set(SCUDO_CFLAGS)
@@ -33,7 +35,7 @@
append_list_if(COMPILER_RT_HAS_WTHREAD_SAFETY_FLAG -Werror=thread-safety
SCUDO_CFLAGS)
-set(SCUDO_LINK_FLAGS)
+set(SCUDO_LINK_FLAGS ${LLVM_ATOMIC_LIB})
list(APPEND SCUDO_LINK_FLAGS -Wl,-z,defs,-z,now,-z,relro)
@@ -185,10 +187,6 @@
append_list_if(FUCHSIA zircon SCUDO_LINK_LIBS)
-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}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139782.554141.patch
Type: text/x-patch
Size: 2172 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230829/4d1cd3b0/attachment.bin>
More information about the llvm-commits
mailing list