Re: [PATCH] x86/build/64: Prevent native builds from generating APX instructions
From: David Laight
Date: Sun Aug 02 2026 - 05:08:33 EST
On Sat, 1 Aug 2026 17:00:36 -0700
"Chang S. Bae" <chang.seok.bae@xxxxxxxxx> wrote:
> On 8/1/2026 4:44 AM, David Laight wrote:
> >
> > Much like when AVX support was added, -march-native needs to check that the
> > operating system is saving the registers not that the cpu supports them.
>
> This GCC bug looks relevant:
>
> "__builtin_cpu_supports avx does not verify OS supports it"
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85100
Yes, except I thought it was much older...
> The resulting commit 059cc8aca774 ("i386: Enable AVX/AVX512 features
> only if supported by OSXSAVE") switched the compiler to read XCR0 before
> set_feature().
>
> Similarly, the APX enablement commit e686416b6217 ("[APX_EGPR] Initial
> support for APX_F") extends the XCR0 check to determine whether APX is
> usable. So, the compiler seemingly won't emit APX instructions without
> OS setting XCR0.APX.
Does that mean that this patch is completely unnecessary?
David
>
> Thanks,
> Chang