Change:
I tried this code on 1.73: Compiled it with , I expected it to compile fine as on previous 1.72.1, but it gave me these errors: It most recently worked on: 1.72.1 Output: : I read release notes for 1.73 and couldn't find anything that could be related to this, also tried to search for an existing issue about this - no luck. This issue also broke compilation of crate and transitively, Fyrox game engine.
Bisected to . cc
And then this was fixed by (or at least it started compiling since)
Hm, why does it think that the function requires that target feature? That function doesn't have any attribute... Cc
Ah, that's what changed in -- that from a bunch of functions. This was changed in Cc
That was changed in stdarch specifically in response to , to avoid breaking users who were using the already.
In principle we could probably silence this check on wasm, since we document wasm to be a target where calling functions with unsupported target features is safe.
What happens in wasm when you call a function that requires an unavailable target feature?
I am told that the wasm runtime will refuse to even load a module that contains invalid operations, so there are two options: the generated code makes no use of the target feature, and so everything just works the generated code makes use of the target feature, and we don't even ever get to the function call since loading the wasm module already failed
can you check on of the latest nightlies to verify if it works for you? (ref. )
We have a special exception for wasm that allows targetfeature functions to not be marked unsafe: We should probably have the same exception in the target-feature check in the interpreter. do you have the time for a follow-up PR implementing that?
I re-checked on latest nightly and seems to work fine:
I will do that
WG-prioritization assigning priority (). Issue is fixed on nightly+beta, leaving open to follow PR fixing label -I-prioritize +P-medium
In which version this fix will be included?
Should land in stable 1.74 (around mid November), iiuc. See or an

Discussion:
} fn check_fn_target_features(&self, instance: ty::Instance<'tcx>) -> InterpResult<'tcx, ()> { <ins> // Calling functions with `#[target_feature]` is not unsafe on WASM, see #84988 </ins> let attrs = self.tcx.codegen_fn_attrs(instance.def_id()); <del> if attrs .target_features .iter() .any(|feature| !self.tcx.sess.target_features.contains(feature)) </del> <ins> if !self.tcx.sess.target.is_like_wasm && attrs .target_features .iter() .any(|feature| !self.tcx.sess.target_features.contains(feature)) </ins> { throw_ub_custom!( fluent::const_eval_unavailable_target_features_for_fn,

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 <del> 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 </del> <ins> 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 </ins> 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 ;;

<ins> //@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() {} </ins>

<ins> // only-wasm32 // compile-flags:-C target-feature=-simd128 // build-pass #![crate_type = "lib"] #[cfg(target_feature = "simd128")] compile_error!("simd128 target feature should be disabled"); // Calling functions with `#[target_feature]` is not unsound on WASM, see #84988 const A: () = simd128_fn(); #[target_feature(enable = "simd128")] const fn simd128_fn() {} </ins>