Skip to content

Commit 7470592

Browse files
committed
Fix x test src/tools/error_index_generator --stage {0,1}
There were two fixes needed: 1. Use `top_stage` instead of `top_stage - 1`. There was a long and torturous comment about trying to match rustdoc's version, but it works better without the hard-coding than with. 2. Make sure that `ci-llvm/lib` is added to LD_LIBRARY_PATH. Previously the error index would be unable to load LLVM for stage0 builds. At some point we should probably have a discussion about how rustdoc stages should be numbered; confusion between 0/1/2 has come up several times in bootstrap now. Note that this is still broken when using `download-rustc = true` and `--stage 1`, but that's *really* a corner case and should affect almost no one. `--stage {0,2}` work fine with download-rustc.
1 parent 02af015 commit 7470592

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

src/bootstrap/builder.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,18 @@ impl<'a> Builder<'a> {
835835
}
836836
}
837837

838+
pub fn rustc_lib_paths(&self, compiler: Compiler) -> Vec<PathBuf> {
839+
let mut dylib_dirs = vec![self.rustc_libdir(compiler)];
840+
841+
// Ensure that the downloaded LLVM libraries can be found.
842+
if self.config.llvm_from_ci {
843+
let ci_llvm_lib = self.out.join(&*compiler.host.triple).join("ci-llvm").join("lib");
844+
dylib_dirs.push(ci_llvm_lib);
845+
}
846+
847+
dylib_dirs
848+
}
849+
838850
/// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic
839851
/// library lookup path.
840852
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) {
@@ -845,15 +857,7 @@ impl<'a> Builder<'a> {
845857
return;
846858
}
847859

848-
let mut dylib_dirs = vec![self.rustc_libdir(compiler)];
849-
850-
// Ensure that the downloaded LLVM libraries can be found.
851-
if self.config.llvm_from_ci {
852-
let ci_llvm_lib = self.out.join(&*compiler.host.triple).join("ci-llvm").join("lib");
853-
dylib_dirs.push(ci_llvm_lib);
854-
}
855-
856-
add_dylib_path(dylib_dirs, cmd);
860+
add_dylib_path(self.rustc_lib_paths(compiler), cmd);
857861
}
858862

859863
/// Gets a path to the compiler specified.

src/bootstrap/tool.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -379,22 +379,14 @@ pub struct ErrorIndex {
379379

380380
impl ErrorIndex {
381381
pub fn command(builder: &Builder<'_>) -> Command {
382-
// This uses stage-1 to match the behavior of building rustdoc.
383-
// Error-index-generator links with the rustdoc library, so we want to
384-
// use the same librustdoc to avoid building rustdoc twice (and to
385-
// avoid building the compiler an extra time). This uses
386-
// saturating_sub to deal with building with stage 0. (Using stage 0
387-
// isn't recommended, since it will fail if any new error index tests
388-
// use new syntax, but it should work otherwise.)
389-
let compiler = builder.compiler(builder.top_stage.saturating_sub(1), builder.config.build);
382+
// Error-index-generator links with the rustdoc library, so we need to add `rustc_lib_paths`
383+
// for rustc_private and libLLVM.so, and `sysroot_lib` for libstd, etc.
384+
let host = builder.config.build;
385+
let compiler = builder.compiler_for(builder.top_stage, host, host);
390386
let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler }));
391-
add_dylib_path(
392-
vec![
393-
PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)),
394-
builder.rustc_libdir(compiler),
395-
],
396-
&mut cmd,
397-
);
387+
let mut dylib_paths = builder.rustc_lib_paths(compiler);
388+
dylib_paths.push(PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)));
389+
add_dylib_path(dylib_paths, &mut cmd);
398390
cmd
399391
}
400392
}

src/bootstrap/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn libdir(target: TargetSelection) -> &'static str {
6363
}
6464

6565
/// Adds a list of lookup paths to `cmd`'s dynamic library lookup path.
66-
/// If The dylib_path_par is already set for this cmd, the old value will be overwritten!
66+
/// If the dylib_path_var is already set for this cmd, the old value will be overwritten!
6767
pub fn add_dylib_path(path: Vec<PathBuf>, cmd: &mut Command) {
6868
let mut list = dylib_path();
6969
for path in path {

0 commit comments

Comments
 (0)