From: Arnd Bergmann <arnd@kernel.org>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andy Shevchenko <andy@kernel.org>,
Matthew Wilcox <willy@infradead.org>
Subject: [PATCH v3 03/10] x86: rework CONFIG_GENERIC_CPU compiler flags
Date: Wed, 26 Feb 2025 22:37:07 +0100 [thread overview]
Message-ID: <20250226213714.4040853-4-arnd@kernel.org> (raw)
In-Reply-To: <20250226213714.4040853-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
Building an x86-64 kernel with CONFIG_GENERIC_CPU is documented to
run on all CPUs, but the Makefile does not actually pass an -march=
argument, instead relying on the default that was used to configure
the toolchain.
In many cases, gcc will be configured to -march=x86-64 or -march=k8
for maximum compatibility, but in other cases a distribution default
may be either raised to a more recent ISA, or set to -march=native
to build for the CPU used for compilation. This still works in the
case of building a custom kernel for the local machine.
The point where it breaks down is building a kernel for another
machine that is older the the default target. Changing the default
to -march=x86-64 would make it work reliable, but possibly produce
worse code on distros that intentionally default to a newer ISA.
To allow reliably building a kernel for either the oldest x86-64
CPUs, pass the -march=x86-64 flag to the compiler. This was not
possible in early versions of x86-64 gcc, but works on all currently
supported versions down to at least gcc-5.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/x86/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5b773b34768d..5af3172fd51c 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -183,14 +183,14 @@ else
cflags-$(CONFIG_MPSC) += -march=nocona
cflags-$(CONFIG_MCORE2) += -march=core2
cflags-$(CONFIG_MATOM) += -march=atom
- cflags-$(CONFIG_GENERIC_CPU) += -mtune=generic
+ cflags-$(CONFIG_GENERIC_CPU) += -march=x86-64 -mtune=generic
KBUILD_CFLAGS += $(cflags-y)
rustflags-$(CONFIG_MK8) += -Ctarget-cpu=k8
rustflags-$(CONFIG_MPSC) += -Ctarget-cpu=nocona
rustflags-$(CONFIG_MCORE2) += -Ctarget-cpu=core2
rustflags-$(CONFIG_MATOM) += -Ctarget-cpu=atom
- rustflags-$(CONFIG_GENERIC_CPU) += -Ztune-cpu=generic
+ rustflags-$(CONFIG_GENERIC_CPU) += -Ctarget-cpu=x86-64 -Ztune-cpu=generic
KBUILD_RUSTFLAGS += $(rustflags-y)
KBUILD_CFLAGS += -mno-red-zone
--
2.39.5
next prev parent reply other threads:[~2025-02-26 21:37 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 21:37 [PATCH v3 00/10] x86: 32-bit cleanups Arnd Bergmann
2025-02-26 21:37 ` [PATCH v3 01/10] x86/Kconfig: Geode CPU has cmpxchg8b Arnd Bergmann
2025-02-27 10:42 ` [tip: x86/cpu] x86/Kconfig: Add cmpxchg8b support back to Geode CPUs tip-bot2 for Arnd Bergmann
2025-02-26 21:37 ` [PATCH v3 02/10] x86: drop 32-bit "bigsmp" machine support Arnd Bergmann
2025-02-27 10:42 ` [tip: x86/cpu] x86/smp: Drop " tip-bot2 for Arnd Bergmann
2025-02-26 21:37 ` Arnd Bergmann [this message]
2025-02-27 10:42 ` [tip: x86/cpu] x86/build: Rework CONFIG_GENERIC_CPU compiler flags tip-bot2 for Arnd Bergmann
2025-02-26 21:37 ` [PATCH v3 04/10] x86: drop configuration options for early 64-bit CPUs Arnd Bergmann
2025-02-27 10:42 ` [tip: x86/cpu] x86/cpu: Drop " tip-bot2 for Arnd Bergmann
2025-02-26 21:37 ` [PATCH v3 05/10] x86: remove HIGHMEM64G support Arnd Bergmann
2025-02-27 10:42 ` [tip: x86/cpu] x86/mm: Remove CONFIG_HIGHMEM64G support tip-bot2 for Arnd Bergmann
2025-02-27 15:41 ` [PATCH v3 05/10] x86: remove HIGHMEM64G support H. Peter Anvin
2025-02-27 16:51 ` Linus Torvalds
2025-02-28 1:48 ` H. Peter Anvin
2025-02-28 10:09 ` Arnd Bergmann
2025-02-26 21:37 ` [PATCH v3 06/10] x86: drop SWIOTLB for PAE Arnd Bergmann
2025-02-27 10:42 ` [tip: x86/cpu] x86/mm: Drop CONFIG_SWIOTLB " tip-bot2 for Arnd Bergmann
2025-02-26 21:37 ` [PATCH v3 07/10] x86: drop support for CONFIG_HIGHPTE Arnd Bergmann
2025-02-27 10:42 ` [tip: x86/cpu] x86/mm: Drop " tip-bot2 for Arnd Bergmann
2025-02-26 21:37 ` [PATCH v3 08/10] x86: document X86_INTEL_MID as 64-bit-only Arnd Bergmann
2025-02-27 10:42 ` [tip: x86/cpu] x86/cpu: Document CONFIG_X86_INTEL_MID " tip-bot2 for Arnd Bergmann
2025-02-28 16:20 ` [PATCH v3 08/10] x86: document X86_INTEL_MID " Ferry Toth
2025-02-28 18:40 ` Andy Shevchenko
2025-02-26 21:37 ` [PATCH v3 09/10] x86: remove old STA2x11 support Arnd Bergmann
2025-02-27 10:42 ` [tip: x86/cpu] x86/pci: Remove " tip-bot2 for Arnd Bergmann
2025-02-26 21:37 ` [PATCH v3 10/10] x86: only allow EISA for 32-bit Arnd Bergmann
2025-02-27 10:42 ` [tip: x86/cpu] x86/platform: Only allow CONFIG_EISA " tip-bot2 for Arnd Bergmann
2025-02-27 10:34 ` [PATCH v3 00/10] x86: 32-bit cleanups Ingo Molnar
2025-02-27 14:08 ` Andy Shevchenko
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=20250226213714.4040853-4-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=andy@kernel.org \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=willy@infradead.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