From 42cbb401574b494c5da7a58cb2485be54992babd Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 6 Nov 2022 17:29:46 -0500 Subject: [PATCH] Use aapcs for efiapi calling convention on arm On arm, llvm treats the C calling convention as `aapcs` on soft-float targets and `aapcs-vfp` on hard-float targets [1]. UEFI specifies in the arm calling convention that floating point extensions aren't used [2], so always translate `efiapi` to `aapcs` on arm. [1]: https://github.com/rust-lang/compiler-builtins/issues/116#issuecomment-261057422 [2]: https://uefi.org/specs/UEFI/2.10/02_Overview.html#detailed-calling-convention https://github.com/rust-lang/rust/issues/65815 --- compiler/rustc_target/src/spec/mod.rs | 1 + src/test/codegen/abi-efiapi.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 72b088d663b1f..b44ed8f3fa9a3 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1915,6 +1915,7 @@ impl Target { Abi::Stdcall { unwind } } Abi::System { unwind } => Abi::C { unwind }, + Abi::EfiApi if self.arch == "arm" => Abi::Aapcs { unwind: false }, Abi::EfiApi if self.arch == "x86_64" => Abi::Win64 { unwind: false }, Abi::EfiApi => Abi::C { unwind: false }, diff --git a/src/test/codegen/abi-efiapi.rs b/src/test/codegen/abi-efiapi.rs index b4fda5f8c8428..9061d7432a3fa 100644 --- a/src/test/codegen/abi-efiapi.rs +++ b/src/test/codegen/abi-efiapi.rs @@ -27,7 +27,7 @@ trait Copy { } //x86_64: define win64cc void @has_efiapi //i686: define void @has_efiapi //aarch64: define dso_local void @has_efiapi -//arm: define dso_local void @has_efiapi +//arm: define dso_local arm_aapcscc void @has_efiapi //riscv: define dso_local void @has_efiapi #[no_mangle] pub extern "efiapi" fn has_efiapi() {}