Skip to content

Commit 7912923

Browse files
committed
native libs: Explicitly limit foo.lib -> libfoo.a fallback to MSVC
In practice this doesn't change anything for current built-in targets
1 parent 97efaa2 commit 7912923

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

compiler/rustc_metadata/src/native_libs.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,15 @@ pub fn try_find_native_static_library(
9595
name: &str,
9696
verbatim: bool,
9797
) -> Option<PathBuf> {
98+
let target = (&*sess.target.staticlib_prefix, &*sess.target.staticlib_suffix);
99+
let unix = ("lib", ".a");
98100
let formats = if verbatim {
99-
vec![("".into(), "".into())]
101+
vec![("", "")]
102+
} else if target != unix && sess.target.is_like_msvc {
103+
// On Windows MSVC naming scheme `libfoo.a` is used as a fallback from default `foo.lib`.
104+
vec![target, unix]
100105
} else {
101-
let os = (sess.target.staticlib_prefix.clone(), sess.target.staticlib_suffix.clone());
102-
// On Windows, static libraries sometimes show up as libfoo.a and other
103-
// times show up as foo.lib
104-
let unix = ("lib".into(), ".a".into());
105-
if os == unix { vec![os] } else { vec![os, unix] }
106+
vec![target]
106107
};
107108

108109
walk_native_lib_search_dirs(sess, None, |dir, is_framework| {

0 commit comments

Comments
 (0)