llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] x86: Clean ups after minimum support compiler version bump
@ 2025-08-15  1:31 Nathan Chancellor
  2025-08-15  1:31 ` [PATCH 1/6] x86/build: Remove cc-option for GCC retpoline flags Nathan Chancellor
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-08-15  1:31 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: linux-kernel, llvm, patches, Nathan Chancellor

Hi x86 folks,

Here is a small series of clean ups that I noticed after PeterZ made a
comment about '-mskip-rax-setup' being supported with all compiler
versions that x86 requires to build (GCC 8.1+ and LLVM 15+). This has
seen a build with GCC 8, GCC 15, LLVM 15, and LLVM 21.

---
Nathan Chancellor (6):
      x86/build: Remove cc-option for GCC retpoline flags
      x86/build: Remove cc-option from stack alignment flags
      x86/build: Clean up stack alignment flags in CC_FLAGS_FPU
      x86/build: Remove cc-option from -mno-fp-ret-in-387
      x86/build: Remove cc-option from -mskip-rax-setup
      x86/Kconfig: Clean up LLVM version checks in IBT configurations

 arch/x86/Kconfig  |  8 +-------
 arch/x86/Makefile | 25 +++++++------------------
 2 files changed, 8 insertions(+), 25 deletions(-)
---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250814-x86-min-ver-cleanups-bfb7a54f1c29

Best regards,
--  
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6] x86/build: Remove cc-option for GCC retpoline flags
  2025-08-15  1:31 [PATCH 0/6] x86: Clean ups after minimum support compiler version bump Nathan Chancellor
@ 2025-08-15  1:31 ` Nathan Chancellor
  2025-08-15  1:31 ` [PATCH 2/6] x86/build: Remove cc-option from stack alignment flags Nathan Chancellor
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-08-15  1:31 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: linux-kernel, llvm, patches, Nathan Chancellor

The minimum supported version of GCC to build the x86 kernel was bumped
to GCC 8.1 in commit a3e8fe814ad1 ("x86/build: Raise the minimum GCC
version to 8.1"). '-mindirect-branch' and '-mindirect-branch-register'
were first supported in GCC 8.1, so there is no need to call cc-option
to inquire if it is supported.

Link: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=da99fd4a3ca06b43b08ba8d96dab84e83ac90aa7
Link: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d543c04b795f8af4ebe5b3d5f38156ef4e5734f1
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/x86/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1913d342969b..ed5657395d6a 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -13,8 +13,8 @@ else
 endif
 
 ifdef CONFIG_CC_IS_GCC
-RETPOLINE_CFLAGS	:= $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register)
-RETPOLINE_VDSO_CFLAGS	:= $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register)
+RETPOLINE_CFLAGS	:= -mindirect-branch=thunk-extern -mindirect-branch-register
+RETPOLINE_VDSO_CFLAGS	:= -mindirect-branch=thunk-inline -mindirect-branch-register
 endif
 ifdef CONFIG_CC_IS_CLANG
 RETPOLINE_CFLAGS	:= -mretpoline-external-thunk

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/6] x86/build: Remove cc-option from stack alignment flags
  2025-08-15  1:31 [PATCH 0/6] x86: Clean ups after minimum support compiler version bump Nathan Chancellor
  2025-08-15  1:31 ` [PATCH 1/6] x86/build: Remove cc-option for GCC retpoline flags Nathan Chancellor
@ 2025-08-15  1:31 ` Nathan Chancellor
  2025-08-15  1:31 ` [PATCH 3/6] x86/build: Clean up stack alignment flags in CC_FLAGS_FPU Nathan Chancellor
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-08-15  1:31 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: linux-kernel, llvm, patches, Nathan Chancellor

'-mpreferred-stack-boundary' (the GCC option) and '-mstack-alignment'
(the clang option) have been supported in their respective compilers for
some time, so it is unnecessary to check for support for them via
cc-option. '-mpreferred-stack-boundary=3' had a restriction on
'-mno-sse' until GCC 7.1 but that is irrelevant for most of the kernel,
which includes '-mno-sse'.

Move to simple Kconfig checks to avoid querying the compiler for the
flags that it supports.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/x86/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index ed5657395d6a..f0aa58d2ec17 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -37,10 +37,11 @@ export RETPOLINE_VDSO_CFLAGS
 
 # For gcc stack alignment is specified with -mpreferred-stack-boundary,
 # clang has the option -mstack-alignment for that purpose.
-ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
+ifdef CONFIG_CC_IS_GCC
       cc_stack_align4 := -mpreferred-stack-boundary=2
       cc_stack_align8 := -mpreferred-stack-boundary=3
