Skip to content

Commit 3eeb8d4

Browse files
committed
Auto merge of #67172 - jethrogb:jb/bootstrap-linker, r=alexcrichton
Bootstrap: change logic for choosing linker and rpath This is a follow-up from #66957 and #67023. Apparently there was one more location with a hard-coded list of targets to influence linking. I've filed #67171 to track this madness. r? @alexcrichton
2 parents e9469a6 + 786b9d0 commit 3eeb8d4

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/bootstrap/builder.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ impl<'a> Builder<'a> {
981981
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
982982
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
983983
// to change a flag in a binary?
984-
if self.config.rust_rpath {
984+
if self.config.rust_rpath && util::use_host_linker(&target) {
985985
let rpath = if target.contains("apple") {
986986

987987
// Note that we need to take one extra step on macOS to also pass
@@ -991,10 +991,7 @@ impl<'a> Builder<'a> {
991991
// flesh out rpath support more fully in the future.
992992
rustflags.arg("-Zosx-rpath-install-name");
993993
Some("-Wl,-rpath,@loader_path/../lib")
994-
} else if !target.contains("windows") &&
995-
!target.contains("wasm32") &&
996-
!target.contains("emscripten") &&
997-
!target.contains("fuchsia") {
994+
} else if !target.contains("windows") {
998995
Some("-Wl,-rpath,$ORIGIN/../lib")
999996
} else {
1000997
None

src/bootstrap/lib.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -805,12 +805,8 @@ impl Build {
805805
.and_then(|c| c.linker.as_ref()) {
806806
Some(linker)
807807
} else if target != self.config.build &&
808-
!target.contains("msvc") &&
809-
!target.contains("emscripten") &&
810-
!target.contains("wasm32") &&
811-
!target.contains("nvptx") &&
812-
!target.contains("fortanix") &&
813-
!target.contains("fuchsia") {
808+
util::use_host_linker(&target) &&
809+
!target.contains("msvc") {
814810
Some(self.cc(target))
815811
} else {
816812
None

src/bootstrap/util.rs

+13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use build_helper::t;
1515

1616
use crate::config::Config;
1717
use crate::builder::Builder;
18+
use crate::cache::Interned;
1819

1920
/// Returns the `name` as the filename of a static library for `target`.
2021
pub fn staticlib(name: &str, target: &str) -> String {
@@ -306,3 +307,15 @@ pub fn forcing_clang_based_tests() -> bool {
306307
false
307308
}
308309
}
310+
311+
pub fn use_host_linker(target: &Interned<String>) -> bool {
312+
// FIXME: this information should be gotten by checking the linker flavor
313+
// of the rustc target
314+
!(
315+
target.contains("emscripten") ||
316+
target.contains("wasm32") ||
317+
target.contains("nvptx") ||
318+
target.contains("fortanix") ||
319+
target.contains("fuchsia")
320+
)
321+
}

0 commit comments

Comments
 (0)