@@ -267,8 +267,10 @@ fn fn_sig_for_fn_abi<'tcx>(
267
267
268
268
#[ inline]
269
269
fn conv_from_spec_abi ( tcx : TyCtxt < ' _ > , abi : ExternAbi , c_variadic : bool ) -> Conv {
270
+ let target = & tcx. sess . target ;
271
+
270
272
use rustc_abi:: ExternAbi :: * ;
271
- match tcx . sess . target . adjust_abi ( abi, c_variadic) {
273
+ match target. adjust_abi ( abi, c_variadic) {
272
274
RustIntrinsic | Rust | RustCall => Conv :: Rust ,
273
275
274
276
// This is intentionally not using `Conv::Cold`, as that has to preserve
@@ -279,10 +281,37 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: ExternAbi, c_variadic: bool) -> Conv
279
281
System { .. } => bug ! ( "system abi should be selected elsewhere" ) ,
280
282
EfiApi => bug ! ( "eficall abi should be selected elsewhere" ) ,
281
283
282
- Stdcall { .. } => Conv :: X86Stdcall ,
283
- Fastcall { .. } => Conv :: X86Fastcall ,
284
- Vectorcall { .. } => Conv :: X86VectorCall ,
285
- Thiscall { .. } => Conv :: X86ThisCall ,
284
+ // See commentary in `is_abi_supported`: we map these to "C" on targets
285
+ // where they do not make sense.
286
+ Stdcall { .. } => {
287
+ if target. arch == "x86" {
288
+ Conv :: X86Stdcall
289
+ } else {
290
+ Conv :: C
291
+ }
292
+ }
293
+ Fastcall { .. } => {
294
+ if target. arch == "x86" {
295
+ Conv :: X86Fastcall
296
+ } else {
297
+ Conv :: C
298
+ }
299
+ }
300
+ Vectorcall { .. } => {
301
+ if [ "x86" , "x86_64" ] . contains ( & & target. arch [ ..] ) {
302
+ Conv :: X86VectorCall
303
+ } else {
304
+ Conv :: C
305
+ }
306
+ }
307
+ Thiscall { .. } => {
308
+ if target. arch == "x86" {
309
+ Conv :: X86ThisCall
310
+ } else {
311
+ Conv :: C
312
+ }
313
+ }
314
+
286
315
C { .. } => Conv :: C ,
287
316
Unadjusted => Conv :: C ,
288
317
Win64 { .. } => Conv :: X86_64Win64 ,
0 commit comments