-else ifneq ($(call cc-option, -mstack-alignment=16),)
+endif
+ifdef CONFIG_CC_IS_CLANG
       cc_stack_align4 := -mstack-alignment=4
       cc_stack_align8 := -mstack-alignment=8
 endif

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/6] x86/build: Clean up stack alignment flags in CC_FLAGS_FPU
  2025-08-15  1:31 [PATCH 0/6] x86: Clean ups after minimum support compiler version bump Nathan Chancellor
  2025-08-15  1:31 ` [PATCH 1/6] x86/build: Remove cc-option for GCC retpoline flags Nathan Chancellor
  2025-08-15  1:31 ` [PATCH 2/6] x86/build: Remove cc-option from stack alignment flags Nathan Chancellor
@ 2025-08-15  1:31 ` Nathan Chancellor
  2025-08-15  1:31 ` [PATCH 4/6] x86/build: Remove cc-option from -mno-fp-ret-in-387 Nathan Chancellor
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-08-15  1:31 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: linux-kernel, llvm, patches, Nathan Chancellor

The minimum supported version of GCC to build the x86 kernel was bumped
to GCC 8.1 in commit a3e8fe814ad1 ("x86/build: Raise the minimum GCC
version to 8.1").

Prior to GCC 7.1, '-mpreferred-stack-boundary=3' was not allowed with
'-msse', so areas of the kernel that needed floating point had a
different alignment. Now that GCC > 7.1 is mandatory, there is no need
to have a different value of '-mpreferred-stack-boundary' from the rest
of the kernel, so remove this handling from CC_FLAGS_FPU.

Link: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=34fac449e121be97dd073c5428cc855367b2872c
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/x86/Makefile | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index f0aa58d2ec17..0c82a610fb54 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -84,19 +84,7 @@ KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-av
 #
 CC_FLAGS_FPU := -msse -msse2
 ifdef CONFIG_CC_IS_GCC
-# Stack alignment mismatch, proceed with caution.
-# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
-# (8B stack alignment).
-# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383
-#
-# The "-msse" in the first argument is there so that the
-# -mpreferred-stack-boundary=3 build error:
-#
-#  -mpreferred-stack-boundary=3 is not between 4 and 12
-#
-# can be triggered. Otherwise gcc doesn't complain.
 CC_FLAGS_FPU += -mhard-float
-CC_FLAGS_FPU += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4)
 endif
 
 ifeq ($(CONFIG_X86_KERNEL_IBT),y)

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/6] x86/build: Remove cc-option from -mno-fp-ret-in-387
  2025-08-15  1:31 [PATCH 0/6] x86: Clean ups after minimum support compiler version bump Nathan Chancellor
                   ` (2 preceding siblings ...)
  2025-08-15  1:31 ` [PATCH 3/6] x86/build: Clean up stack alignment flags in CC_FLAGS_FPU Nathan Chancellor
