diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 3c68b5a7ab116..3f1e8ee55286b 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -761,7 +761,7 @@ impl Default for TargetOptions { } impl Target { - /// Given a function ABI, turn "System" into the correct ABI for this target. + /// Given a function ABI, turn it into the correct ABI for this target. pub fn adjust_abi(&self, abi: Abi) -> Abi { match abi { Abi::System => { @@ -771,6 +771,16 @@ impl Target { Abi::C } }, + // These ABI kinds are ignored on non-x86 Windows targets. + // See https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions + // and the individual pages for __stdcall et al. + Abi::Stdcall | Abi::Fastcall | Abi::Vectorcall | Abi::Thiscall => { + if self.options.is_like_windows && self.arch != "x86" { + Abi::C + } else { + abi + } + }, abi => abi } } diff --git a/src/test/codegen/issue-32364.rs b/src/test/codegen/issue-32364.rs index 401253a315fbf..8feb10b57577c 100644 --- a/src/test/codegen/issue-32364.rs +++ b/src/test/codegen/issue-32364.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-arm -// ignore-aarch64 +// Test that `extern "stdcall"` is properly translated. + +// only-x86 // compile-flags: -C no-prepopulate-passes