From 1054054a46b8b13a54fc5e5ac89b6103c5528c9b Mon Sep 17 00:00:00 2001 From: Oneirical Date: Mon, 5 Aug 2024 15:07:33 -0400 Subject: [PATCH] rewrite simd-ffi to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/simd-ffi/Makefile | 47 -------------- tests/run-make/simd-ffi/rmake.rs | 63 +++++++++++++++++++ 3 files changed, 63 insertions(+), 48 deletions(-) delete mode 100644 tests/run-make/simd-ffi/Makefile create mode 100644 tests/run-make/simd-ffi/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 38880e5e95f..90a85efb3ae 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -29,7 +29,6 @@ run-make/redundant-libs/Makefile run-make/remap-path-prefix-dwarf/Makefile run-make/reproducible-build/Makefile run-make/rlib-format-packed-bundled-libs/Makefile -run-make/simd-ffi/Makefile run-make/split-debuginfo/Makefile run-make/staticlib-dylib-linkage/Makefile run-make/symbol-mangling-hashed/Makefile diff --git a/tests/run-make/simd-ffi/Makefile b/tests/run-make/simd-ffi/Makefile deleted file mode 100644 index 29735347041..00000000000 --- a/tests/run-make/simd-ffi/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -include ../tools.mk - -TARGETS = -ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm) -# construct a fairly exhaustive list of platforms that we -# support. These ones don't follow a pattern -TARGETS += arm-linux-androideabi arm-unknown-linux-gnueabihf arm-unknown-linux-gnueabi -endif - -ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) -X86_ARCHS = i686 x86_64 -else -X86_ARCHS = -endif - -# these ones do, each OS lists the architectures it supports -LINUX=$(filter aarch64 mips,$(LLVM_COMPONENTS)) $(X86_ARCHS) -ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips) -LINUX += mipsel -endif - -WINDOWS=$(X86_ARCHS) -# fails with: failed to get iphonesimulator SDK path: no such file or directory -#IOS=i386 aarch64 armv7 -DARWIN=$(X86_ARCHS) - -$(foreach arch,$(LINUX),$(eval TARGETS += $(arch)-unknown-linux-gnu)) -$(foreach arch,$(WINDOWS),$(eval TARGETS += $(arch)-pc-windows-gnu)) -#$(foreach arch,$(IOS),$(eval TARGETS += $(arch)-apple-ios)) -$(foreach arch,$(DARWIN),$(eval TARGETS += $(arch)-apple-darwin)) - -all: $(TARGETS) - -define MK_TARGETS -# compile the rust file to the given target, but only to asm and IR -# form, to avoid having to have an appropriate linker. -# -# we need some features because the integer SIMD instructions are not -# enabled by-default for i686 and ARM; these features will be invalid -# on some platforms, but LLVM just prints a warning so that's fine for -# now. -$(1): simd.rs - $$(RUSTC) --target=$(1) --emit=llvm-ir,asm simd.rs \ - -C target-feature='+neon,+sse2' -C extra-filename=-$(1) -endef - -$(foreach targetxxx,$(TARGETS),$(eval $(call MK_TARGETS,$(targetxxx)))) diff --git a/tests/run-make/simd-ffi/rmake.rs b/tests/run-make/simd-ffi/rmake.rs new file mode 100644 index 00000000000..04990c8bdf4 --- /dev/null +++ b/tests/run-make/simd-ffi/rmake.rs @@ -0,0 +1,63 @@ +// Using SIMD types in a program with foreign-function interfaces used to result in an ICE +// (internal compiler error). Since this was fixed in #21233, it should be checked that +// compilation of SIMD and FFI together should be successful on all the most common +// architectures. +// Note that this test does not check linking or binary execution. +// See https://github.com/rust-lang/rust/pull/21233 + +use run_make_support::{llvm_components_contain, rustc}; + +fn main() { + let mut targets = Vec::new(); + // arm-specific targets. + if llvm_components_contain("arm") { + targets.append(&mut vec![ + "arm-linux-androideabi".to_owned(), + "arm-unknown-linux-gnueabihf".to_owned(), + "arm-unknown-linux-gnueabi".to_owned(), + ]); + } + let mut x86_archs = Vec::new(); + if llvm_components_contain("x86") { + x86_archs.append(&mut vec!["i686", "x86_64"]); + } + // Linux has all x86 targets, plus aarch64 and mips. + let mut extra_targets = x86_archs.clone(); + if llvm_components_contain("aarch64") { + extra_targets.push("aarch64"); + } + if llvm_components_contain("mips") { + extra_targets.append(&mut vec!["mips", "mipsel"]); + } + + for target in extra_targets { + let linux = format!("{target}-unknown-linux-gnu"); + targets.push(linux); + } + + // Windows and Darwin (OSX) only receive x86 targets. + let extra_targets = x86_archs.clone(); + for target in extra_targets { + let windows = format!("{target}-pc-windows-gnu"); + let darwin = format!("{target}-apple-darwin"); + targets.push(windows); + targets.push(darwin); + } + + for target in targets { + // compile the rust file to the given target, but only to asm and IR + // form, to avoid having to have an appropriate linker. + // + // we need some features because the integer SIMD instructions are not + // enabled by-default for i686 and ARM; these features will be invalid + // on some platforms, but LLVM just prints a warning so that's fine for + // now. + rustc() + .target(&target) + .emit("llvm-ir,asm") + .input("simd.rs") + .arg("-Ctarget-feature=+neon,+sse") + .arg(&format!("-Cextra-filename=-{target}")) + .run(); + } +}