Skip to content

Commit d63e2de

Browse files
committed
bootstrap: Remove usage of RUSTC_TARGET_LINKER
Cargo has a native enviroment variable for this.
1 parent c36849a commit d63e2de

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ fn main() {
148148
cmd.arg("-L").arg(&root);
149149
}
150150

151-
// Override linker if necessary.
152-
if let Ok(target_linker) = env::var("RUSTC_TARGET_LINKER") {
153-
cmd.arg(format!("-Clinker={}", target_linker));
154-
}
155-
156151
// If we're compiling specifically the `panic_abort` crate then we pass
157152
// the `-C panic=abort` option. Note that we do not do this for any
158153
// other crate intentionally as this is the only crate for now that we

src/bootstrap/builder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,8 @@ impl<'a> Builder<'a> {
926926
cargo.env("RUSTC_HOST_LINKER", host_linker);
927927
}
928928
if let Some(target_linker) = self.linker(target) {
929-
cargo.env("RUSTC_TARGET_LINKER", target_linker);
929+
let target = crate::envify(&target);
930+
cargo.env(&format!("CARGO_TARGET_{}_LINKER", target), target_linker);
930931
}
931932
if !(["build", "check", "clippy", "fix", "rustc"].contains(&cmd)) && want_rustdoc {
932933
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler));

src/bootstrap/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,3 +1320,13 @@ impl Compiler {
13201320
self.stage >= final_stage
13211321
}
13221322
}
1323+
1324+
fn envify(s: &str) -> String {
1325+
s.chars()
1326+
.map(|c| match c {
1327+
'-' => '_',
1328+
c => c,
1329+
})
1330+
.flat_map(|c| c.to_uppercase())
1331+
.collect()
1332+
}

src/bootstrap/test.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::tool::{self, Tool, SourceType};
2323
use crate::toolstate::ToolState;
2424
use crate::util::{self, dylib_path, dylib_path_var};
2525
use crate::Crate as CargoCrate;
26-
use crate::{DocTests, Mode, GitRepo};
26+
use crate::{DocTests, Mode, GitRepo, envify};
2727

2828
const ADB_TEST_DIR: &str = "/data/tmp/work";
2929

@@ -1913,16 +1913,6 @@ impl Step for CrateRustdoc {
19131913
}
19141914
}
19151915

1916-
fn envify(s: &str) -> String {
1917-
s.chars()
1918-
.map(|c| match c {
1919-
'-' => '_',
1920-
c => c,
1921-
})
1922-
.flat_map(|c| c.to_uppercase())
1923-
.collect()
1924-
}
1925-
19261916
/// Some test suites are run inside emulators or on remote devices, and most
19271917
/// of our test binaries are linked dynamically which means we need to ship
19281918
/// the standard library and such to the emulator ahead of time. This step

0 commit comments

Comments
 (0)