File tree Expand file tree Collapse file tree 3 files changed +17
-11
lines changed Expand file tree Collapse file tree 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> {
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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ use build_helper::t;
1515
1616use crate :: config:: Config ;
1717use crate :: builder:: Builder ;
18+ use crate :: cache:: Interned ;
1819
1920/// Returns the `name` as the filename of a static library for `target`.
2021pub 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+ }
You can’t perform that action at this time.
0 commit comments