@@ -977,31 +977,34 @@ fn get_crt_libs_path(sess: &Session) -> Option<PathBuf> {
977
977
use std:: sync:: Mutex ;
978
978
979
979
lazy_static:: lazy_static! {
980
- static ref SYSTEM_LIBS : Mutex <Option <PathBuf >> = Mutex :: new( None ) ;
980
+ static ref SYSTEM_LIBS : Mutex <Option <Result < PathBuf , ( ) > >> = Mutex :: new( None ) ;
981
981
}
982
982
983
983
let system_libs = SYSTEM_LIBS . lock ( ) . unwrap ( ) . clone ( ) ;
984
- if let Some ( compiler_libs_path) = system_libs {
985
- return Some ( compiler_libs_path) ;
986
- } else {
987
- let compiler = if let Some ( linker) = & sess. opts . cg . linker {
988
- linker. clone ( ) . into_os_string ( )
989
- } else if let Some ( linker) = & sess. target . target . options . linker {
990
- linker. into ( )
991
- } else {
992
- return None ;
993
- } ;
994
- if let Ok ( output) = Command :: new ( compiler) . arg ( "-print-file-name=crt2.o" ) . output ( ) {
995
- if let Some ( compiler_libs_path) =
996
- PathBuf :: from ( std:: str:: from_utf8 ( & output. stdout ) . unwrap ( ) ) . parent ( )
997
- {
998
- let compiler_libs_path = fix_windows_verbatim_for_gcc ( compiler_libs_path) ;
999
- * SYSTEM_LIBS . lock ( ) . unwrap ( ) = Some ( compiler_libs_path. clone ( ) ) ;
1000
- return Some ( compiler_libs_path) ;
1001
- }
984
+ match system_libs {
985
+ Some ( Ok ( compiler_libs_path) ) => Some ( compiler_libs_path) ,
986
+ Some ( Err ( _) ) => None ,
987
+ _ => {
988
+ let compiler = if let Some ( linker) = & sess. opts . cg . linker {
989
+ linker. clone ( ) . into_os_string ( )
990
+ } else if let Some ( linker) = & sess. target . target . options . linker {
991
+ linker. into ( )
992
+ } else {
993
+ * SYSTEM_LIBS . lock ( ) . unwrap ( ) = Some ( Err ( ( ) ) ) ;
994
+ return None ;
995
+ } ;
996
+ if let Ok ( output) = Command :: new ( compiler) . arg ( "-print-file-name=crt2.o" ) . output ( ) {
997
+ if let Some ( compiler_libs_path) =
998
+ PathBuf :: from ( std:: str:: from_utf8 ( & output. stdout ) . unwrap ( ) ) . parent ( )
999
+ {
1000
+ let compiler_libs_path = fix_windows_verbatim_for_gcc ( compiler_libs_path) ;
1001
+ * SYSTEM_LIBS . lock ( ) . unwrap ( ) = Some ( Ok ( compiler_libs_path. clone ( ) ) ) ;
1002
+ return Some ( compiler_libs_path) ;
1003
+ }
1004
+ } ;
1005
+ None
1002
1006
}
1003
1007
}
1004
- None
1005
1008
}
1006
1009
1007
1010
pub fn get_file_path ( sess : & Session , name : & str ) -> PathBuf {
0 commit comments