[compiler-rt] 4cd8dd3 - [scudo][standalone] Link tests against libatomic if libatomic exists

Amy Kwan via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 22 11:47:39 PDT 2021


Author: Amy Kwan
Date: 2021-08-22T13:47:04-05:00
New Revision: 4cd8dd3fe05e099792e1494dedd074eb5ba289b6

URL: https://github.com/llvm/llvm-project/commit/4cd8dd3fe05e099792e1494dedd074eb5ba289b6
DIFF: https://github.com/llvm/llvm-project/commit/4cd8dd3fe05e099792e1494dedd074eb5ba289b6.diff

LOG: [scudo][standalone] Link tests against libatomic if libatomic exists

It is possible that libatomic does not exist on some systems. This patch updates
the scudo standalone tests to link against libatomic if the library exists.

This is an update to the original patch: https://reviews.llvm.org/D64134 and
aims to resolve https://bugs.llvm.org/show_bug.cgi?id=51431.

Differential Revision: https://reviews.llvm.org/D108503

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
index f4186eba16881..eaa47a04a179a 100644
--- a/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
+++ b/compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt
@@ -39,7 +39,10 @@ foreach(lib ${SANITIZER_TEST_CXX_LIBRARIES})
 endforeach()
 list(APPEND LINK_FLAGS -pthread)
 # Linking against libatomic is required with some compilers
-list(APPEND LINK_FLAGS -latomic)
+check_library_exists(atomic __atomic_load_8 "" COMPILER_RT_HAS_LIBATOMIC)
+if (COMPILER_RT_HAS_LIBATOMIC)
+  list(APPEND LINK_FLAGS -latomic)
+endif()
 
 set(SCUDO_TEST_HEADERS
   scudo_unit_test.h


        


More information about the llvm-commits mailing list