Skip to content

Commit

Permalink
MsvcLinker: allow linking statically to Meson and MinGW-style named l…
Browse files Browse the repository at this point in the history
…ibraries

See rust-lang#122455
  • Loading branch information
amyspark committed Apr 20, 2024
1 parent f9b1614 commit 291a31d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,9 +812,14 @@ impl<'a> Linker for MsvcLinker<'a> {
}

fn link_staticlib_by_name(&mut self, name: &str, verbatim: bool, whole_archive: bool) {
// Static libraries built by MSVC are usually called foo.lib.
// However, under MinGW and build systems such as Meson, they are
// called libfoo.a
let prefix = if whole_archive { "/WHOLEARCHIVE:" } else { "" };
let suffix = if verbatim { "" } else { ".lib" };
self.cmd.arg(format!("{prefix}{name}{suffix}"));
let path = find_native_static_library(name, verbatim, self.sess);
let mut arg = OsString::from(prefix);
arg.push(path);
self.cmd.arg(arg);
}

fn link_staticlib_by_path(&mut self, path: &Path, whole_archive: bool) {
Expand Down

0 comments on commit 291a31d

Please sign in to comment.