@ 2025-08-15  1:31 ` Nathan Chancellor
  2025-08-15  1:31 ` [PATCH 5/6] x86/build: Remove cc-option from -mskip-rax-setup Nathan Chancellor
  2025-08-15  1:31 ` [PATCH 6/6] x86/Kconfig: Clean up LLVM version checks in IBT configurations Nathan Chancellor
  5 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-08-15  1:31 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: linux-kernel, llvm, patches, Nathan Chancellor

This has been supported in GCC for forever and clang gained support for
it as an alias of '-mno-x87' in LLVM 14. Now that x86 requires LLVM 15
or newer since commit 7861640aac52 ("x86/build: Raise the minimum LLVM
version to 15.0.0"), this flag can be unconditionally added, saving a
compiler invocation.

Link: https://github.com/llvm/llvm-project/commit/a9fba2be35db674971382e38b99a31403444d9bf
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 0c82a610fb54..1bbf943fe9e1 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -148,7 +148,7 @@ else
 
         # Don't autogenerate traditional x87 instructions
         KBUILD_CFLAGS += -mno-80387
-        KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
+        KBUILD_CFLAGS += -mno-fp-ret-in-387
 
         # By default gcc and clang use a stack alignment of 16 bytes for x86.
         # However the standard kernel entry on x86-64 leaves the stack on an

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/6] x86/build: Remove cc-option from -mskip-rax-setup
  2025-08-15  1:31 [PATCH 0/6] x86: Clean ups after minimum support compiler version bump Nathan Chancellor
                   ` (3 preceding siblings ...)
  2025-08-15  1:31 ` [PATCH 4/6] x86/build: Remove cc-option from -mno-fp-ret-in-387 Nathan Chancellor
@ 2025-08-15  1:31 ` Nathan Chancellor
  2025-08-15  1:31 ` [PATCH 6/6] x86/Kconfig: Clean up LLVM version checks in IBT configurations Nathan Chancellor
  5 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-08-15  1:31 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: linux-kernel, llvm, patches, Nathan Chancellor

This has been supported in GCC since 5.1 and clang since 14.0. Now that
x86 requires LLVM 15 or newer since commit 7861640aac52 ("x86/build:
Raise the minimum LLVM version to 15.0.0"), this flag can be
unconditionally added, saving a compiler invocation.

Link: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=fbe575b652f5bdcc459f447a0e6f0e059996d4ef
Link: https://github.com/llvm/llvm-project/commit/a9fba2be35db674971382e38b99a31403444d9bf
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/x86/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1bbf943fe9e1..4b4e2a3ac6df 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -160,7 +160,7 @@ else
         KBUILD_CFLAGS += $(cc_stack_align8)
 
 	# Use -mskip-rax-setup if supported.
-	KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
+	KBUILD_CFLAGS += -mskip-rax-setup
 
 ifdef CONFIG_X86_NATIVE_CPU
         KBUILD_CFLAGS += -march=native

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6/6] x86/Kconfig: Clean up LLVM version checks in IBT configurations
  2025-08-15  1:31 [PATCH 0/6] x86: Clean ups after minimum support compiler version bump Nathan Chancellor
                   ` (4 preceding siblings ...)
  2025-08-15  1:31 ` [PATCH 5/6] x86/build: Remove cc-option from -mskip-rax-setup Nathan Chancellor
@ 2025-08-15  1:31 ` Nathan Chancellor
  5 siblings, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-08-15  1:31 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: linux-kernel, llvm, patches, Nathan Chancellor

The minimum supported version of LLVM for building the x86 kernel
was bumped to 15.0.0 in commit 7861640aac52 ("x86/build: Raise the
minimum LLVM version to 15.0.0"), so the checks for Clang 14.0.0 and
ld.lld 14.0.0 or newer will always been true. Clean them up.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/x86/Kconfig | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 58d890fe2100..85b91267c01c 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1753,11 +1753,7 @@ config X86_UMIP
 config CC_HAS_IBT
 	# GCC >= 9 and binutils >= 2.29
 	# Retpoline check to work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93654
-	# Clang/LLVM >= 14
-	# https://github.com/llvm/llvm-project/commit/e0b89df2e0f0130881bf6c39bf31d7f6aac00e0f
-	# https://github.com/llvm/llvm-project/commit/dfcf69770bc522b9e411c66454934a37c1f35332
-	def_bool ((CC_IS_GCC && $(cc-option, -fcf-protection=branch -mindirect-branch-register)) || \
-		  (CC_IS_CLANG && CLANG_VERSION >= 140000)) && \
+	def_bool ((CC_IS_GCC && $(cc-option, -fcf-protection=branch -mindirect-branch-register)) || CC_IS_CLANG) && \
 		  $(as-instr,endbr64)
 
 config X86_CET
@@ -1769,8 +1765,6 @@ config X86_KERNEL_IBT
 	prompt "Indirect Branch Tracking"
 	def_bool y
 	depends on X86_64 && CC_HAS_IBT && HAVE_OBJTOOL
-	# https://github.com/llvm/llvm-project/commit/9d7001eba9c4cb311e03cd8cdc231f9e579f2d0f
-	depends on !LD_IS_LLD || LLD_VERSION >= 140000
 	select OBJTOOL
 	select X86_CET
 	help

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-08-15  1:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-15  1:31 [PATCH 0/6] x86: Clean ups after minimum support compiler version bump Nathan Chancellor
2025-08-15  1:31 ` [PATCH 1/6] x86/build: Remove cc-option for GCC retpoline flags Nathan Chancellor
2025-08-15  1:31 ` [PATCH 2/6] x86/build: Remove cc-option from stack alignment flags Nathan Chancellor
2025-08-15  1:31 ` [PATCH 3/6] x86/build: Clean up stack alignment flags in CC_FLAGS_FPU Nathan Chancellor
2025-08-15  1:31 ` [PATCH 4/6] x86/build: Remove cc-option from -mno-fp-ret-in-387 Nathan Chancellor
2025-08-15  1:31 ` [PATCH 5/6] x86/build: Remove cc-option from -mskip-rax-setup Nathan Chancellor
2025-08-15  1:31 ` [PATCH 6/6] x86/Kconfig: Clean up LLVM version checks in IBT configurations Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).