@@ -119,18 +119,25 @@ impl Archive {
119
119
}
120
120
121
121
fn find_library ( & self , name : & str ) -> Path {
122
- let ( prefix , ext ) = match self . sess . targ_cfg . os {
122
+ let ( osprefix , osext ) = match self . sess . targ_cfg . os {
123
123
abi:: OsWin32 => ( "" , "lib" ) , _ => ( "lib" , "a" ) ,
124
124
} ;
125
- let libname = format ! ( "{}{}.{}" , prefix, name, ext) ;
125
+ // On windows, static libraries sometimes show up as libfoo.a and other
126
+ // times show up as foo.lib
127
+ let oslibname = format ! ( "{}{}.{}" , osprefix, name, osext) ;
128
+ let unixlibname = format ! ( "lib{}.a" , name) ;
126
129
127
130
let mut rustpath = filesearch:: rust_path ( ) ;
128
131
rustpath. push ( self . sess . filesearch . get_target_lib_path ( ) ) ;
129
132
let path = self . sess . opts . addl_lib_search_paths . iter ( ) ;
130
133
for path in path. chain ( rustpath. iter ( ) ) {
131
134
debug ! ( "looking for {} inside {}" , name, path. display( ) ) ;
132
- let test = path. join ( libname . clone ( ) ) ;
135
+ let test = path. join ( oslibname . as_slice ( ) ) ;
133
136
if test. exists ( ) { return test }
137
+ if oslibname != unixlibname {
138
+ let test = path. join ( unixlibname. as_slice ( ) ) ;
139
+ if test. exists ( ) { return test }
140
+ }
134
141
}
135
142
self . sess . fatal ( format ! ( "could not find native static library `{}`, \
136
143
perhaps an -L flag is missing?", name) ) ;
0 commit comments