Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: "Thomas Weißschuh" <linux@weissschuh.net>
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 13:28:37 -0700	[thread overview]
Message-ID: <20261125202837.GB3625068@ax162> (raw)
In-Reply-To: <25eaa926-c244-40a5-b7b9-e5182e601446@t-8ch.de>

On Wed, Nov 25, 2026 at 11:27:10AM +0100, Thomas Weißschuh wrote:
> The expansion to bit width and endianess will be a lot of busy-work.
> See the CC_CAN_LINK infrastructure.

Yeah, fair enough.

> 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.

Ah, thanks a lot for reminding me about SUBARCH! In looking around, I
noticed that Kbuild already checks if SRCARCH = SUBARCH and exports
cross_compiling=1 in that case, which means this patch should just
become

diff --git a/scripts/Kconfig.toolchain b/scripts/Kconfig.toolchain
index 2acbd40a38f1..a8b5258eac7e 100644
--- a/scripts/Kconfig.toolchain
+++ b/scripts/Kconfig.toolchain
@@ -97,6 +97,9 @@ config RUSTC_CLANG_LLVM_COMPATIBLE
 	  LTO) require the same LLVM major version to work properly. For best
 	  compatibility it is recommended that the exact same LLVM is used.
 
+config CROSS_COMPILING
+	def_bool $(success,test "$(cross_compiling)" = "1")
+
 config ARCH_HAS_CC_CAN_LINK
 	bool
 
--

unless we did not want the separate symbol, in which case patch two
could just become

diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 6e7a366f0798..b40aaff6867d 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -217,6 +217,7 @@ config RUSTC_HAS_APXF
 config X86_NATIVE_CPU
 	bool "Build and optimize for local/native CPU"
 	depends on X86_64
+	depends on $(success,test "$(cross_compiling)" = "")
 	depends on CC_HAS_MARCH_NATIVE
 	depends on !RUST || RUSTC_HAS_APXF
 	help
--

-tip folks, preferences?

-- 
Cheers,
Nathan

  reply	other threads:[~2026-11-25 20:28 UTC|newest]

Thread overview: 6+ 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
2026-11-25 20:28     ` Nathan Chancellor [this message]
2026-11-26  6:43   ` sashiko-bot
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=20261125202837.GB3625068@ax162 \
    --to=nathan@kernel.org \
    --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=linux@weissschuh.net \
    --cc=llvm@lists.linux.dev \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --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