|
| 1 | +// Using SIMD types in a program with foreign-function interfaces used to result in an ICE |
| 2 | +// (internal compiler error). Since this was fixed in #21233, it should be checked that |
| 3 | +// compilation of SIMD and FFI together should be successful on all the most common |
| 4 | +// architectures. |
| 5 | +// Note that this test does not check linking or binary execution. |
| 6 | +// See https://github.com/rust-lang/rust/pull/21233 |
| 7 | + |
| 8 | +use run_make_support::{llvm_components_contain, rustc}; |
| 9 | + |
| 10 | +fn main() { |
| 11 | + let mut targets = Vec::new(); |
| 12 | + // arm-specific targets. |
| 13 | + if llvm_components_contain("arm") { |
| 14 | + targets.append(&mut vec![ |
| 15 | + "arm-linux-androideabi".to_owned(), |
| 16 | + "arm-unknown-linux-gnueabihf".to_owned(), |
| 17 | + "arm-unknown-linux-gnueabi".to_owned(), |
| 18 | + ]); |
| 19 | + } |
| 20 | + let mut x86_archs = Vec::new(); |
| 21 | + if llvm_components_contain("x86") { |
| 22 | + x86_archs.append(&mut vec!["i686", "x86_64"]); |
| 23 | + } |
| 24 | + // Linux has all x86 targets, plus aarch64 and mips. |
| 25 | + let mut extra_targets = x86_archs.clone(); |
| 26 | + if llvm_components_contain("aarch64") { |
| 27 | + extra_targets.push("aarch64"); |
| 28 | + } |
| 29 | + if llvm_components_contain("mips") { |
| 30 | + extra_targets.append(&mut vec!["mips", "mipsel"]); |
| 31 | + } |
| 32 | + |
| 33 | + for target in extra_targets { |
| 34 | + let linux = format!("{target}-unknown-linux-gnu"); |
| 35 | + targets.push(linux); |
| 36 | + } |
| 37 | + |
| 38 | + // Windows and Darwin (OSX) only receive x86 targets. |
| 39 | + let extra_targets = x86_archs.clone(); |
| 40 | + for target in extra_targets { |
| 41 | + let windows = format!("{target}-pc-windows-gnu"); |
| 42 | + let darwin = format!("{target}-apple-darwin"); |
| 43 | + targets.push(windows); |
| 44 | + targets.push(darwin); |
| 45 | + } |
| 46 | + |
| 47 | + for target in targets { |
| 48 | + // compile the rust file to the given target, but only to asm and IR |
| 49 | + // form, to avoid having to have an appropriate linker. |
| 50 | + // |
| 51 | + // we need some features because the integer SIMD instructions are not |
| 52 | + // enabled by-default for i686 and ARM; these features will be invalid |
| 53 | + // on some platforms, but LLVM just prints a warning so that's fine for |
| 54 | + // now. |
| 55 | + rustc() |
| 56 | + .target(&target) |
| 57 | + .emit("llvm-ir,asm") |
| 58 | + .input("simd.rs") |
| 59 | + .arg("-Ctarget-feature=+neon,+sse") |
| 60 | + .arg(&format!("-Cextra-filename=-{target}")) |
| 61 | + .run(); |
| 62 | + } |
| 63 | +} |
0 commit comments