-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[compiler-rt] Propagate sysroot from CMake to msan tests #132299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Haowei (zeroomega) ChangesSome 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. Full diff: https://github.com/llvm/llvm-project/pull/132299.diff 2 Files Affected:
diff --git a/compiler-rt/test/msan/lit.cfg.py b/compiler-rt/test/msan/lit.cfg.py
index 361be79e2557e..7282d29340201 100644
--- a/compiler-rt/test/msan/lit.cfg.py
+++ b/compiler-rt/test/msan/lit.cfg.py
@@ -17,6 +17,10 @@
"-fno-optimize-sibling-calls",
]
+ [config.target_cflags]
+ + [
+ "--sysroot",
+ config.cmake_sysroot
+ ] if config.cmake_sysroot and config.host_os == "Linux" else []
+ config.debug_info_flags
)
# Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
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")
|
✅ With the latest revision this PR passed the Python code formatter. |
5c8a61c
to
83b012a
Compare
compiler-rt/test/msan/lit.cfg.py
Outdated
@@ -17,7 +17,9 @@ | |||
"-fno-optimize-sibling-calls", | |||
] | |||
+ [config.target_cflags] | |||
+ config.debug_info_flags | |||
+ ["--sysroot", config.cmake_sysroot] | |||
if config.cmake_sysroot and config.host_os == "Linux" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we do that for entire compiler-rt?
https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/lit.common.configured.in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried but ran into some further issues as some rtsan unit tests are not compatible with older glibc as memfd_create
was not defined in glibc 2.19, it still can be invoked through syscall wrappers but that probably needs a separate patch. Therefore, I current limit the change to msan on Linux only to avoid other unwanted breakages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's seems like incremental which which does not lead us to desired direction.
Could you try to figure out rtsan issue instead?
74d3fd4
to
9637a8a
Compare
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.
@@ -63,7 +63,11 @@ set(MSAN_UNITTEST_LINK_FLAGS | |||
# inputs. | |||
) | |||
|
|||
append_list_if(COMPILER_RT_HAS_LIBDL -ldl MSAN_UNITTEST_LINK_FLAGS) | |||
if (LINUX) | |||
append_list_if(CMAKE_SYSROOT "--sysroot=${CMAKE_SYSROOT}" MSAN_UNITTEST_LINK_FLAGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be included in MSAN_UNITTEST_COMMON_CFLAGS
as well.
[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.
9637a8a
to
215d995
Compare
[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.
@@ -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@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a nit, but I'd suggest calling it just sysroot
, the fact that it comes from CMake
isn't relevant.
config.cmake_sysroot = "@CMAKE_SYSROOT@" | |
config.sysroot = "@CMAKE_SYSROOT@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's good enough @petrhosek, then it's good enough for me. LGTM
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.