[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
This commit is contained in:
Amy Kwan 2021-08-22 13:46:52 -05:00
parent d8d84c9df8
commit 4cd8dd3fe0
1 changed files with 4 additions and 1 deletions

View File

@ -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