Skip to content

Commit 02f2e7c

Browse files
committed
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.
1 parent 4b6653d commit 02f2e7c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/bootstrap/tool.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,16 @@ impl ErrorIndex {
391391
// use new syntax, but it should work otherwise.)
392392
let compiler = builder.compiler(builder.top_stage.saturating_sub(1), builder.config.build);
393393
let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler }));
394+
// because rustdoc depends on rustc_driver, error_index transitively depends on libLLVM.so.
395+
// by default libLLVM is only copied in the assemble stage, so copy it explicitly here.
396+
// NOTE: this does *not* use `builder.sysroot(compiler)` because that gives `stage0-sysroot/` for the stage0 compiler,
397+
// but we want `stage0/` to be consistent with the dynamic load path.
398+
let rustc_libdir = builder.rustc_libdir(compiler);
399+
let sysroot = rustc_libdir.parent().unwrap();
400+
crate::dist::maybe_install_llvm_runtime(builder, compiler.host, &sysroot);
401+
394402
add_dylib_path(
395-
vec![
396-
PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)),
397-
PathBuf::from(builder.rustc_libdir(compiler)),
398-
],
403+
vec![builder.sysroot_libdir(compiler, compiler.host).to_path_buf(), rustc_libdir],
399404
&mut cmd,
400405
);
401406
cmd

0 commit comments

Comments
 (0)