ARMv7: target_feature not forwarded?

Consider this code:

#[cfg(target_feature = "neon")]
compile_error!("Neon!");

#[cfg(not(target_feature = "neon"))]
compile_error!("No neon?!");

fn main() {
    println!("hello world");
}

If compiled with rustc --target=armv7-unknown-linux-gnueabihf -C target-feature=+v7,+neon neon.rs on 1.65.0, this gives the "No neon?!" compile error, but on my current nightly (rustc 1.67.0-nightly (215e3cd21 2022-11-03)), the same command works as expected, switching between both +neon and -neon. For aarch64-unknown-linux-gnueabihf, it seems to work correctly on the stable compiler.

Is there documentation around when and why it's supposed to work? Silently failing like this is very annoying.

EDIT: with rustc 1.67.0-nightly (6284998a2 2022-11-12), I seem to have only the v7 flag forwarded through cargo +nightly doc, not the neon flag. I'm starting to go crazy.

1 Like

Neon is an unstable feature on arm. Rustc ignores all unstable cfg's on stable and beta. As such #[cfg(target_feature = "neon")] won't work.

1 Like

That's good to know, thanks! It's a bit annoying that there's no error message for these...

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.