Skip to content

Commit

Permalink
Properly define va_arg and va_list for aarch64-apple-darwin
Browse files Browse the repository at this point in the history
From [Apple][]:

> Because of these changes, the type `va_list` is an alias for `char*`,
> and not for the struct type in the generic procedure call standard.

With this change `/x.py test --stage 1 src/test/ui/abi/variadic-ffi`
passes.

Fixes #78092

[Apple]: https://developer.apple.com/documentation/xcode/writing_arm64_code_for_apple_platforms
  • Loading branch information
shepmaster committed Oct 26, 2020
1 parent c6ab758 commit 0a91755
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/va_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ pub(super) fn emit_va_arg(
"aarch64" if target.options.is_like_windows => {
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), false)
}
// iOS AArch64
"aarch64" if target.target_os == "ios" => {
// macOS / iOS AArch64
"aarch64" if target.options.is_like_osx => {
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), true)
}
"aarch64" => emit_aapcs_va_arg(bx, addr, target_ty),
Expand Down
18 changes: 11 additions & 7 deletions library/core/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl fmt::Debug for c_void {
// The name is WIP, using `VaListImpl` for now.
#[cfg(any(
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
all(target_arch = "aarch64", target_os = "ios"),
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_arch = "wasm32",
target_arch = "asmjs",
windows
Expand All @@ -85,7 +85,7 @@ pub struct VaListImpl<'f> {

#[cfg(any(
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
all(target_arch = "aarch64", target_os = "ios"),
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_arch = "wasm32",
target_arch = "asmjs",
windows
Expand All @@ -107,7 +107,11 @@ impl<'f> fmt::Debug for VaListImpl<'f> {
///
/// [AArch64 Procedure Call Standard]:
/// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf
#[cfg(all(target_arch = "aarch64", not(target_os = "ios"), not(windows)))]
#[cfg(all(
target_arch = "aarch64",
not(any(target_os = "macos", target_os = "ios")),
not(windows)
))]
#[repr(C)]
#[derive(Debug)]
#[unstable(
Expand Down Expand Up @@ -181,7 +185,7 @@ pub struct VaList<'a, 'f: 'a> {
not(target_arch = "powerpc"),
not(target_arch = "x86_64")
),
all(target_arch = "aarch64", target_os = "ios"),
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_arch = "wasm32",
target_arch = "asmjs",
windows
Expand All @@ -190,7 +194,7 @@ pub struct VaList<'a, 'f: 'a> {

#[cfg(all(
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
any(not(target_arch = "aarch64"), not(target_os = "ios")),
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
not(target_arch = "wasm32"),
not(target_arch = "asmjs"),
not(windows)
Expand All @@ -202,7 +206,7 @@ pub struct VaList<'a, 'f: 'a> {

#[cfg(any(
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
all(target_arch = "aarch64", target_os = "ios"),
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
target_arch = "wasm32",
target_arch = "asmjs",
windows
Expand All @@ -223,7 +227,7 @@ impl<'f> VaListImpl<'f> {

#[cfg(all(
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
any(not(target_arch = "aarch64"), not(target_os = "ios")),
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
not(target_arch = "wasm32"),
not(target_arch = "asmjs"),
not(windows)
Expand Down

0 comments on commit 0a91755

Please sign in to comment.