Skip to content

Commit

Permalink
Pass host flags to rustc shim using prefixed env. vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Oct 5, 2023
1 parent 65519f5 commit acd1869
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
9 changes: 0 additions & 9 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ fn main() {
if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() {
cmd.arg("-Z").arg("force-unstable-if-unmarked");
}
if let Some(linker) = env::var_os("RUSTDOC_LINKER") {
let mut arg = OsString::from("-Clinker=");
arg.push(&linker);
cmd.arg(arg);
}
if let Ok(no_threads) = env::var("RUSTDOC_LLD_NO_THREADS") {
cmd.arg("-Clink-arg=-fuse-ld=lld");
cmd.arg(format!("-Clink-arg=-Wl,{no_threads}"));
}
// Cargo doesn't pass RUSTDOCFLAGS to proc_macros:
// https://github.com/rust-lang/cargo/issues/4423
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,9 @@ impl<'a> Builder<'a> {
cmd.env_remove("MFLAGS");

if let Some(linker) = self.linker(compiler.host) {
cmd.env("RUSTDOC_LINKER", linker);
let mut flag = std::ffi::OsString::from("-Clinker=");
flag.push(linker);
cmd.arg(flag);
}
if self.is_fuse_ld_lld(compiler.host) {
cmd.env("RUSTDOC_FUSE_LD_LLD", "1");
Expand Down
13 changes: 8 additions & 5 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,13 +854,16 @@ impl Step for RustdocTheme {
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
.env("RUSTC_BOOTSTRAP", "1");
if let Some(linker) = builder.linker(self.compiler.host) {
cmd.env("RUSTDOC_LINKER", linker);
let mut flag = std::ffi::OsString::from("-Clinker=");
flag.push(linker);
cmd.arg(flag);
}
if builder.is_fuse_ld_lld(self.compiler.host) {
cmd.env(
"RUSTDOC_LLD_NO_THREADS",
util::lld_flag_no_threads(self.compiler.host.contains("windows")),
);
cmd.arg("-Clink-arg=-fuse-ld=lld");
cmd.arg(format!(
"-Clink-arg=-Wl,{}",
util::lld_flag_no_threads(self.compiler.host.contains("windows"))
));
}
builder.run_delaying_failure(&mut cmd);
}
Expand Down

0 comments on commit acd1869

Please sign in to comment.