diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2025-02-25 13:07:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-25 13:07:23 +0100 |
| commit | e02de837be503dd30e363b9a684c1c254778c13e (patch) | |
| tree | 30dfe5e31e40088c5cc1cc88a6498889f467da43 | |
| parent | ad27045c31a9f37ad7d44ca2a403de52d1a896d3 (diff) | |
| parent | f7ae9e11fc67f6bbbe06c095983c928225f39b88 (diff) | |
| download | rust-e02de837be503dd30e363b9a684c1c254778c13e.tar.gz rust-e02de837be503dd30e363b9a684c1c254778c13e.zip | |
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.
| -rw-r--r-- | compiler/rustc_target/src/spec/mod.rs | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 761d2848a05..cc8162a2f27 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2914,20 +2914,35 @@ impl Target { // On Windows, `extern "system"` behaves like msvc's `__stdcall`. // `__stdcall` only applies on x86 and on non-variadic functions: // https://learn.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-170 - System { unwind } if self.is_like_windows && self.arch == "x86" && !c_variadic => { - Stdcall { unwind } + System { unwind } => { + if self.is_like_windows && self.arch == "x86" && !c_variadic { + Stdcall { unwind } + } else { + C { unwind } + } + } + + EfiApi => { + if self.arch == "arm" { + Aapcs { unwind: false } + } else if self.arch == "x86_64" { + Win64 { unwind: false } + } else { + C { unwind: false } + } } - System { unwind } => C { unwind }, - EfiApi if self.arch == "arm" => Aapcs { unwind: false }, - EfiApi if self.arch == "x86_64" => Win64 { unwind: false }, - EfiApi => C { unwind: false }, // See commentary in `is_abi_supported`. - Stdcall { .. } | Thiscall { .. } if self.arch == "x86" => abi, - Stdcall { unwind } | Thiscall { unwind } => C { unwind }, - Fastcall { .. } if self.arch == "x86" => abi, - Vectorcall { .. } if ["x86", "x86_64"].contains(&&self.arch[..]) => abi, - Fastcall { unwind } | Vectorcall { unwind } => C { unwind }, + Stdcall { unwind } | Thiscall { unwind } | Fastcall { unwind } => { + if self.arch == "x86" { abi } else { C { unwind } } + } + Vectorcall { unwind } => { + if ["x86", "x86_64"].contains(&&*self.arch) { + abi + } else { + C { unwind } + } + } // The Windows x64 calling convention we use for `extern "Rust"` // <https://learn.microsoft.com/en-us/cpp/build/x64-software-conventions#register-volatility-and-preservation> |
