Skip to content

Commit e02de83

Browse files
authored
Rollup merge of #137370 - RalfJung:x86-abi-fallback, r=SparrowLii
adjust_abi: make fallback logic for ABIs a bit easier to read I feel like the match guards here make this unnecessarily harder to follow.
2 parents ad27045 + f7ae9e1 commit e02de83

File tree

1 file changed

+26
-11
lines changed
  • compiler/rustc_target/src/spec

1 file changed

+26
-11
lines changed

compiler/rustc_target/src/spec/mod.rs

+26-11
Original file line numberDiff line numberDiff line change
@@ -2914,20 +2914,35 @@ impl Target {
29142914
// On Windows, `extern "system"` behaves like msvc's `__stdcall`.
29152915
// `__stdcall` only applies on x86 and on non-variadic functions:
29162916
// https://learn.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-170
2917-
System { unwind } if self.is_like_windows && self.arch == "x86" && !c_variadic => {
2918-
Stdcall { unwind }
2917+
System { unwind } => {
2918+
if self.is_like_windows && self.arch == "x86" && !c_variadic {
2919+
Stdcall { unwind }
2920+
} else {
2921+
C { unwind }
2922+
}
2923+
}
2924+
2925+
EfiApi => {
2926+
if self.arch == "arm" {
2927+
Aapcs { unwind: false }
2928+
} else if self.arch == "x86_64" {
2929+
Win64 { unwind: false }
2930+
} else {
2931+
C { unwind: false }
2932+
}
29192933
}
2920-
System { unwind } => C { unwind },
2921-
EfiApi if self.arch == "arm" => Aapcs { unwind: false },
2922-
EfiApi if self.arch == "x86_64" => Win64 { unwind: false },
2923-
EfiApi => C { unwind: false },
29242934

29252935
// See commentary in `is_abi_supported`.
2926-
Stdcall { .. } | Thiscall { .. } if self.arch == "x86" => abi,
2927-
Stdcall { unwind } | Thiscall { unwind } => C { unwind },
2928-
Fastcall { .. } if self.arch == "x86" => abi,
2929-
Vectorcall { .. } if ["x86", "x86_64"].contains(&&self.arch[..]) => abi,
2930-
Fastcall { unwind } | Vectorcall { unwind } => C { unwind },
2936+
Stdcall { unwind } | Thiscall { unwind } | Fastcall { unwind } => {
2937+
if self.arch == "x86" { abi } else { C { unwind } }
2938+
}
2939+
Vectorcall { unwind } => {
2940+
if ["x86", "x86_64"].contains(&&*self.arch) {
2941+
abi
2942+
} else {
2943+
C { unwind }
2944+
}
2945+
}
29312946

29322947
// The Windows x64 calling convention we use for `extern "Rust"`
29332948
// <https://learn.microsoft.com/en-us/cpp/build/x64-software-conventions#register-volatility-and-preservation>

0 commit comments

Comments
 (0)