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 @@ -980,7 +980,7 @@ impl<'a> Builder<'a> {
980
980
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
981
981
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
982
982
// to change a flag in a binary?
983
- if self . config . rust_rpath {
983
+ if self . config . rust_rpath && util :: use_host_linker ( & target ) {
984
984
let rpath = if target. contains ( "apple" ) {
985
985
986
986
// Note that we need to take one extra step on macOS to also pass
@@ -990,10 +990,7 @@ impl<'a> Builder<'a> {
990
990
// flesh out rpath support more fully in the future.
991
991
rustflags. arg ( "-Zosx-rpath-install-name" ) ;
992
992
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" ) {
997
994
Some ( "-Wl,-rpath,$ORIGIN/../lib" )
998
995
} else {
999
996
None
Original file line number Diff line number Diff line change @@ -806,12 +806,8 @@ impl Build {
806
806
. and_then ( |c| c. linker . as_ref ( ) ) {
807
807
Some ( linker)
808
808
} 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" ) {
815
811
Some ( self . cc ( target) )
816
812
} else {
817
813
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