Skip to content

Commit 445978e

Browse files
committed
[compiler-rt] Use just built libatomic if available
Use libclang_rt.atomic.so instead of the libatomic installed on the system if it is available. Differential Revision: https://reviews.llvm.org/D151680
1 parent fe9b587 commit 445978e

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

compiler-rt/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pythonize_bool(COMPILER_RT_TEST_STANDALONE_BUILD_LIBS)
1414
pythonize_bool(LLVM_ENABLE_EXPENSIVE_CHECKS)
1515

1616
pythonize_bool(ZLIB_FOUND)
17+
pythonize_bool(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC)
1718

1819
pythonize_bool(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)
1920

compiler-rt/test/dfsan/libatomic.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clang_dfsan -g3 -DDATA_BYTES=3 %s -fno-exceptions -latomic -o %t && %run %t
2-
// RUN: %clang_dfsan -g3 -DDATA_BYTES=3 -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -fno-exceptions -latomic -o %t && %run %t
3-
// RUN: %clang_dfsan -g3 -DDATA_BYTES=32 %s -fno-exceptions -latomic -o %t && %run %t
4-
// RUN: %clang_dfsan -g3 -DDATA_BYTES=32 -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -fno-exceptions -latomic -o %t && %run %t
1+
// RUN: %clang_dfsan -g3 -DDATA_BYTES=3 %s -fno-exceptions %libatomic -o %t && %run %t
2+
// RUN: %clang_dfsan -g3 -DDATA_BYTES=3 -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -fno-exceptions %libatomic -o %t && %run %t
3+
// RUN: %clang_dfsan -g3 -DDATA_BYTES=32 %s -fno-exceptions %libatomic -o %t && %run %t
4+
// RUN: %clang_dfsan -g3 -DDATA_BYTES=32 -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -fno-exceptions %libatomic -o %t && %run %t
55

66
#include <assert.h>
77
#include <sanitizer/dfsan_interface.h>

compiler-rt/test/lit.common.cfg.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,16 @@ def is_windows_lto_supported():
933933
# preempt something we're looking to trap (e.g. _FORTIFY_SOURCE vs our ASAN).
934934
config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
935935

936+
if config.has_compiler_rt_libatomic:
937+
base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.atomic%s.so"
938+
% config.target_suffix)
939+
if sys.platform in ['win32'] and execute_external:
940+
# Don't pass dosish path separator to msys bash.exe.
941+
base_lib = base_lib.replace('\\', '/')
942+
config.substitutions.append(("%libatomic", base_lib + f" -Wl,-rpath,{config.compiler_rt_libdir}"))
943+
else:
944+
config.substitutions.append(("%libatomic", "-latomic"))
945+
936946
# Set LD_LIBRARY_PATH to pick dynamic runtime up properly.
937947
push_dynamic_library_lookup_path(config, config.compiler_rt_libdir)
938948

compiler-rt/test/lit.common.configured.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ set_default("have_rpc_xdr_h", @HAVE_RPC_XDR_H@)
4949
set_default("gwp_asan", @COMPILER_RT_HAS_GWP_ASAN_PYBOOL@)
5050
set_default("expensive_checks", @LLVM_ENABLE_EXPENSIVE_CHECKS_PYBOOL@)
5151
set_default("test_standalone_build_libs", @COMPILER_RT_TEST_STANDALONE_BUILD_LIBS_PYBOOL@)
52+
set_default("has_compiler_rt_libatomic", @COMPILER_RT_BUILD_STANDALONE_LIBATOMIC_PYBOOL@)
5253
# True iff the test suite supports ignoring the test compiler's runtime library path
5354
# and using `config.compiler_rt_libdir` instead. This only matters when the runtime
5455
# library paths differ.

compiler-rt/test/msan/libatomic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %clang_msan -fsanitize-memory-track-origins=2 -latomic -DTEST_STORE -O0 %s -o %t && %run %t 2>&1
2-
// RUN: %clang_msan -fsanitize-memory-track-origins=0 -latomic -DTEST_LOAD -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK
3-
// RUN: %clang_msan -fsanitize-memory-track-origins=2 -latomic -DTEST_LOAD -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SHADOW
1+
// RUN: %clang_msan -fsanitize-memory-track-origins=2 %libatomic -DTEST_STORE -O0 %s -o %t && %run %t 2>&1
2+
// RUN: %clang_msan -fsanitize-memory-track-origins=0 %libatomic -DTEST_LOAD -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK
3+
// RUN: %clang_msan -fsanitize-memory-track-origins=2 %libatomic -DTEST_LOAD -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SHADOW
44

55
// PPC has no libatomic
66
// UNSUPPORTED: powerpc64-target-arch

compiler-rt/test/msan/libatomic_load_exceptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx_msan -fexceptions -fsanitize-memory-track-origins=2 -latomic -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SHADOW
1+
// RUN: %clangxx_msan -fexceptions -fsanitize-memory-track-origins=2 %libatomic -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SHADOW
22

33
// PPC has no libatomic
44
// UNSUPPORTED: powerpc64-target-arch

0 commit comments

Comments
 (0)