Skip to content

Commit c7cf3c4

Browse files
committed
amend! amend! [compiler-rt] Propagate sysroot from CMake to msan tests
[compiler-rt] Propagate sysroot from CMake to msan tests Some msan tests requires rpc/xdr.h, which is no longer available in some newer glibc. In build systems with hermetic sysroot set through CMake, this issue can be solved by setting the sysroot to CMAKE_SYSROOT for these tests. This patch implements it.
1 parent 215d995 commit c7cf3c4

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

compiler-rt/lib/msan/tests/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ set(MSAN_UNITTEST_LINK_FLAGS
6363
# inputs.
6464
)
6565

66-
if (LINUX)
67-
append_list_if(CMAKE_SYSROOT "--sysroot=${CMAKE_SYSROOT}" MSAN_UNITTEST_LINK_FLAGS)
68-
endif()
66+
append_list_if(CMAKE_SYSROOT "--sysroot=${CMAKE_SYSROOT}" MSAN_UNITTEST_COMMON_CFLAGS)
67+
append_list_if(CMAKE_SYSROOT "--sysroot=${CMAKE_SYSROOT}" MSAN_UNITTEST_LINK_FLAGS)
6968

70-
append_list_if(COMPILER_RT_HAS_LIBDL -ldl MSAN_UNITTEST_LINK_FLAGS)
69+
append_list_if(COMPILER_RT_HAS_LIBDL -ldl MSAN_UNITTEST_LINK_FLAGS)
7170

7271
macro(msan_compile obj_list source arch kind cflags)
7372
sanitizer_test_compile(

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@
1818
]
1919
+ [config.target_cflags]
2020
+ config.debug_info_flags
21-
+ (
22-
["--sysroot", config.cmake_sysroot]
23-
if config.cmake_sysroot and config.host_os == "Linux"
24-
else []
25-
)
2621
)
22+
if config.cmake_sysroot:
23+
clang_msan_cflags += [f"--sysroot={config.cmake_sysroot}"]
2724
# Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
2825
if config.host_os == "FreeBSD":
2926
clang_msan_cflags += ["-lexecinfo", "-fPIC"]

0 commit comments

Comments
 (0)