From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@kernel.org,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
hpa@zytor.com, "Omar Avelar" <omar.avelar@intel.com>,
stable@vger.kernel.org, "Miguel Ojeda" <ojeda@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
rust-for-linux <rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH] x86/build/64: Prevent native builds from generating APX instructions
Date: Tue, 14 Jul 2026 15:15:38 -0700 [thread overview]
Message-ID: <b705ef27-e87e-432a-ad1a-f425fe66887f@intel.com> (raw)
In-Reply-To: <CANiq72=-HjYOoJPd=B+0OYrHuyCO+NpcjRvmmhT_ecVZj8q97Q@mail.gmail.com>
On 7/9/2026 5:36 AM, Miguel Ojeda wrote:
> On Wed, Jul 8, 2026 at 11:40 PM Chang S. Bae <chang.seok.bae@intel.com> 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.
Ouch. :(
>
> 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.
I did some investigation [*] into the APX code generation across Rust
versions. A few notable observations:
* Rust 1.88 is the first release to recognizes the apxf target feature.
Prior to that, when LLVM supports APX, target-cpu=native appears to
allow APX code generation.
* Starting with Rust 1.95, target-cpu=native no longer appears to
enable APX instruction generation even without explicitly disabling
apxf. However, this seems to be implementation-specific and could
change in future releases.
* Passing target-feature=-apxf currently emits the warning you quoted
because the feature is still unstable. Using the generated target
JSON avoids the warning but Rust versions prior to 1.93 instead
produce another noise:
'-apxf' is not a recognized feature for this target ...
Given that, the goal here is to disable APX without build warnings. Rust
1.93 needs to be the minimum version via the generated target JSON.
>
> 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.
Indeed. This is very helpful!
Thanks,
Chang
[*]:
https://github.com/intel/apx/blob/study_rust-apxf/study_rust-apxf.md
next prev parent reply other threads:[~2026-07-14 22:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 21:14 Chang S. Bae
2026-07-09 12:36 ` Miguel Ojeda
2026-07-14 22:15 ` Chang S. Bae [this message]
2026-07-15 10:30 ` Miguel Ojeda
2026-07-12 20:25 ` Nathan Chancellor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b705ef27-e87e-432a-ad1a-f425fe66887f@intel.com \
--to=chang.seok.bae@intel.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=bp@alien8.de \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dave.hansen@linux.intel.com \
--cc=gary@garyguo.net \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=ojeda@kernel.org \
--cc=omar.avelar@intel.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tglx@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox