tests: cross-compile multi-platform ZST ABI tests

This allows them to be blessed, regardless of platform.
This commit is contained in:
Jubilee Young 2024-10-29 23:22:36 -07:00
parent 11f9217a33
commit 0b9d1eb889
6 changed files with 73 additions and 24 deletions

View File

@ -1,27 +1,63 @@
//@ revisions: other other-linux x86_64-pc-windows-gnu s390x-linux sparc64-linux powerpc-linux
//@ normalize-stderr-test: "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
// ZSTs are only not ignored when the target_env is "gnu", "musl" or "uclibc". However, Rust does
// not currently support any other target_env on these architectures.
/*!
C doesn't have zero-sized types... except it does.
// Ignore the ZST revisions
//@[other] ignore-x86_64-pc-windows-gnu
//@[other] ignore-linux
//@[other-linux] only-linux
//@[other-linux] ignore-s390x
//@[other-linux] ignore-sparc64
//@[other-linux] ignore-powerpc
Standard C doesn't, but some C compilers, like GCC, implement ZSTs as a compiler extension.
This historically has wound up interacting with processor-specific ABIs in fairly ad-hoc ways.
e.g. despite being "zero-sized", sometimes C compilers decide ZSTs consume registers.
// Pass the ZST indirectly revisions
//@[x86_64-pc-windows-gnu] only-x86_64-pc-windows-gnu
//@[s390x-linux] only-s390x
//@[s390x-linux] only-linux
//@[sparc64-linux] only-sparc64
//@[sparc64-linux] only-linux
//@[powerpc-linux] only-powerpc
//@[powerpc-linux] only-linux
That means these two function signatures may not be compatible:
#![feature(rustc_attrs)]
```
extern "C" fn((), i32, i32);
extern "C" fn(i32, (), i32);
```
*/
/*
* ZST IN "C" IS ZERO-SIZED
*/
//@ revisions: aarch64-darwin
//@[aarch64-darwin] compile-flags: --target aarch64-apple-darwin
//@[aarch64-darwin] needs-llvm-components: aarch64
//@ revisions: x86_64-linux
//@[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu
//@[x86_64-linux] needs-llvm-components: x86
/*
* ZST IN "C" IS PASS-BY-POINTER
*/
// according to the SRV4 ABI, an aggregate is always passed in registers,
// and it so happens the GCC extension for ZSTs considers them as structs.
//@ revisions: powerpc-linux
//@[powerpc-linux] compile-flags: --target powerpc-unknown-linux-gnu
//@[powerpc-linux] needs-llvm-components: powerpc
//@ revisions: s390x-linux
//@[s390x-linux] compile-flags: --target s390x-unknown-linux-gnu
//@[s390x-linux] needs-llvm-components: systemz
//@ revisions: sparc64-linux
//@[sparc64-linux] compile-flags: --target sparc64-unknown-linux-gnu
//@[sparc64-linux] needs-llvm-components: sparc
// The Win64 ABI uses slightly different handling for power-of-2 sizes in the ABI,
// so GCC decided that ZSTs are pass-by-pointer, as `0.is_power_of_two() == false`
//@ revisions: x86_64-pc-windows-gnu
//@[x86_64-pc-windows-gnu] compile-flags: --target x86_64-pc-windows-gnu
//@[x86_64-pc-windows-gnu] needs-llvm-components: x86
#![feature(lang_items, no_core, rustc_attrs)]
#![no_core]
#![crate_type = "lib"]
#[lang = "sized"]
trait Sized {}
#[rustc_abi(debug)]
extern "C" fn pass_zst(_: ()) {} //~ ERROR: fn_abi

View File

@ -1,11 +1,24 @@
//@ only-x86_64
//@ revisions: other windows-gnu
//@ normalize-stderr-test: "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
//@[other] ignore-windows-gnu
//@[windows-gnu] only-windows-gnu
//@ only-x86_64
#![feature(rustc_attrs)]
//@ revisions: x86_64-linux
//@[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu
//@[x86_64-linux] needs-llvm-components: x86
//@ revisions: x86_64-windows-gnu
//@[x86_64-windows-gnu] compile-flags: --target x86_64-pc-windows-gnu
//@[x86_64-windows-gnu] needs-llvm-components: x86
//@ revisions: x86_64-windows-msvc
//@[x86_64-windows-msvc] compile-flags: --target x86_64-pc-windows-msvc
//@[x86_64-windows-msvc] needs-llvm-components: x86
#![feature(no_core, lang_items, rustc_attrs)]
#![no_core]
#![crate_type = "lib"]
#[lang = "sized"]
trait Sized {}
#[rustc_abi(debug)]
extern "win64" fn pass_zst(_: ()) {} //~ ERROR: fn_abi