Rollup merge of #84866 - petrochenkov:wholesome, r=Mark-Simulacrum

linker: Avoid library duplication with `/WHOLEARCHIVE`

Looks like in #72785 I misinterpreted how the `link.exe`'s `/WHOLEARCHIVE` flag works.

It's not necessary to write `mylib /WHOLEARCHIVE:mylib` to mark `mylib` as whole archive, `/WHOLEARCHIVE:mylib` alone is enough.

https://docs.microsoft.com/en-us/cpp/build/reference/wholearchive-include-all-library-object-files?view=msvc-160
This commit is contained in:
Dylan DPC 2021-05-07 16:19:20 +02:00 committed by GitHub
commit 6e4c842305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -821,11 +821,9 @@ impl<'a> Linker for MsvcLinker<'a> {
}
fn link_whole_staticlib(&mut self, lib: Symbol, verbatim: bool, _search_path: &[PathBuf]) {
self.link_staticlib(lib, verbatim);
self.cmd.arg(format!("/WHOLEARCHIVE:{}{}", lib, if verbatim { "" } else { ".lib" }));
}
fn link_whole_rlib(&mut self, path: &Path) {
self.link_rlib(path);
let mut arg = OsString::from("/WHOLEARCHIVE:");
arg.push(path);
self.cmd.arg(arg);