From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Nathan Chancellor <nathan@kernel.org>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Nicolas Schier <nsc@kernel.org>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Julian Braha <julianbraha@gmail.com>,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
linux-kbuild@vger.kernel.org, stable@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH v3 1/2] kbuild: Introduce CONFIG_CROSS_COMPILING
Date: Wed, 25 Nov 2026 11:27:10 +0100 [thread overview]
Message-ID: <25eaa926-c244-40a5-b7b9-e5182e601446@t-8ch.de> (raw)
In-Reply-To: <20261124-x86-no-march-native-on-non-x86_64-v3-1-268354149c5f@kernel.org>
On 2026-11-24 23:43:12-0700, Nathan Chancellor wrote:
> There are times where decisions may want to be made within Kconfig when
> cross compiling. Introduce a small script to call '$(HOSTCC) -v' and
> '$(CC) -v' and compare the first part of the target triples to see if
> they match.
>
> This check is cheap but approximate, as Kconfig does not have all the
> information available such as endianness and bit width for the target to
> pass along to compiler. For example, a user building for x86 with a
> compiler that can build both with '-m32' / '-m64' may have
> CONFIG_CROSS_COMPILING set depending on the default value of the
> toolchain and what's being targeted. Should this become problematic in
> the future, the logic can be expanded to cover these corner cases but
> for now, keep the implementation simple and cover the majority of cases.
> Leave some informational prints to make it easy to debug future reports
> with
The expansion to bit width and endianess will be a lot of busy-work.
See the CC_CAN_LINK infrastructure.
We already have host-architecture detection in kbuild through
scripts/subarch.include. So CC_HAS_MARCH_NATIVE could depend on
$(ARCH) = $(SUBARCH), after exporting SUBARCH. Or maybe give the
variable a better name, like HOSTARCH.
This would avoid the introduction of a new, not-really-correct flag
and also the whack-a-mole that Boris complained about.
> $ make ... run-command KBUILD_RUN_COMMAND='$(srctree)/scripts/check-cross-compiling.sh "$(HOSTCC)" "$(CC) $(CLANG_FLAGS)"'
>
> Cc: stable@vger.kernel.org # dependency of future change
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Link: https://lore.kernel.org/CAHk-=wgmkoWHWwaQ6nsGoCiBp0hrpJuiwmoVbQ=Efun8JyUNKw@mail.gmail.com/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> MAINTAINERS | 1 +
> scripts/Kconfig.toolchain | 3 +++
> scripts/check-cross-compiling.sh | 26 ++++++++++++++++++++++++++
> 3 files changed, 30 insertions(+)
(...)
next prev parent reply other threads:[~2026-11-25 10:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 6:43 [PATCH v3 0/2] x86: Avoid CONFIG_X86_NATIVE_CPU=y when cross compiling Nathan Chancellor
2026-11-25 6:43 ` [PATCH v3 1/2] kbuild: Introduce CONFIG_CROSS_COMPILING Nathan Chancellor
2026-11-25 10:27 ` Thomas Weißschuh [this message]
2026-11-25 6:43 ` [PATCH v3 2/2] x86/build: Do not allow X86_NATIVE_CPU to be enabled when cross compiling 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=25eaa926-c244-40a5-b7b9-e5182e601446@t-8ch.de \
--to=linux@weissschuh.net \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=julianbraha@gmail.com \
--cc=justinstitt@google.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nsc@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=torvalds@linux-foundation.org \
--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
all inboxes | Powered by JetHome®