@@ -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
@@ -1494,7 +1494,8 @@ fn print_native_static_libs(
1494
1494
| NativeLibKind :: Unspecified => {
1495
1495
let verbatim = lib. verbatim ;
1496
1496
if sess. target . is_like_msvc {
1497
- Some ( format ! ( "{}{}" , name, if verbatim { "" } else { ".lib" } ) )
1497
+ let ( prefix, suffix) = sess. staticlib_components ( verbatim) ;
1498
+ Some ( format ! ( "{prefix}{name}{suffix}" ) )
1498
1499
} else if sess. target . linker_flavor . is_gnu ( ) {
1499
1500
Some ( format ! ( "-l{}{}" , if verbatim { ":" } else { "" } , name) )
1500
1501
} else {
@@ -1783,16 +1784,15 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
1783
1784
}
1784
1785
1785
1786
// Returns true if linker is located within sysroot
1786
- fn detect_self_contained_mingw ( sess : & Session ) -> bool {
1787
- let ( linker, _) = linker_and_flavor ( sess) ;
1787
+ fn detect_self_contained_mingw ( sess : & Session , linker : & Path ) -> bool {
1788
1788
// Assume `-C linker=rust-lld` as self-contained mode
1789
1789
if linker == Path :: new ( "rust-lld" ) {
1790
1790
return true ;
1791
1791
}
1792
1792
let linker_with_extension = if cfg ! ( windows) && linker. extension ( ) . is_none ( ) {
1793
1793
linker. with_extension ( "exe" )
1794
1794
} else {
1795
- linker
1795
+ linker. to_path_buf ( )
1796
1796
} ;
1797
1797
for dir in env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) ) {
1798
1798
let full_path = dir. join ( & linker_with_extension) ;
@@ -1807,7 +1807,11 @@ fn detect_self_contained_mingw(sess: &Session) -> bool {
1807
1807
/// Various toolchain components used during linking are used from rustc distribution
1808
1808
/// instead of being found somewhere on the host system.
1809
1809
/// We only provide such support for a very limited number of targets.
1810
- fn self_contained_components ( sess : & Session , crate_type : CrateType ) -> LinkSelfContainedComponents {
1810
+ fn self_contained_components (
1811
+ sess : & Session ,
1812
+ crate_type : CrateType ,
1813
+ linker : & Path ,
1814
+ ) -> LinkSelfContainedComponents {
1811
1815
// Turn the backwards compatible bool values for `self_contained` into fully inferred
1812
1816
// `LinkSelfContainedComponents`.
1813
1817
let self_contained =
@@ -1836,7 +1840,7 @@ fn self_contained_components(sess: &Session, crate_type: CrateType) -> LinkSelfC
1836
1840
LinkSelfContainedDefault :: InferredForMingw => {
1837
1841
sess. host == sess. target
1838
1842
&& sess. target . vendor != "uwp"
1839
- && detect_self_contained_mingw ( sess)
1843
+ && detect_self_contained_mingw ( sess, linker )
1840
1844
}
1841
1845
}
1842
1846
} ;
0 commit comments