@@ -2962,12 +2962,12 @@ impl Target {
29622962 }
29632963 }
29642964
2965- pub fn is_abi_supported ( & self , abi : ExternAbi ) -> bool {
2965+ /// Returns `None` if the ABI was accidentally allowed and the UNSUPPORTED_CALLING_CONVENTIONS
2966+ /// lint should be emitted.
2967+ pub fn is_abi_supported ( & self , abi : ExternAbi ) -> Option < bool > {
29662968 use ExternAbi :: * ;
2967- match abi {
2968- Rust | C { .. } | System { .. } | RustCall | Unadjusted | Cdecl { .. } | RustCold => {
2969- true
2970- }
2969+ Some ( match abi {
2970+ Rust | C { .. } | System { .. } | RustCall | Unadjusted | RustCold => true ,
29712971 EfiApi => {
29722972 [ "arm" , "aarch64" , "riscv32" , "riscv64" , "x86" , "x86_64" ] . contains ( & & self . arch [ ..] )
29732973 }
@@ -2984,44 +2984,30 @@ impl Target {
29842984 RiscvInterruptM | RiscvInterruptS => [ "riscv32" , "riscv64" ] . contains ( & & self . arch [ ..] ) ,
29852985 AvrInterrupt | AvrNonBlockingInterrupt => self . arch == "avr" ,
29862986 Thiscall { .. } => self . arch == "x86" ,
2987- // On windows these fall-back to platform native calling convention (C) when the
2988- // architecture is not supported.
2989- //
2990- // This is I believe a historical accident that has occurred as part of Microsoft
2991- // striving to allow most of the code to "just" compile when support for 64-bit x86
2992- // was added and then later again, when support for ARM architectures was added.
2993- //
2994- // This is well documented across MSDN. Support for this in Rust has been added in
2995- // #54576. This makes much more sense in context of Microsoft's C++ than it does in
2996- // Rust, but there isn't much leeway remaining here to change it back at the time this
2997- // comment has been written.
2998- //
2999- // Following are the relevant excerpts from the MSDN documentation.
3000- //
3001- // > The __vectorcall calling convention is only supported in native code on x86 and
3002- // x64 processors that include Streaming SIMD Extensions 2 (SSE2) and above.
3003- // > ...
3004- // > On ARM machines, __vectorcall is accepted and ignored by the compiler.
3005- //
3006- // -- https://docs.microsoft.com/en-us/cpp/cpp/vectorcall?view=msvc-160
3007- //
3008- // > On ARM and x64 processors, __stdcall is accepted and ignored by the compiler;
3009- //
3010- // -- https://docs.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-160
3011- //
3012- // > In most cases, keywords or compiler switches that specify an unsupported
3013- // > convention on a particular platform are ignored, and the platform default
3014- // > convention is used.
3015- //
3016- // -- https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions
3017- Stdcall { .. } | Fastcall { .. } | Vectorcall { .. } if self . is_like_windows => true ,
3018- // Outside of Windows we want to only support these calling conventions for the
3019- // architectures for which these calling conventions are actually well defined.
3020- Stdcall { .. } | Fastcall { .. } if self . arch == "x86" => true ,
3021- Vectorcall { .. } if [ "x86" , "x86_64" ] . contains ( & & self . arch [ ..] ) => true ,
3022- // Reject these calling conventions everywhere else.
3023- Stdcall { .. } | Fastcall { .. } | Vectorcall { .. } => false ,
3024- }
2987+ Stdcall { .. } | Fastcall { .. } => {
2988+ if self . arch == "x86" {
2989+ true
2990+ } else {
2991+ // This *should* be false, but we emit an FCW on Windows since ABIs were not
2992+ // properly validated in the past. Also see
2993+ // <https://github.com/rust-lang/rust/issues/137018>.
2994+ if self . is_like_windows {
2995+ return None ;
2996+ } else {
2997+ false
2998+ }
2999+ }
3000+ }
3001+ Cdecl { .. } => {
3002+ if self . arch == "x86" {
3003+ true
3004+ } else {
3005+ // Similar to above, we emit an FCW for backwards compatibility.
3006+ return None ;
3007+ }
3008+ }
3009+ Vectorcall { .. } => [ "x86" , "x86_64" ] . contains ( & & self . arch [ ..] ) ,
3010+ } )
30253011 }
30263012
30273013 /// Minimum integer size in bits that this target can perform atomic
0 commit comments