diff --git a/compiler-rt/lib/msan/tests/CMakeLists.txt b/compiler-rt/lib/msan/tests/CMakeLists.txt index a8500225337e6..26a86afd4674f 100644 --- a/compiler-rt/lib/msan/tests/CMakeLists.txt +++ b/compiler-rt/lib/msan/tests/CMakeLists.txt @@ -63,6 +63,9 @@ set(MSAN_UNITTEST_LINK_FLAGS # inputs. ) +append_list_if(CMAKE_SYSROOT "--sysroot=${CMAKE_SYSROOT}" MSAN_UNITTEST_COMMON_CFLAGS) +append_list_if(CMAKE_SYSROOT "--sysroot=${CMAKE_SYSROOT}" MSAN_UNITTEST_LINK_FLAGS) + append_list_if(COMPILER_RT_HAS_LIBDL -ldl MSAN_UNITTEST_LINK_FLAGS) macro(msan_compile obj_list source arch kind cflags) diff --git a/compiler-rt/test/msan/lit.cfg.py b/compiler-rt/test/msan/lit.cfg.py index 361be79e2557e..bcc6d693022ee 100644 --- a/compiler-rt/test/msan/lit.cfg.py +++ b/compiler-rt/test/msan/lit.cfg.py @@ -19,6 +19,8 @@ + [config.target_cflags] + config.debug_info_flags ) +if config.cmake_sysroot: + clang_msan_cflags += [f"--sysroot={config.cmake_sysroot}"] # Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD. if config.host_os == "FreeBSD": clang_msan_cflags += ["-lexecinfo", "-fPIC"] diff --git a/compiler-rt/test/msan/lit.site.cfg.py.in b/compiler-rt/test/msan/lit.site.cfg.py.in index 47264d0986946..41231359692ed 100644 --- a/compiler-rt/test/msan/lit.site.cfg.py.in +++ b/compiler-rt/test/msan/lit.site.cfg.py.in @@ -6,6 +6,7 @@ config.target_cflags = "@MSAN_TEST_TARGET_CFLAGS@" config.target_arch = "@MSAN_TEST_TARGET_ARCH@" config.use_lld = @MSAN_TEST_USE_LLD@ config.use_thinlto = @MSAN_TEST_USE_THINLTO@ +config.cmake_sysroot = "@CMAKE_SYSROOT@" # Load common config for all compiler-rt lit tests. lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")