Skip to content

Commit 786b9d0

Browse files
author
Jethro Beekman
committed
Bootstrap: change logic for choosing linker and rpath
1 parent 2b0e6d2 commit 786b9d0

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

Diff for: src/bootstrap/builder.rs

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

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

Diff for: src/bootstrap/lib.rs

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

Diff for: 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)