|
| 1 | +//@ add-minicore |
| 2 | +//@ check-pass |
| 3 | +// |
| 4 | +//@ revisions: linux_gnu linux_musl linux_ohos linux_powerpc |
| 5 | +//@[linux_gnu] compile-flags: --target aarch64-unknown-linux-gnu |
| 6 | +//@[linux_gnu] needs-llvm-components: aarch64 |
| 7 | +//@[linux_musl] compile-flags: --target aarch64-unknown-linux-musl |
| 8 | +//@[linux_musl] needs-llvm-components: aarch64 |
| 9 | +//@[linux_ohos] compile-flags: --target aarch64-unknown-linux-ohos |
| 10 | +//@[linux_ohos] needs-llvm-components: aarch64 |
| 11 | +//@[linux_powerpc] compile-flags: --target powerpc-unknown-linux-gnu |
| 12 | +//@[linux_powerpc] needs-llvm-components: powerpc |
| 13 | +// |
| 14 | +//@ revisions: darwin ios |
| 15 | +//@[darwin] compile-flags: --target aarch64-apple-darwin |
| 16 | +//@[darwin] needs-llvm-components: aarch64 |
| 17 | +//@[ios] compile-flags: --target aarch64-apple-ios |
| 18 | +//@[ios] needs-llvm-components: aarch64 |
| 19 | +// |
| 20 | +//@ revisions: win_msvc win_gnu |
| 21 | +//@[win_msvc] compile-flags: --target aarch64-pc-windows-msvc |
| 22 | +//@[win_msvc] needs-llvm-components: aarch64 |
| 23 | +//@[win_gnu] compile-flags: --target x86_64-pc-windows-gnu |
| 24 | +//@[win_gnu] needs-llvm-components: x86 |
| 25 | +// |
| 26 | +//@ revisions: wasm32 wasm64 |
| 27 | +//@[wasm32] compile-flags: --target wasm32-unknown-unknown |
| 28 | +//@[wasm32] needs-llvm-components: webassembly |
| 29 | +//@[wasm64] compile-flags: --target wasm64-unknown-unknown |
| 30 | +//@[wasm64] needs-llvm-components: webassembly |
| 31 | +// |
| 32 | +//@ revisions: aix |
| 33 | +//@[aix] compile-flags: --target powerpc64-ibm-aix |
| 34 | +//@[aix] needs-llvm-components: powerpc |
| 35 | +// |
| 36 | +//@ revisions: hermit sgx uefi |
| 37 | +//@[hermit] compile-flags: --target x86_64-unknown-hermit |
| 38 | +//@[hermit] needs-llvm-components: x86 |
| 39 | +//@[sgx] compile-flags: --target x86_64-fortanix-unknown-sgx |
| 40 | +//@[sgx] needs-llvm-components: x86 |
| 41 | +//@[uefi] compile-flags: --target x86_64-unknown-uefi |
| 42 | +//@[uefi] needs-llvm-components: x86 |
| 43 | +// |
| 44 | +//@ revisions: bpfeb bpfel |
| 45 | +//@[bpfeb] compile-flags: --target bpfeb-unknown-none |
| 46 | +//@[bpfeb] needs-llvm-components: bpf |
| 47 | +//@[bpfel] compile-flags: --target bpfel-unknown-none |
| 48 | +//@[bpfel] needs-llvm-components: bpf |
| 49 | +// |
| 50 | +//@ revisions: avr |
| 51 | +//@[avr] compile-flags: --target avr-none -Ctarget-cpu=atmega328 |
| 52 | +//@[avr] needs-llvm-components: avr |
| 53 | +// |
| 54 | +//@ revisions: msp430 |
| 55 | +//@[msp430] compile-flags: --target msp430-none-elf |
| 56 | +//@[msp430] needs-llvm-components: msp430 |
| 57 | +// |
| 58 | +//@ revisions: thumb |
| 59 | +//@[thumb] compile-flags: --target thumbv7m-none-eabi |
| 60 | +//@[thumb] needs-llvm-components: arm |
| 61 | +#![crate_type = "lib"] |
| 62 | +#![feature(no_core, lang_items, cfg_target_object_format)] |
| 63 | +#![no_core] |
| 64 | + |
| 65 | +extern crate minicore; |
| 66 | +use minicore::*; |
| 67 | + |
| 68 | +macro_rules! assert_cfg { |
| 69 | + ($rhs:ident = $rhs_val:literal) => { |
| 70 | + #[cfg(not($rhs = $rhs_val))] |
| 71 | + compile_error!(concat!("expected `", stringify!($rhs), " = ", $rhs_val, "`",)); |
| 72 | + }; |
| 73 | +} |
| 74 | + |
| 75 | +const _: () = { |
| 76 | + cfg_select!( |
| 77 | + target_os = "linux" => assert_cfg!(target_object_format = "elf"), |
| 78 | + target_os = "aix" => assert_cfg!(target_object_format = "xcoff"), |
| 79 | + target_os = "uefi" => assert_cfg!(target_object_format = "coff"), |
| 80 | + target_os = "windows" => assert_cfg!(target_object_format = "coff"), |
| 81 | + target_os = "hermit" => assert_cfg!(target_object_format = "elf"), |
| 82 | + |
| 83 | + target_arch = "bpf" => assert_cfg!(target_object_format = "elf"), |
| 84 | + target_arch = "avr" => assert_cfg!(target_object_format = "elf"), |
| 85 | + target_arch = "msp430" => assert_cfg!(target_object_format = "elf"), |
| 86 | + target_abi = "eabi" => assert_cfg!(target_object_format = "elf"), |
| 87 | + |
| 88 | + target_vendor = "apple" => assert_cfg!(target_object_format = "mach-o"), |
| 89 | + target_family = "wasm" => assert_cfg!(target_object_format = "wasm"), |
| 90 | + |
| 91 | + windows => assert_cfg!(target_object_format = "coff"), |
| 92 | + |
| 93 | + _ => {} |
| 94 | + ); |
| 95 | +}; |
| 96 | + |
| 97 | +const _: () = { |
| 98 | + cfg_select!( |
| 99 | + target_object_format = "mach-o" => assert_cfg!(target_vendor = "apple"), |
| 100 | + target_object_format = "wasm" => assert_cfg!(target_family = "wasm"), |
| 101 | + target_object_format = "xcoff" => assert_cfg!(target_os = "aix"), |
| 102 | + _ => {} |
| 103 | + ); |
| 104 | +}; |
0 commit comments