I think you meant to use #[cfg(target_feature = "neon")]?.
the #[target_feature(...)] attribute is a (per-function) codegen option for the backend, it's related, but not the equivalent to conditional compilcation guards.
see also this previous question:
I'm trying to compile Rustdesk server to run on older hardware which does not support AVX and I cannot compile it directly on it:
sub-repo: GitHub - rustdesk/hbb_common
I have tried multiple options like setting
RUSTFLAGS = "-C target-feature=-avx,-avx2"
also similar things in Cargo.toml or .cargo/config.toml .
But I still get binary executable which have these instructions enabled. Can it be from a dependency or the flags are ignored?
What can I try or analyze?
or this one:
Problem
I've written some SIMD intrinsics code targeting x86-64: SSE4.1, AVX, and AVX2. I began reading some of the assembly output, and came across a troubling result. When I made the mistake of not explicitly enabling AVX2 but only AVX, the compiler generated weird code sequences for AVX2 intrinsics.
This is very problematic since code like this may go unnoticed unless the actual assembly is inspected with every version. Is there any way to disable or protect against this code generation?
Ex…