mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 13:36:49 +00:00
Change name when outputting staticlibs on Windows
libfoo.a -> foo.lib In order to not cause conflicts, changes the DLL import library name foo.lib -> foo.dll.lib Fixes https://github.com/rust-lang/rust/issues/29508 Because this changes output filenames this is a [breaking-change] Signed-off-by: Peter Atashian <retep998@gmail.com>
This commit is contained in:
parent
dda25f2221
commit
06c66d6ca2
@ -388,11 +388,12 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
|
||||
let dypair = self.dylibname();
|
||||
let staticpair = self.staticlibname();
|
||||
|
||||
// want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
|
||||
let dylib_prefix = format!("{}{}", dypair.0, self.crate_name);
|
||||
let rlib_prefix = format!("lib{}", self.crate_name);
|
||||
let staticlib_prefix = format!("lib{}", self.crate_name);
|
||||
let staticlib_prefix = format!("{}{}", staticpair.0, self.crate_name);
|
||||
|
||||
let mut candidates = HashMap::new();
|
||||
let mut staticlibs = vec!();
|
||||
@ -425,7 +426,7 @@ impl<'a> Context<'a> {
|
||||
false)
|
||||
} else {
|
||||
if file.starts_with(&staticlib_prefix[..]) &&
|
||||
file.ends_with(".a") {
|
||||
file.ends_with(&staticpair.1) {
|
||||
staticlibs.push(CrateMismatch {
|
||||
path: path.to_path_buf(),
|
||||
got: "static".to_string()
|
||||
@ -644,6 +645,13 @@ impl<'a> Context<'a> {
|
||||
(t.options.dll_prefix.clone(), t.options.dll_suffix.clone())
|
||||
}
|
||||
|
||||
// Returns the corresponding (prefix, suffix) that files need to have for
|
||||
// static libraries
|
||||
fn staticlibname(&self) -> (String, String) {
|
||||
let t = &self.target;
|
||||
(t.options.staticlib_prefix.clone(), t.options.staticlib_suffix.clone())
|
||||
}
|
||||
|
||||
fn find_commandline_library(&mut self, locs: &[String]) -> Option<Library> {
|
||||
// First, filter out all libraries that look suspicious. We only accept
|
||||
// files which actually exist that have the correct naming scheme for
|
||||
|
@ -490,7 +490,10 @@ pub fn filename_for_input(sess: &Session,
|
||||
suffix))
|
||||
}
|
||||
config::CrateTypeStaticlib => {
|
||||
outputs.out_directory.join(&format!("lib{}.a", libname))
|
||||
let (prefix, suffix) = (&sess.target.target.options.staticlib_prefix,
|
||||
&sess.target.target.options.staticlib_suffix);
|
||||
outputs.out_directory.join(&format!("{}{}{}", prefix, libname,
|
||||
suffix))
|
||||
}
|
||||
config::CrateTypeExecutable => {
|
||||
let suffix = &sess.target.target.options.exe_suffix;
|
||||
|
@ -210,7 +210,14 @@ impl<'a> Linker for MsvcLinker<'a> {
|
||||
fn link_rlib(&mut self, lib: &Path) { self.cmd.arg(lib); }
|
||||
fn add_object(&mut self, path: &Path) { self.cmd.arg(path); }
|
||||
fn args(&mut self, args: &[String]) { self.cmd.args(args); }
|
||||
fn build_dylib(&mut self, _out_filename: &Path) { self.cmd.arg("/DLL"); }
|
||||
|
||||
fn build_dylib(&mut self, out_filename: &Path) {
|
||||
self.cmd.arg("/DLL");
|
||||
let mut arg: OsString = "/IMPLIB:".into();
|
||||
arg.push(out_filename.with_extension("dll.lib"));
|
||||
self.cmd.arg(arg);
|
||||
}
|
||||
|
||||
fn gc_sections(&mut self, _is_dylib: bool) { self.cmd.arg("/OPT:REF,ICF"); }
|
||||
|
||||
fn link_dylib(&mut self, lib: &str) {
|
||||
@ -222,7 +229,7 @@ impl<'a> Linker for MsvcLinker<'a> {
|
||||
// `foo.lib` file if the dll doesn't actually export any symbols, so we
|
||||
// check to see if the file is there and just omit linking to it if it's
|
||||
// not present.
|
||||
let name = format!("{}.lib", lib);
|
||||
let name = format!("{}.dll.lib", lib);
|
||||
if fs::metadata(&path.join(&name)).is_ok() {
|
||||
self.cmd.arg(name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user