Re: [PATCH] x86/build/64: Prevent native builds from generating APX instructions

From: Miguel Ojeda

Date: Thu Jul 09 2026 - 08:38:03 EST


On Wed, Jul 8, 2026 at 11:40 PM Chang S. Bae <chang.seok.bae@xxxxxxxxx> wrote:
>
> + KBUILD_RUSTFLAGS += -Ctarget-cpu=native $(if $(call rust-min-version,109100),-Ctarget-feature=-apxf,)

Hmm... I don't think this was tested?

There is a missing `c` there -- the flag is never going to get passed.

And while it is true that `rustc` knows about the target feature since
1.88.0, it will (sadly) still loudly warn about it:

warning: unstable feature specified for `-Ctarget-feature`: `apxf`
|
= note: this feature is not stably supported; its behavior can
change in the future

Instead, we should be able to do it in the custom target spec, i.e. in
`scripts/generate_rust_target.rs`, assuming `-Ctarget-cpu=native`
enables it and we need to override it. But please double-check the
interaction between those and test that LLVM is actually getting the
right set of features you want.

Finally, we are trying to get rid of the custom target and instead use
flags as soon as possible, so if the flag will be eventually needed,
then it should be stabilized.

To help with that, I have tagged the tracking issue with our Rust for
Linux tag and will raise it to them in our next meeting, but it is
even better if the actual company pings as well:

https://github.com/rust-lang/rust/issues/139284

I have also added it to our usual live list of features:

https://github.com/Rust-for-Linux/linux/issues/2

Link: https://github.com/rust-lang/rust/issues/139284
Link: https://github.com/rust-lang/rust/pull/139534

Also Cc'ing rust-for-linux and the maintainers and reviewers.

I hope this helps.

Cheers,
Miguel