Skip to content

Commit 0a91755

Browse files
committed
Properly define va_arg and va_list for aarch64-apple-darwin
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 rust-lang#78092 [Apple]: https://developer.apple.com/documentation/xcode/writing_arm64_code_for_apple_platforms
1 parent c6ab758 commit 0a91755

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

compiler/rustc_codegen_llvm/src/va_arg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ pub(super) fn emit_va_arg(
184184
"aarch64" if target.options.is_like_windows => {
185185
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), false)
186186
}
187-
// iOS AArch64
188-
"aarch64" if target.target_os == "ios" => {
187+
// macOS / iOS AArch64
188+
"aarch64" if target.options.is_like_osx => {
189189
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), true)
190190
}
191191
"aarch64" => emit_aapcs_va_arg(bx, addr, target_ty),

library/core/src/ffi.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl fmt::Debug for c_void {
6262
// The name is WIP, using `VaListImpl` for now.
6363
#[cfg(any(
6464
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
65-
all(target_arch = "aarch64", target_os = "ios"),
65+
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
6666
target_arch = "wasm32",
6767
target_arch = "asmjs",
6868
windows
@@ -85,7 +85,7 @@ pub struct VaListImpl<'f> {
8585

8686
#[cfg(any(
8787
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
88-
all(target_arch = "aarch64", target_os = "ios"),
88+
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
8989
target_arch = "wasm32",
9090
target_arch = "asmjs",
9191
windows
@@ -107,7 +107,11 @@ impl<'f> fmt::Debug for VaListImpl<'f> {
107107
///
108108
/// [AArch64 Procedure Call Standard]:
109109
/// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf
110-
#[cfg(all(target_arch = "aarch64", not(target_os = "ios"), not(windows)))]
110+
#[cfg(all(
111+
target_arch = "aarch64",
112+
not(any(target_os = "macos", target_os = "ios")),
113+
not(windows)
114+
))]
111115
#[repr(C)]
112116
#[derive(Debug)]
113117
#[unstable(
@@ -181,7 +185,7 @@ pub struct VaList<'a, 'f: 'a> {
181185
not(target_arch = "powerpc"),
182186
not(target_arch = "x86_64")
183187
),
184-
all(target_arch = "aarch64", target_os = "ios"),
188+
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
185189
target_arch = "wasm32",
186190
target_arch = "asmjs",
187191
windows
@@ -190,7 +194,7 @@ pub struct VaList<'a, 'f: 'a> {
190194

191195
#[cfg(all(
192196
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
193-
any(not(target_arch = "aarch64"), not(target_os = "ios")),
197+
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
194198
not(target_arch = "wasm32"),
195199
not(target_arch = "asmjs"),
196200
not(windows)
@@ -202,7 +206,7 @@ pub struct VaList<'a, 'f: 'a> {
202206

203207
#[cfg(any(
204208
all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
205-
all(target_arch = "aarch64", target_os = "ios"),
209+
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios")),
206210
target_arch = "wasm32",
207211
target_arch = "asmjs",
208212
windows
@@ -223,7 +227,7 @@ impl<'f> VaListImpl<'f> {
223227

224228
#[cfg(all(
225229
any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
226-
any(not(target_arch = "aarch64"), not(target_os = "ios")),
230+
any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))),
227231
not(target_arch = "wasm32"),
228232
not(target_arch = "asmjs"),
229233
not(windows)

0 commit comments

Comments
 (0)