Skip to content

Commit

Permalink
Unrolled build for rust-lang#137370
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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.
  • Loading branch information
rust-timer authored Feb 25, 2025
2 parents 4ecd70d + f7ae9e1 commit 03f0c93
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 03f0c93

Please sign in to comment.