-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix run make tests when it can't find dynamically linked librustc #123100
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Some changes occurred in src/tools/compiletest cc @jieyouxu |
@@ -3784,6 +3784,7 @@ impl<'test> TestCx<'test> { | |||
.env("TMPDIR", &tmpdir) | |||
.env("LD_LIB_PATH_ENVVAR", dylib_env_var()) | |||
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path)) | |||
.env("LD_LIBRARY_PATH", cwd.join(&self.config.compile_lib_path)) |
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.
Hmm, I wonder if this is the right place to solve it. The original run-make specifies LD_LIBRARY_PATH
via LD_LIB_PATH_ENVVAR
(when that is the correct LD_LIB_PATH_ENVVAR
for the target):
rust/src/tools/compiletest/src/runtest.rs
Line 3582 in 7f3a62b
.env("LD_LIB_PATH_ENVVAR", dylib_env_var()) |
In tools.mk
, then LD_LIBRARY_PATH
(which is the suitable LD_LIB_PATH_ENVVAR
) is set to the correct paths
Lines 3 to 6 in 536606b
HOST_RPATH_ENV = \ | |
$(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))" | |
TARGET_RPATH_ENV = \ | |
$(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))" |
My guess is that
rust/src/tools/run-make-support/src/lib.rs
Lines 142 to 154 in 536606b
let ld_lib_path_envvar = env::var("LD_LIB_PATH_ENVVAR").unwrap(); | |
let mut cmd = Command::new(bin_path); | |
cmd.env(&ld_lib_path_envvar, { | |
let mut paths = vec![]; | |
paths.push(PathBuf::from(env::var("TMPDIR").unwrap())); | |
for p in env::split_paths(&env::var("TARGET_RPATH_ENV").unwrap()) { | |
paths.push(p.to_path_buf()); | |
} | |
for p in env::split_paths(&env::var(&ld_lib_path_envvar).unwrap()) { | |
paths.push(p.to_path_buf()); | |
} | |
env::join_paths(paths.iter()).unwrap() | |
}); |
is broken, but this should be the correct place to fix it. In particular, I think you'd just need to preserve the semantics of
HOST_RPATH_ENV = \
$(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
TARGET_RPATH_ENV = \
$(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))"
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.
Ah, I think "TARGET_RPATH_ENV"
should instead be TARGET_RPATH_DIR
? Can you check if that fixes the issue?
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.
@jieyouxu Updating TARGET_RPATH_ENV
with TARGET_RAPTH_DIR
doesn't work on sgx.
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.
Hmm nevermind then. I see the original run-make test also had this issue...
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.
Actually, could you try changing
- for p in env::split_paths(&env::var("TARGET_RPATH_ENV").unwrap()) {
- paths.push(p.to_path_buf());
- }
+ for p in env::split_paths(&env::var("HOST_RPATH_DIR").unwrap()) {
+ paths.push(p.to_path_buf());
+ }
+ for p in env::split_paths(&env::var("TARGET_RPATH_DIR").unwrap()) {
+ paths.push(p.to_path_buf());
+ }
Judging from #113889, HOST_RPATH_DIR
should have the paths you need (I hope)
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.
Fixing this with something like this makes sense to me.
Fixed in #123763 |
The recent updates to run make support caused the following tests to break on sgx i.e. target
x86_64-fortanix-unknown-sgx
:The error observed was:
Providing the LD_LIBRARY_PATH for compiling and running the tests fixes the issue. Similar fix from the past - #113889 for a similar error.
@jethrogb @raoulstrackx