-
Notifications
You must be signed in to change notification settings - Fork 13.8k
PowerPC C ZST ABI fixes #64259
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
PowerPC C ZST ABI fixes #64259
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2642,12 +2642,11 @@ where | |
}; | ||
|
||
let target = &cx.tcx().sess.target.target; | ||
let win_x64_gnu = | ||
target.target_os == "windows" && target.arch == "x86_64" && target.target_env == "gnu"; | ||
let linux_s390x = | ||
target.target_os == "linux" && target.arch == "s390x" && target.target_env == "gnu"; | ||
let linux_sparc64 = | ||
target.target_os == "linux" && target.arch == "sparc64" && target.target_env == "gnu"; | ||
let indirect_zst = match target.arch.as_ref() { | ||
"powerpc" | "s390x" | "sparc64" => true, | ||
"x86_64" => target.target_os == "windows" && target.target_env == "gnu", | ||
|
||
_ => false, | ||
}; | ||
let rust_abi = match sig.abi { | ||
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => true, | ||
_ => false, | ||
|
@@ -2709,11 +2708,10 @@ where | |
let is_return = arg_idx.is_none(); | ||
let mut arg = mk_arg_type(ty, arg_idx); | ||
if arg.layout.is_zst() { | ||
// For some forsaken reason, x86_64-pc-windows-gnu | ||
// doesn't ignore zero-sized struct arguments. | ||
// The same is true for s390x-unknown-linux-gnu | ||
// and sparc64-unknown-linux-gnu. | ||
if is_return || rust_abi || (!win_x64_gnu && !linux_s390x && !linux_sparc64) { | ||
// FIXME: The C ABI case should be handled in adjust_for_cabi. | ||
// Zero-sized struct arguments cannot be ignored in the C ABI | ||
// if they are passed indirectly. | ||
|
||
if is_return || rust_abi || !indirect_zst { | ||
arg.mode = PassMode::Ignore; | ||
} | ||
} | ||
|
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.
Wait, you've removed the
target_env == "gnu"
- this workaround only makes sense in that case, because ZSTs in C are a GNU extension.Uh oh!
There was an error while loading. Please reload this page.
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.
@eddyb That's not true. It makes equally as much sense for
target_env == "musl"
, which follows the exact same ELF ABI as glibc. As I mentioned before:It is also necessary for the BSDs, since again they use the same ABI (both as specified, and as implemented in gcc/clang).
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.
You could probably add a
has_gnu_extensions
or something that's set fortarget_env
being either"gnu"
or"musl"
.While this doesn't feel ideal, I'd certainly prefer to broaden the whitelist than start including combinations we might not be aware of, and it does make sense that
musl
would hit the same problems.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.
That still doesn't make any sense to me.
target_env
refers to the libc in use: glibc versus musl. That has nothing to do with the ABI, which is a property of the compiler.Like I already said, this fix applies for the BSDs as well as Linux (regardless of
target_env
), because they all use GCC or a GCC-compatible compiler.