File tree 3 files changed +17
-11
lines changed
3 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -981,7 +981,7 @@ impl<'a> Builder<'a> {
981
981
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
982
982
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
983
983
// to change a flag in a binary?
984
- if self . config . rust_rpath {
984
+ if self . config . rust_rpath && util :: use_host_linker ( & target ) {
985
985
let rpath = if target. contains ( "apple" ) {
986
986
987
987
// Note that we need to take one extra step on macOS to also pass
@@ -991,10 +991,7 @@ impl<'a> Builder<'a> {
991
991
// flesh out rpath support more fully in the future.
992
992
rustflags. arg ( "-Zosx-rpath-install-name" ) ;
993
993
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" ) {
998
995
Some ( "-Wl,-rpath,$ORIGIN/../lib" )
999
996
} else {
1000
997
None
Original file line number Diff line number Diff line change @@ -805,12 +805,8 @@ impl Build {
805
805
. and_then ( |c| c. linker . as_ref ( ) ) {
806
806
Some ( linker)
807
807
} 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" ) {
814
810
Some ( self . cc ( target) )
815
811
} else {
816
812
None
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ use build_helper::t;
15
15
16
16
use crate :: config:: Config ;
17
17
use crate :: builder:: Builder ;
18
+ use crate :: cache:: Interned ;
18
19
19
20
/// Returns the `name` as the filename of a static library for `target`.
20
21
pub fn staticlib ( name : & str , target : & str ) -> String {
@@ -306,3 +307,15 @@ pub fn forcing_clang_based_tests() -> bool {
306
307
false
307
308
}
308
309
}
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
+ }
You can’t perform that action at this time.
0 commit comments