Re: [tip: x86/urgent] x86/build: Do not allow X86_NATIVE_CPU to be enabled when compile testing
From: David Laight
Date: Mon Nov 16 2026 - 17:36:34 EST
On Mon, 16 Nov 2026 07:48:34 -0800
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> 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.
I don't even remember a check that the compiler is right for the architecture.
I'm sure I've got strange errors when I've forgotten I need to specify the
compiler for a cross build - and then forgotten where I'd put the compiler,
Oh and forgotten all the things you need to set to get clang to do a
cross compile.
David
>
> 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
>