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

From: Chang S. Bae

Date: Sat Aug 01 2026 - 20:06:28 EST


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

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.

Thanks,
Chang