diff options
| author | Nathan Froyd <froydnj@gmail.com> | 2018-09-25 16:37:31 -0400 |
|---|---|---|
| committer | Nathan Froyd <froydnj@gmail.com> | 2018-09-27 16:50:47 -0400 |
| commit | 2819deffe3988b438bb7fab7463299fa6c917502 (patch) | |
| tree | 36bcbfe8ad4158a8f8070b53f4856418f27e169e | |
| parent | 31789a658bb6b6c78da1f2b99a5f169e4e8b983b (diff) | |
ignore {std,fast,vector,this}call on non-x86 windows
MSVC ignores these keywords for C/C++ and uses the standard system calling convention. Rust should do so as well. Fixes #54569.
| -rw-r--r-- | src/librustc_target/spec/mod.rs | 12 | ||||
| -rw-r--r-- | src/test/codegen/issue-32364.rs | 5 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 3c68b5a7ab1..3f1e8ee5528 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 401253a315f..8feb10b5757 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 |
