Re: [tip: x86/urgent] x86/build: Do not allow X86_NATIVE_CPU to be enabled when compile testing
From: Linus Torvalds
Date: Mon Nov 16 2026 - 10:48:59 EST
On Mon, 16 Nov 2026 at 05:02, Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
>
> On Mon, Nov 16, 2026 at 10:40:01AM +0100, Ingo Molnar wrote:
> > Can we just limit the feature to when host == target, ie. to not
> > work it around in such a crude fashion?
>
> That was my v1 but Boris didn't like it:
>
> https://lore.kernel.org/20261113-x86-no-march-native-on-non-x86_64-v1-1-cbc8b096d1c4@xxxxxxxxxx
Well, that is admittedly very crude and hacky.
Maybe we should have some config variables that depend on HOSTCC, and
detect it *that* way. It does appear that we don't have any model for
cross-compiling in the Kconfig setup, but maybe we should..
I'd actually love to have support for making the compiler itself part
of Kconfig, so that the gcc-vs-clang could be *in* the .config file
rather than being an external thing to it.
I've mentioned that before, and the problem has typically been that we
end up depending on 'CC' outside of the Kconfig scripts and
independently of the current config.
The recent work to move the compiler flags into Kconfig itself may
have lessened some of those dependencies, but there's probably still
lots of small details.
But for the whole "cross-compile", maybe we can just say that
X86_NATIVE_CPU depends on '$CC' being the same as '$HOSTCC'.
Or even do '$(CC) -v" and '$(HOSTCC) -v' and check for 'Target' being
the same, and having a CONFIG_CROSSCOMPILE thing for that?
Linus