Re: [PATCH v2] x86/build/64: Prevent native builds from generating APX instructions
From: Chang S. Bae
Date: Fri Aug 07 2026 - 23:26:31 EST
On 8/7/2026 9:58 AM, Miguel Ojeda wrote:
On Fri, Aug 7, 2026 at 5:43 PM Chang S. Bae <chang.seok.bae@xxxxxxxxx> wrote:
Omar reported this broad concern to me, when resolving a separate issue
with his custom module. CONFIG_X86_NATIVE_CPU=y allows builds to
opportunistically emit APX instructions when the build host supports APX
since the commit.
I think this sentence may be cut? I guess this refers to the commit in
the Fixes tag.
Yes, I intended “the commit” to refer to the one in the Fixes: tag. To make it explicit, I can add the commit back here:
ea1dcca1de12 ("x86/kbuild/64: Add the CONFIG_X86_NATIVE_CPU ...")
For Rust, APX must be explicitly disabled because any backend supporting
APX may otherwise emit APX instructions with target-cpu=native. Pass
features=-apxf through the generated JSON to avoid unstable-feature
warnings.
So, just to confirm: is Rust 1.88 (with a new enough LLVM) enough to
avoid the warnings? Maybe a link to the tracking issue would be nice:
https://github.com/rust-lang/rust/issues/139284
Passing `-apxf` through the generated target JSON avoids this warning:
warning: unstable feature specified for `-Ctarget-feature`: `apxf`
|
= note: this feature is not stably supported; its behavior can change in the future
I’ll add the link to reference the status of the Rust support. Thanks.
Support for this gating also depends on the Rust/LLVM combination. Rust
1.88 introduced the `apxf` feature option, but versions prior to 1.93 may
emit an `apxf` attribute which LLVM 23 or later can interpret. Restrict
native Rust builds accordingly.
Fixes: ea1dcca1de12 ("x86/kbuild/64: Add the CONFIG_X86_NATIVE_CPU option to locally optimize the kernel with '-march=native'")
This looks like it exists in 6.18.y+, so I assume this should have:
Cc: stable@xxxxxxxxxxxxxxx
Yes, I have included it.
Thanks,
Chang