From 4b6653da1e397d329d9a538f9f1247a52afc5999 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 23 Apr 2021 00:25:39 -0400 Subject: [PATCH 1/2] Allow running `x.py test src/test/linkchecker` with `download-llvm = true` Previously, the LD_LIBRARY_PATH for the linkchecker looked like `build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib`, because the linkchecker depends on the master copy of the standard library. This is true, but doesn't include the library path for the compiler libraries: ``` /home/joshua/src/rust/rust/build/x86_64-unknown-linux-gnu/stage1-tools-bin/error_index_generator: error while loading shared libraries: libLLVM-12-rust-1.53.0-nightly.so: cannot open shared object file: No such file or directory ``` That file is in `build/x86_64-unknown-linux-gnu/stage1/lib/libLLVM-12-rust-1.53.0-nightly.so`, which wasn't included in the dynamic path. This adds `build/x86_64-unknown-linux-gnu/stage1/lib` to the dynamic path for the linkchecker. --- src/bootstrap/tool.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index e85f4628fb03a..4f2426648fd8a 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -392,7 +392,10 @@ impl ErrorIndex { let compiler = builder.compiler(builder.top_stage.saturating_sub(1), builder.config.build); let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler })); add_dylib_path( - vec![PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host))], + vec![ + PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)), + PathBuf::from(builder.rustc_libdir(compiler)), + ], &mut cmd, ); cmd From 02f2e7c9c1d73034f4efaf9d0d6c78530b5bbb1f Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 30 Apr 2021 23:40:28 -0400 Subject: [PATCH 2/2] Fix `x.py doc --stage 1 src/tools/error_index_generator` The error index is a complicated tool (because it depends on rustdoc) and this fix is only one of many possible approaches. Here is the sequence of fixes that culminated in this commit: 1. The error index gives an error that libLLVM-nightly.so isn't found. 2. libLLVM-nightly.so is present in stage1/lib, but not in stage0/lib. 3. `builder.sysroot()` returns `stage0-sysroot`, but `builder.rustc_libdir()` returns `stage0/lib`. 4. Therefore, special case the sysroot to be `stage0` for the error index. Another, possibly better fix is to stop depending on rustdoc at all, and call it as a binary or separate out a shared crate. But that's a larger refactor. --- src/bootstrap/tool.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 4f2426648fd8a..d1f16ae7bfd3b 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -391,11 +391,16 @@ impl ErrorIndex { // use new syntax, but it should work otherwise.) let compiler = builder.compiler(builder.top_stage.saturating_sub(1), builder.config.build); let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler })); + // because rustdoc depends on rustc_driver, error_index transitively depends on libLLVM.so. + // by default libLLVM is only copied in the assemble stage, so copy it explicitly here. + // NOTE: this does *not* use `builder.sysroot(compiler)` because that gives `stage0-sysroot/` for the stage0 compiler, + // but we want `stage0/` to be consistent with the dynamic load path. + let rustc_libdir = builder.rustc_libdir(compiler); + let sysroot = rustc_libdir.parent().unwrap(); + crate::dist::maybe_install_llvm_runtime(builder, compiler.host, &sysroot); + add_dylib_path( - vec![ - PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)), - PathBuf::from(builder.rustc_libdir(compiler)), - ], + vec![builder.sysroot_libdir(compiler, compiler.host).to_path_buf(), rustc_libdir], &mut cmd, ); cmd