Files
Jonathan Brouwer 470cb0754e Rollup merge of #153763 - nikic:target-cpu-native-fix, r=lqd
Don't add empty target features for target-cpu=native on macOS

LLVM does not support host feature detection (only host cpu detection) on apple platforms. As such, the returned feature string will be empty. Adding this empty string to the target-features attribute results in a verifier error on LLVM 22.

Fix this by not adding the empty string to the target features. The reason why this was not caught by the target-cpu-native test is that it requires a function that adds *some* target features, otherwise the attribute is omitted entirely. We achieve this with a somewhat peculiar construction that enables `neon` if it's already enabled. (This is to avoid enabling it on softfloat targets.)

Fixes https://github.com/rust-lang/rust/issues/153397.
2026-03-24 18:16:01 -07:00

10 lines
305 B
Rust

fn main() {}
// This forces explicit emission of a +neon target feature on targets
// where it is implied by the target-cpu, like aarch64-apple-darwin.
// This is a regression test for #153397.
#[cfg(target_feature = "neon")]
#[target_feature(enable = "neon")]
#[unsafe(no_mangle)]
pub fn with_neon() {}