Skip to content

Commit

Permalink
Auto merge of #67172 - jethrogb:jb/bootstrap-linker, r=alexcrichton
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Dec 12, 2019
2 parents e9469a6 + 786b9d0 commit 3eeb8d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ impl<'a> Builder<'a> {
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
// to change a flag in a binary?
if self.config.rust_rpath {
if self.config.rust_rpath && util::use_host_linker(&target) {
let rpath = if target.contains("apple") {

// Note that we need to take one extra step on macOS to also pass
Expand All @@ -991,10 +991,7 @@ impl<'a> Builder<'a> {
// flesh out rpath support more fully in the future.
rustflags.arg("-Zosx-rpath-install-name");
Some("-Wl,-rpath,@loader_path/../lib")
} else if !target.contains("windows") &&
!target.contains("wasm32") &&
!target.contains("emscripten") &&
!target.contains("fuchsia") {
} else if !target.contains("windows") {
Some("-Wl,-rpath,$ORIGIN/../lib")
} else {
None
Expand Down
8 changes: 2 additions & 6 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,12 +805,8 @@ impl Build {
.and_then(|c| c.linker.as_ref()) {
Some(linker)
} else if target != self.config.build &&
!target.contains("msvc") &&
!target.contains("emscripten") &&
!target.contains("wasm32") &&
!target.contains("nvptx") &&
!target.contains("fortanix") &&
!target.contains("fuchsia") {
util::use_host_linker(&target) &&
!target.contains("msvc") {
Some(self.cc(target))
} else {
None
Expand Down
13 changes: 13 additions & 0 deletions src/bootstrap/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use build_helper::t;

use crate::config::Config;
use crate::builder::Builder;
use crate::cache::Interned;

/// Returns the `name` as the filename of a static library for `target`.
pub fn staticlib(name: &str, target: &str) -> String {
Expand Down Expand Up @@ -306,3 +307,15 @@ pub fn forcing_clang_based_tests() -> bool {
false
}
}

pub fn use_host_linker(target: &Interned<String>) -> bool {
// FIXME: this information should be gotten by checking the linker flavor
// of the rustc target
!(
target.contains("emscripten") ||
target.contains("wasm32") ||
target.contains("nvptx") ||
target.contains("fortanix") ||
target.contains("fuchsia")
)
}

0 comments on commit 3eeb8d4

Please sign in to comment.