Skip to content

Commit 064a559

Browse files
committed
Fix x doc --stage 0 compiler
Eric figured out the fix to this almost 2 years ago, I just didn't read his comment carefully enough at the timme. The issue was that fake rustc and fake rustdoc were inconsistent about when they passed `--sysroot` to the real compiler. Change them to consistently only pass it when `--target` is present.
1 parent 11909e3 commit 064a559

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/bootstrap/bin/rustdoc.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ fn main() {
1515
let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set");
1616
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
1717

18+
// Detect whether or not we're a build script depending on whether --target
19+
// is passed (a bit janky...)
20+
let target = args.windows(2).find(|w| &*w[0] == "--target").and_then(|w| w[1].to_str());
21+
1822
use std::str::FromStr;
1923

2024
let verbose = match env::var("RUSTC_VERBOSE") {
@@ -26,10 +30,18 @@ fn main() {
2630
dylib_path.insert(0, PathBuf::from(libdir.clone()));
2731

2832
let mut cmd = Command::new(rustdoc);
29-
cmd.args(&args)
30-
.arg("--sysroot")
31-
.arg(&sysroot)
32-
.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
33+
34+
if target.is_some() {
35+
// The stage0 compiler has a special sysroot distinct from what we
36+
// actually downloaded, so we just always pass the `--sysroot` option,
37+
// unless one is already set.
38+
if !args.iter().any(|arg| arg == "--sysroot") {
39+
cmd.arg("--sysroot").arg(&sysroot);
40+
}
41+
}
42+
43+
cmd.args(&args);
44+
cmd.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
3345

3446
// Force all crates compiled by this compiler to (a) be unstable and (b)
3547
// allow the `rustc_private` feature to link to other unstable crates

0 commit comments

Comments
 (0)