Skip to content

Commit d95fd25

Browse files
committed
Auto merge of #54576 - froydnj:non-x86-abi-adjustment, r=alexcrichton
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.
2 parents 6622172 + 2819def commit d95fd25

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Diff for: src/librustc_target/spec/mod.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ impl Default for TargetOptions {
761761
}
762762

763763
impl Target {
764-
/// Given a function ABI, turn "System" into the correct ABI for this target.
764+
/// Given a function ABI, turn it into the correct ABI for this target.
765765
pub fn adjust_abi(&self, abi: Abi) -> Abi {
766766
match abi {
767767
Abi::System => {
@@ -771,6 +771,16 @@ impl Target {
771771
Abi::C
772772
}
773773
},
774+
// These ABI kinds are ignored on non-x86 Windows targets.
775+
// See https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions
776+
// and the individual pages for __stdcall et al.
777+
Abi::Stdcall | Abi::Fastcall | Abi::Vectorcall | Abi::Thiscall => {
778+
if self.options.is_like_windows && self.arch != "x86" {
779+
Abi::C
780+
} else {
781+
abi
782+
}
783+
},
774784
abi => abi
775785
}
776786
}

Diff for: src/test/codegen/issue-32364.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// ignore-arm
12-
// ignore-aarch64
11+
// Test that `extern "stdcall"` is properly translated.
12+
13+
// only-x86
1314

1415
// compile-flags: -C no-prepopulate-passes
1516

0 commit comments

Comments
 (0)