@@ -670,7 +670,7 @@ fn link_natively(
670
670
) {
671
671
info ! ( "preparing {:?} to {:?}" , crate_type, out_filename) ;
672
672
let ( linker_path, flavor) = linker_and_flavor ( sess) ;
673
- let self_contained_components = self_contained_components ( sess, crate_type) ;
673
+ let self_contained_components = self_contained_components ( sess, crate_type, & linker_path ) ;
674
674
675
675
// On AIX, we ship all libraries as .a big_af archive
676
676
// the expected format is lib<name>.a(libname.so) for the actual
@@ -1788,16 +1788,15 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
1788
1788
}
1789
1789
1790
1790
// Returns true if linker is located within sysroot
1791
- fn detect_self_contained_mingw ( sess : & Session ) -> bool {
1792
- let ( linker, _) = linker_and_flavor ( sess) ;
1791
+ fn detect_self_contained_mingw ( sess : & Session , linker : & Path ) -> bool {
1793
1792
// Assume `-C linker=rust-lld` as self-contained mode
1794
1793
if linker == Path :: new ( "rust-lld" ) {
1795
1794
return true ;
1796
1795
}
1797
1796
let linker_with_extension = if cfg ! ( windows) && linker. extension ( ) . is_none ( ) {
1798
1797
linker. with_extension ( "exe" )
1799
1798
} else {
1800
- linker
1799
+ linker. to_path_buf ( )
1801
1800
} ;
1802
1801
for dir in env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) ) {
1803
1802
let full_path = dir. join ( & linker_with_extension) ;
@@ -1812,7 +1811,11 @@ fn detect_self_contained_mingw(sess: &Session) -> bool {
1812
1811
/// Various toolchain components used during linking are used from rustc distribution
1813
1812
/// instead of being found somewhere on the host system.
1814
1813
/// We only provide such support for a very limited number of targets.
1815
- fn self_contained_components ( sess : & Session , crate_type : CrateType ) -> LinkSelfContainedComponents {
1814
+ fn self_contained_components (
1815
+ sess : & Session ,
1816
+ crate_type : CrateType ,
1817
+ linker : & Path ,
1818
+ ) -> LinkSelfContainedComponents {
1816
1819
// Turn the backwards compatible bool values for `self_contained` into fully inferred
1817
1820
// `LinkSelfContainedComponents`.
1818
1821
let self_contained =
@@ -1841,7 +1844,7 @@ fn self_contained_components(sess: &Session, crate_type: CrateType) -> LinkSelfC
1841
1844
LinkSelfContainedDefault :: InferredForMingw => {
1842
1845
sess. host == sess. target
1843
1846
&& sess. target . vendor != "uwp"
1844
- && detect_self_contained_mingw ( sess)
1847
+ && detect_self_contained_mingw ( sess, linker )
1845
1848
}
1846
1849
}
1847
1850
} ;
0 commit comments