From 001f789838e756729ba1491d6a74de14c07bc61d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Mon, 9 Oct 2023 19:11:42 +0200 Subject: [PATCH] const-eval: allow calling functions with targat features disabled at compile time in WASM This is not unsafe on WASM, see https://github.com/rust-lang/rust/pull/84988 --- ci.sh | 4 ++-- tests/pass/function_calls/target_feature_wasm.rs | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 tests/pass/function_calls/target_feature_wasm.rs diff --git a/ci.sh b/ci.sh index 1b3ed796c6..eda1ceb408 100755 --- a/ci.sh +++ b/ci.sh @@ -110,8 +110,8 @@ case $HOST_TARGET in MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple atomic data_race env/var MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic - MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings - MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings + MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm + MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings wasm MIRI_TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std # no_std embedded architecture MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std # JSON target file ;; diff --git a/tests/pass/function_calls/target_feature_wasm.rs b/tests/pass/function_calls/target_feature_wasm.rs new file mode 100644 index 0000000000..5056f32de4 --- /dev/null +++ b/tests/pass/function_calls/target_feature_wasm.rs @@ -0,0 +1,11 @@ +//@only-target-wasm32: tests WASM-specific behavior +//@compile-flags: -C target-feature=-simd128 + +fn main() { + // Calling functions with `#[target_feature]` is not unsound on WASM, see #84988 + assert!(!cfg!(target_feature = "simd128")); + simd128_fn(); +} + +#[target_feature(enable = "simd128")] +fn simd128_fn() {}