@@ -7,7 +7,7 @@ use std::{env, iter, mem, str};
7
7
8
8
use cc:: windows_registry;
9
9
use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
10
- use rustc_metadata:: find_native_static_library;
10
+ use rustc_metadata:: { find_native_static_library, try_find_native_static_library } ;
11
11
use rustc_middle:: bug;
12
12
use rustc_middle:: middle:: dependency_format:: Linkage ;
13
13
use rustc_middle:: middle:: exported_symbols;
@@ -891,9 +891,15 @@ impl<'a> Linker for MsvcLinker<'a> {
891
891
}
892
892
893
893
fn link_staticlib_by_name ( & mut self , name : & str , verbatim : bool , whole_archive : bool ) {
894
- let prefix = if whole_archive { "/WHOLEARCHIVE:" } else { "" } ;
895
- let suffix = if verbatim { "" } else { ".lib" } ;
896
- self . link_arg ( format ! ( "{prefix}{name}{suffix}" ) ) ;
894
+ // On MSVC-like targets rustc supports static libraries using alternative naming
895
+ // scheme (`libfoo.a`) unsupported by linker, search for such libraries manually.
896
+ if let Some ( path) = try_find_native_static_library ( self . sess , name, verbatim) {
897
+ self . link_staticlib_by_path ( & path, whole_archive) ;
898
+ } else {
899
+ let prefix = if whole_archive { "/WHOLEARCHIVE:" } else { "" } ;
900
+ let suffix = if verbatim { "" } else { ".lib" } ;
901
+ self . link_arg ( format ! ( "{prefix}{name}{suffix}" ) ) ;
902
+ }
897
903
}
898
904
899
905
fn link_staticlib_by_path ( & mut self , path : & Path , whole_archive : bool ) {
0 commit comments