Skip to content

Commit ddf39ca

Browse files
committed
Avoid copying rustc rmeta artifacts into the build compiler sysroot
This helps to avoid polluting the sysroot of the build compiler.
1 parent 1ae7c49 commit ddf39ca

File tree

3 files changed

+189
-65
lines changed

3 files changed

+189
-65
lines changed

src/bootstrap/src/bin/rustc.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ fn main() {
179179
}
180180
}
181181

182+
// Here we pass additional paths that essentially act as a sysroot.
183+
// These are used to load rustc crates (e.g. `extern crate rustc_ast;`)
184+
// for rustc_private tools, so that we do not have to copy them into the
185+
// actual sysroot of the compiler that builds the tool.
186+
if let Ok(dirs) = env::var("RUSTC_ADDITIONAL_SYSROOT_PATHS") {
187+
for dir in dirs.split(",") {
188+
cmd.arg(format!("-L{dir}"));
189+
}
190+
}
191+
182192
// Force all crates compiled by this compiler to (a) be unstable and (b)
183193
// allow the `rustc_private` feature to link to other unstable crates
184194
// also in the sysroot. We also do this for host crates, since those

0 commit comments

Comments
 (0)