@@ -670,7 +670,7 @@ fn link_natively(
670670) {
671671 info ! ( "preparing {:?} to {:?}" , crate_type, out_filename) ;
672672 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 ) ;
674674
675675 // On AIX, we ship all libraries as .a big_af archive
676676 // the expected format is lib<name>.a(libname.so) for the actual
@@ -1494,7 +1494,8 @@ fn print_native_static_libs(
14941494 | NativeLibKind :: Unspecified => {
14951495 let verbatim = lib. verbatim ;
14961496 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}" ) )
14981499 } else if sess. target . linker_flavor . is_gnu ( ) {
14991500 Some ( format ! ( "-l{}{}" , if verbatim { ":" } else { "" } , name) )
15001501 } else {
@@ -1783,16 +1784,15 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
17831784}
17841785
17851786// 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 {
17881788 // Assume `-C linker=rust-lld` as self-contained mode
17891789 if linker == Path :: new ( "rust-lld" ) {
17901790 return true ;
17911791 }
17921792 let linker_with_extension = if cfg ! ( windows) && linker. extension ( ) . is_none ( ) {
17931793 linker. with_extension ( "exe" )
17941794 } else {
1795- linker
1795+ linker. to_path_buf ( )
17961796 } ;
17971797 for dir in env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) ) {
17981798 let full_path = dir. join ( & linker_with_extension) ;
@@ -1807,7 +1807,11 @@ fn detect_self_contained_mingw(sess: &Session) -> bool {
18071807/// Various toolchain components used during linking are used from rustc distribution
18081808/// instead of being found somewhere on the host system.
18091809/// 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 {
18111815 // Turn the backwards compatible bool values for `self_contained` into fully inferred
18121816 // `LinkSelfContainedComponents`.
18131817 let self_contained =
@@ -1836,7 +1840,7 @@ fn self_contained_components(sess: &Session, crate_type: CrateType) -> LinkSelfC
18361840 LinkSelfContainedDefault :: InferredForMingw => {
18371841 sess. host == sess. target
18381842 && sess. target . vendor != "uwp"
1839- && detect_self_contained_mingw ( sess)
1843+ && detect_self_contained_mingw ( sess, linker )
18401844 }
18411845 }
18421846 } ;
0 commit comments