Skip to content
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 weak linkage on windows and apple platforms #672

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ macro_rules! intrinsics {
#[cfg(all(any(windows, target_os = "uefi"), target_arch = "x86_64", not(feature = "mangled-names")))]
mod $name {
#[no_mangle]
#[cfg_attr(all(not(windows), not(target_vendor = "apple")), linkage = "weak")]
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should likely also check not(target_abi = "llvm", how do you test it? I'd like to test with gnullvm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just testing this crate locally? You should be able to cd to testcrate and cargo test --target ....

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought this issue would manifest only during Rust build, gonna look into it this weekend.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rust-lang/rust update of compiler-builtins merged, so it should also be available to test with the next rustc nightly (couple hours after 0:00 UTC)

extern $abi fn $name( $($argname: $ty),* )
-> $crate::macros::win64_128bit_abi_hack::U64x2
{
Expand Down Expand Up @@ -298,7 +298,7 @@ macro_rules! intrinsics {
#[cfg(all(target_arch = "arm", not(feature = "mangled-names")))]
mod $name {
#[no_mangle]
#[cfg_attr(all(not(windows), not(target_vendor = "apple")), linkage = "weak")]
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
$(#[$($attr)*])*
extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
super::$name($($argname),*)
Expand All @@ -308,7 +308,7 @@ macro_rules! intrinsics {
#[cfg(all(target_arch = "arm", not(feature = "mangled-names")))]
mod $alias {
#[no_mangle]
#[cfg_attr(all(not(windows), not(target_vendor="apple")), linkage = "weak")]
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
$(#[$($attr)*])*
extern "aapcs" fn $alias( $($argname: $ty),* ) $(-> $ret)? {
super::$name($($argname),*)
Expand Down Expand Up @@ -375,7 +375,7 @@ macro_rules! intrinsics {
mod $name {
$(#[$($attr)*])*
#[no_mangle]
#[cfg_attr(all(not(windows), not(target_vendor = "apple")), linkage = "weak")]
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
unsafe extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
super::$name($($argname),*)
}
Expand All @@ -400,7 +400,7 @@ macro_rules! intrinsics {
#[naked]
$(#[$($attr)*])*
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
#[cfg_attr(all(not(windows), not(target_vendor = "apple")), linkage = "weak")]
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
pub unsafe extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
$($body)*
}
Expand Down Expand Up @@ -467,7 +467,7 @@ macro_rules! intrinsics {
mod $name {
$(#[$($attr)*])*
#[no_mangle]
#[cfg_attr(all(not(windows), not(target_vendor = "apple")), linkage = "weak")]
#[cfg_attr(not(all(windows, target_env = "gnu")), linkage = "weak")]
$(unsafe $($empty)?)? extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
super::$name($($argname),*)
}
Expand Down
Loading