-
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
error_index_generator stage 0 tests don't work with download-ci-llvm: "error while loading shared libraries: libLLVM-11-rust-1.49.0-nightly.so" #78778
Comments
I have |
Miri also runs into this when doing |
|
@jyn514 I believe this may have been resolved some time between the issue being created and now. When i tried to reproduce it locally (a4cbb44) the error index tests were able to start and run just fine. The tests failed with "error[E0658]: const generics are unstable" because some snippets use |
I just tried this and it still fails:
I haven't checked, but I assume the "incorrect version format" is precisely because there's still some error such as "cannot open shared object file" being reported. (That's what used to happen.) Note that I have |
It looks like
I printed the output of
|
That's stdout; what does stderr say? |
Ah yep, it's the "unable to load shared libraries" error message:
|
Inspecting the failing $ ldd build/x86_64-unknown-linux-gnu/stage0-tools-bin/miri
linux-vdso.so.1 (0x00007ffeac5f7000)
librustc_driver-110e2444bfbc1fba.so => not found
libstd-6593c2e4e017f5fb.so => not found
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f0f3d890000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f0f3d86e000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f0f3d728000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f0f3d55f000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f0f3dced000) Should bootstrap be fiddling with $ build/x86_64-unknown-linux-gnu/stage0-tools-bin/miri --version
build/x86_64-unknown-linux-gnu/stage0-tools-bin/miri: error while loading shared libraries: librustc_driver-110e2444bfbc1fba.so: cannot open shared object file: No such file or directory
$ export LD_LIBRARY_PATH=build/x86_64-unknown-linux-gnu/stage1/lib/
$ build/x86_64-unknown-linux-gnu/stage0-tools-bin/miri --version
rustc 1.51.0-dev |
The error is about I think |
The error you got first is a different one though. Possibly it's not loading the codegen backend. Can you try |
Ah, good to know.
That's odd... Given the dependency chain This is what I see when looking at the dependencies for $ ldd build/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-110e2444bfbc1fba.so
linux-vdso.so.1 (0x00007fff511fb000)
libstd-6593c2e4e017f5fb.so => /home/michael/Documents/forks/rust/build/x86_64-unknown-linux-gnu/stage1/lib/../lib/libstd-6593c2e4e017f5fb.so (0x00007fd8e30e2000)
libLLVM-11-rust-1.51.0-nightly.so => /home/michael/Documents/forks/rust/build/x86_64-unknown-linux-gnu/stage1/lib/../lib/libLLVM-11-rust-1.51.0-nightly.so (0x00007fd8de6a1000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fd8de494000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fd8de47a000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fd8de458000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007fd8de312000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fd8de30a000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007fd8de141000)
/usr/lib64/ld-linux-x86-64.so.2 (0x00007fd8e776f000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007fd8de127000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007fd8de11c000)
Looks like it's picking up LLVM just fine 🤷♂️ $ export LD_LIBRARY_PATH=build/x86_64-unknown-linux-gnu/stage1/lib/
$ build/x86_64-unknown-linux-gnu/stage0-tools-bin/miri -vV
rustc 1.51.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.51.0-dev
LLVM version: 11.0.1 |
Even on your machine it complained about LLVM, not rustc_driver. So far it doesn't look like there is a difference between our machines. FWIW, this also works here:
Probably |
It sounds like the only change that needs to happen is setting LD_LIBRARY_PATH correctly? |
Possibly? I don't know anything about our LD_LIBRARY_PATH handling.^^ |
Based on these comments on Zulip from @Mark-Simulacrum...
... we should set Is that the correct interpretation? Otherwise we could explicitly add the sysroot to the
|
So it looks like the issue is that we need some way to tell tools where to find LLVM and the other dynamic libraries it needs. What I've done is found where we create the
The places I've tried making this modification are:
I believe the fix for this issue should only take a couple lines, but I don't know where to put them because of my unfamiliarity with Rustbuild. I wouldn't be surprised if I was actually doing the right thing, but trying to link to the wrong stage or something. @jyn514 do you have any pointers? |
Those sound like questions for @Mark-Simulacrum |
tool_cmd sounds like the right place to me at a high level, yes - it'll be hard for me to be sure without rebuilding all of the context, but if you propose a PR that'll make it easier for me to evaluate. I don't think there's necessarily a "right place", if you find something that works for the stage 0 tools pretty much across the board that would be good enough most likely. |
I don't think it is a good idea to change the working directory; the tool might be invoked with relative paths that would then not work any more. But I also have no idea how the working directory is even determined currently. However, I also don't see why that would even help. The RPATH is set to |
@Mark-Simulacrum Moreover, let mut cargo = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolRustc,
host,
"run",
"src/tools/miri/cargo-miri",
SourceType::Submodule,
&[],
); |
Oh, that seems wrong. IIRC we generally don't build+run in one step, rather we run cargo build and then tool_cmd on the binary? Setting up the environment in prepare_tool_cargo seems feasible, too, though. |
We do already modify this variable in some places, but I don't think in a very principled way (so I'm not terribly surprised it's not working). I'm not sure I have enough time to investigate though, unfortunately. |
We later want to do Also, this does not build+run in one step. The build already happened earlier. But we use
Which variable? I did some more experiments and I can confirm that adding |
Okay, I found who's overwriting LD_LIBRARY_PATH, it was diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index 86d940cd733..96a94d43428 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -393,6 +392,12 @@ fn run(self, builder: &Builder<'_>) {
);
cargo.arg("--").arg("miri").arg("setup");
+ // Make sure we can access all the dynamic libraries.
+ let mut dylib_path = dylib_path();
+ let ci_llvm_lib = builder.out.join(&*host.triple).join("ci-llvm/lib");
+ dylib_path.insert(0, ci_llvm_lib);
+ cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
+ eprintln!("{} = {:?}", dylib_path_var(), env::join_paths(&dylib_path).unwrap());
// Tell `cargo miri setup` where to find the sources.
cargo.env("XARGO_RUST_SRC", builder.src.join("library"));
// Tell it where to find Miri.
@@ -442,6 +447,7 @@ fn run(self, builder: &Builder<'_>) {
SourceType::Submodule,
&[],
);
+ cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
// miri tests need to know about the stage sysroot
cargo.env("MIRI_SYSROOT", miri_sysroot);
@@ -450,7 +456,7 @@ fn run(self, builder: &Builder<'_>) {
cargo.arg("--").args(builder.config.cmd.test_args());
- cargo.add_rustc_lib_path(builder, compiler);
+ //cargo.add_rustc_lib_path(builder, compiler);
if !try_run(builder, &mut cargo.into()) {
return; I hope at some point someone can take this and turn it into something proper. ;) |
It is also worth noting that this is a regression -- testing Miri on stage 0 used to work just fine some time in summer/fall last year. I have no idea which rustbuild change broke things, though. EDIT: ah I remember, it's probably the pre-built LLVM download. |
So how can we make progress on this? I produced a working diff above, but it's a crude hack and only fixes the problem for Miri. I don't know nearly enough about rustbuild to figure out the proper fix for this though -- there are lots of moving pieces here, so this is unlikely to be fixed until someone from the rustbuild team can take a look. That would be much appreciated. :) |
@RalfJung there is not really a rustbuild team - there's me and Mark-Simulacrum, and ehuss has a fair bit of knowledge I think. I'm on break for a while and Simulacrum is always busy. |
I mean, I guess that makes you two (or three) the rustbuild team. At least this is exactly how I became part of the Miri and const-eval teams. ;) |
Regarding the problem at hand, I could probably try patching |
@RalfJung sure, that seems reasonable. |
Reopening as the issue persists for error_index_generator specifically, which has some custom logic for dylib paths that still needs adjusting: Lines 396 to 400 in 903e369
|
The text was updated successfully, but these errors were encountered: