Skip to content

Commit 74d3fd4

Browse files
committed
[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 14d2561 commit 74d3fd4

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ set(MSAN_UNITTEST_LINK_FLAGS
6363
# inputs.
6464
)
6565

66+
append_list_if(CMAKE_SYSROOT "--sysroot=${CMAKE_SYSROOT}" MSAN_UNITTEST_LINK_FLAGS)
6667
append_list_if(COMPILER_RT_HAS_LIBDL -ldl MSAN_UNITTEST_LINK_FLAGS)
6768

6869
macro(msan_compile obj_list source arch kind cflags)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
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+
)
2126
)
2227
# Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
2328
if config.host_os == "FreeBSD":

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ config.target_cflags = "@MSAN_TEST_TARGET_CFLAGS@"
66
config.target_arch = "@MSAN_TEST_TARGET_ARCH@"
77
config.use_lld = @MSAN_TEST_USE_LLD@
88
config.use_thinlto = @MSAN_TEST_USE_THINLTO@
9+
config.cmake_sysroot = "@CMAKE_SYSROOT@"
910

1011
# Load common config for all compiler-rt lit tests.
1112
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")

0 commit comments

Comments
 (0)