@@ -33,28 +33,25 @@ pub fn find_native_static_library(
33
33
search_paths : & [ PathBuf ] ,
34
34
sess : & Session ,
35
35
) -> PathBuf {
36
- let verbatim = verbatim. unwrap_or ( false ) ;
37
- // On Windows, static libraries sometimes show up as libfoo.a and other
38
- // times show up as foo.lib
39
- let oslibname = if verbatim {
40
- name. to_string ( )
36
+ let formats = if verbatim. unwrap_or ( false ) {
37
+ vec ! [ ( "" . into( ) , "" . into( ) ) ]
41
38
} else {
42
- format ! ( "{}{}{}" , sess. target. staticlib_prefix, name, sess. target. staticlib_suffix)
39
+ let os = ( sess. target . staticlib_prefix . clone ( ) , sess. target . staticlib_suffix . clone ( ) ) ;
40
+ // On Windows, static libraries sometimes show up as libfoo.a and other
41
+ // times show up as foo.lib
42
+ let unix = ( "lib" . into ( ) , ".a" . into ( ) ) ;
43
+ if os == unix { vec ! [ os] } else { vec ! [ os, unix] }
43
44
} ;
44
- let unixlibname = format ! ( "lib{}.a" , name) ;
45
45
46
46
for path in search_paths {
47
- let test = path. join ( & oslibname) ;
48
- if test. exists ( ) {
49
- return test;
50
- }
51
- if oslibname != unixlibname {
52
- let test = path. join ( & unixlibname) ;
47
+ for ( prefix, suffix) in & formats {
48
+ let test = path. join ( format ! ( "{}{}{}" , prefix, name, suffix) ) ;
53
49
if test. exists ( ) {
54
50
return test;
55
51
}
56
52
}
57
53
}
54
+
58
55
sess. emit_fatal ( MissingNativeLibrary { libname : name } ) ;
59
56
}
60
57
0 commit comments