@@ -670,6 +670,14 @@ struct LinkerOutput {
670670 inner : String ,
671671}
672672
673+ fn is_msvc_link_exe ( sess : & Session ) -> bool {
674+ let ( linker_path, flavor) = linker_and_flavor ( sess) ;
675+ sess. target . is_like_msvc
676+ && flavor == LinkerFlavor :: Msvc ( Lld :: No )
677+ // Match exactly "link.exe"
678+ && linker_path. to_str ( ) == Some ( "link.exe" )
679+ }
680+
673681/// Create a dynamic library or executable.
674682///
675683/// This will invoke the system linker/cc to create the resulting file. This links to all upstream
@@ -856,11 +864,6 @@ fn link_natively(
856864
857865 match prog {
858866 Ok ( prog) => {
859- let is_msvc_link_exe = sess. target . is_like_msvc
860- && flavor == LinkerFlavor :: Msvc ( Lld :: No )
861- // Match exactly "link.exe"
862- && linker_path. to_str ( ) == Some ( "link.exe" ) ;
863-
864867 if !prog. status . success ( ) {
865868 let mut output = prog. stderr . clone ( ) ;
866869 output. extend_from_slice ( & prog. stdout ) ;
@@ -880,7 +883,7 @@ fn link_natively(
880883 if let Some ( code) = prog. status . code ( ) {
881884 // All Microsoft `link.exe` linking ror codes are
882885 // four digit numbers in the range 1000 to 9999 inclusive
883- if is_msvc_link_exe && ( code < 1000 || code > 9999 ) {
886+ if is_msvc_link_exe ( sess ) && ( code < 1000 || code > 9999 ) {
884887 let is_vs_installed = find_msvc_tools:: find_vs_version ( ) . is_ok ( ) ;
885888 let has_linker =
886889 find_msvc_tools:: find_tool ( sess. target . arch . desc ( ) , "link.exe" )
@@ -919,7 +922,7 @@ fn link_natively(
919922
920923 // Hide some progress messages from link.exe that we don't care about.
921924 // See https://github.com/chromium/chromium/blob/bfa41e41145ffc85f041384280caf2949bb7bd72/build/toolchain/win/tool_wrapper.py#L144-L146
922- if is_msvc_link_exe {
925+ if is_msvc_link_exe ( sess ) {
923926 if let Ok ( str) = str:: from_utf8 ( & prog. stdout ) {
924927 let mut output = String :: with_capacity ( str. len ( ) ) ;
925928 for line in stdout. lines ( ) {
0 commit comments