-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Meson naming convention #432
Conversation
src/build_targets.rs
Outdated
let static_lib = targetdir.join(format!("{lib_name}.lib")); | ||
let impl_lib = targetdir.join(format!("{lib_name}.dll.lib")); | ||
let impl_lib = match use_meson_naming_convention { | ||
false => targetdir.join(format!("{lib_name}.dll.lib")), | ||
true => targetdir.join(format!("{lib_name}.lib")), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit is not entirely correct, under the Meson convention import libs are lib
but also static libs are changed to a
. https://mesonbuild.com/FAQ.html#why-does-building-my-project-with-msvc-output-static-libraries-called-libfooa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Static libs behavior is controlled by:
Lines 118 to 129 in 5a92c3f
pub fn static_output_file_name(&self) -> Option<OsString> { | |
match self.lib_type() { | |
LibType::Windows => { | |
if self.static_lib.is_some() && self.use_meson_naming_convention { | |
Some(format!("lib{}.a", self.name).into()) | |
} else { | |
Some(self.static_lib.as_ref()?.file_name()?.to_owned()) | |
} | |
} | |
_ => Some(self.static_lib.as_ref()?.file_name()?.to_owned()), | |
} | |
} |
The shared_lib
, static_lib
or pdb
declarations cannot be modified here, as they also define which library is copied from Rust. Consequently, this logic must always align with:
https://github.com/rust-lang/rust/blob/1.84.0/compiler/rustc_target/src/spec/base/windows_msvc.rs#L11-L15
PR #433 will fix the CI failures.
Work-in-progress commit kleisauke@6ad3303 seems to fix this. |
If you have time during the weekend I'd fold your fixes in the next release. |
Ensure import libraries under MinGW are named `libfoo.dll.a` when using `--meson-paths`.
Shared libraries under MSVC are always in the form `foo.dll`.
5a92c3f
to
8815a9f
Compare
Thank you I defer to @amyspark for the review since I do not know enough of windows to be sure :) |
This PR fixes two issues when using
--meson-paths
.libfoo.dll.a
(44e96dc).foo.dll
(9cf2de8)./cc @amyspark
As an aside, I've encountered the same issue as #426 with the
x86_64-pc-windows-gnullvm
target. It looks like-Wl,--output-def
here:cargo-c/src/target.rs
Lines 112 to 118 in c4e6c08
also generates a
.def
file with a missing library name, at least on LLVM (I haven't checked Binutils):https://github.com/llvm/llvm-project/blob/llvmorg-19.1.6/lld/COFF/MinGW.cpp#L173-L192
Perhaps we could somehow allow
implib
to override the import library name?:https://github.com/messense/implib-rs/blob/v0.3.3/src/lib.rs#L109-L112