From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "Linus Torvalds" <torvalds@linux-foundation.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nsc@kernel.org>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"Bill Wendling" <morbo@google.com>,
"Justin Stitt" <justinstitt@google.com>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Alexey Gladkov" <legion@kernel.org>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Arnd Bergmann" <arnd@arndb.de>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Will Deacon" <will@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Josh Poimboeuf" <jpoimboe@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Jonathan Corbet" <corbet@lwn.net>,
"Randy Dunlap" <rdunlap@infradead.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, linux-riscv@lists.infradead.org,
linux-arch@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org,
rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org,
Jens Axboe <axboe@kernel.dk>,
"Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Subject: [PATCH 12/23] kbuild: avoid re-running compiler and linker probes
Date: Tue, 08 Sep 2026 21:55:12 +0100 [thread overview]
Message-ID: <20260908-build-speedup-v1-12-5dc1ac01672d@kernel.org> (raw)
In-Reply-To: <20260908-build-speedup-v1-0-5dc1ac01672d@kernel.org>
Each kernel make invocation begins with ~30 compiler and linker runs each
of which performs duplicate probe for a number of compiler and linker
options.
This is useless work - the compiler and its version is known, so use these
to determine which options are available, once.
A convention already exists for this - CC_HAS_xxx, LD_HAS_xxx in Kconfig
files (for example, CC_HAS_COUNTED_BY), so convert these probes to Kconfig
options where appropriate.
With gcc and clang, defconfig and allmodconfig, the recorded command
lines are unchanged, a build with nothing to do rebuilds nothing and W=1
continues to function correctly.
Doing this improves all builds, but has a particularly positive impact on
no-op builds (builds where nothing has changed).
Whole build, 128-thread Threadripper 9980X, best of N runs:
before after delta
-------------------------------
x86 defconfig, no-op make, gcc 0.62s 0.46s -0.17s (-27%)
x86 defconfig, no-op make, clang 0.78s 0.53s -0.25s (-32%)
x86 defconfig, touch mm/vma.c, gcc 8.7s 8.5s -0.17s (-2%)
x86 defconfig, touch mm/vma.c, clang 7.9s 7.6s -0.25s (-3%)
x86 defconfig, clean, clang 27.0s 26.8s -0.26s (-1%)
x86 allmodconfig, no-op make, gcc 11.2s 11.0s -0.18s (-2%)
x86 allmodconfig, no-op make, clang 11.9s 11.6s -0.28s (-2%)
x86 allmodconfig, touch mm/vma.c, clang 36.5s 36.2s -0.31s (-1%)
Assisted-by: LLM
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
Makefile | 23 +++++------
arch/arm64/kernel/pi/Makefile | 2 +-
arch/riscv/kernel/pi/Makefile | 2 +-
arch/x86/Kconfig | 17 ++++++++
arch/x86/Makefile | 12 +++---
drivers/firmware/efi/libstub/Makefile | 2 +-
init/Kconfig | 77 +++++++++++++++++++++++++++++++++++
scripts/Makefile.warn | 28 ++++++-------
8 files changed, 128 insertions(+), 35 deletions(-)
diff --git a/Makefile b/Makefile
index 56e56bea53c3..088e901f0a72 100644
--- a/Makefile
+++ b/Makefile
@@ -946,8 +946,8 @@ KBUILD_RUSTFLAGS += -Coverflow-checks=$(if $(CONFIG_RUST_OVERFLOW_CHECKS),y,n)
ifdef CONFIG_CC_IS_GCC
# gcc-10 renamed --param=allow-store-data-races=0 to
# -fno-allow-store-data-races.
-KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
-KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_ALLOW_STORE_DATA_RACES_PARAM),--param=allow-store-data-races=0)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_NO_ALLOW_STORE_DATA_RACES),-fno-allow-store-data-races)
endif
ifdef CONFIG_READABLE_ASM
@@ -1011,18 +1011,18 @@ endif
endif
# Explicitly clear padding bits during variable initialization
-KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_ZERO_INIT_PADDING_BITS),-fzero-init-padding-bits=all)
# While VLAs have been removed, GCC produces unreachable stack probes
# for the randomize_kstack_offset feature. Disable it for all compilers.
-KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_NO_STACK_CLASH_PROTECTION),-fno-stack-clash-protection)
# Get details on warnings generated due to GCC value tracking.
-KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-context=2)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_DIAGNOSTICS_SHOW_CONTEXT),-fdiagnostics-show-context=2)
# Show inlining notes for __attribute__((warning/error)) call chains.
# GCC supports this unconditionally while Clang 23+ provides a flag.
-KBUILD_CFLAGS += $(call cc-option, -fdiagnostics-show-inlining-chain)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_DIAGNOSTICS_SHOW_INLINING_CHAIN),-fdiagnostics-show-inlining-chain)
# Clear used registers at func exit (to reduce data lifetime and ROP gadgets).
ifdef CONFIG_ZERO_CALL_USED_REGS
@@ -1033,7 +1033,7 @@ ifdef CONFIG_FUNCTION_TRACER
ifdef CONFIG_FTRACE_MCOUNT_USE_CC
CC_FLAGS_FTRACE += -mrecord-mcount
ifdef CONFIG_HAVE_NOP_MCOUNT
- ifeq ($(call cc-option-yn, -mnop-mcount),y)
+ ifdef CONFIG_CC_HAS_MNOP_MCOUNT
CC_FLAGS_FTRACE += -mnop-mcount
CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
endif
@@ -1051,8 +1051,7 @@ ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
endif
endif
ifdef CONFIG_HAVE_FENTRY
- # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
- ifeq ($(call cc-option-yn, -mfentry),y)
+ ifdef CONFIG_CC_HAS_MFENTRY
CC_FLAGS_FTRACE += -mfentry
CC_FLAGS_USING += -DCC_USING_FENTRY
endif
@@ -1160,7 +1159,7 @@ NOSTDINC_FLAGS += -nostdinc
# the kernel uses only C99 flexible arrays for dynamically sized trailing
# arrays. Enforce this for everything that may examine structure sizes and
# perform bounds checking.
-KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_STRICT_FLEX_ARRAYS),-fstrict-flex-arrays=3)
# disable invalid "can't wrap" optimizations for signed / pointers
KBUILD_CFLAGS += -fno-strict-overflow
@@ -1240,11 +1239,11 @@ LDFLAGS_vmlinux += --build-id=sha1
# COMDAT-deduplicated sections. Use --force-group-allocation to resolve these
# groups when linking modules. The option is available from ld.bfd 2.29 and
# ld.lld 19.1.0.
-KBUILD_LDFLAGS_MODULE += $(call ld-option,--force-group-allocation)
+KBUILD_LDFLAGS_MODULE += $(if $(CONFIG_LD_HAS_FORCE_GROUP_ALLOCATION),--force-group-allocation)
KBUILD_LDFLAGS += -z noexecstack
ifeq ($(CONFIG_LD_IS_BFD),y)
-KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
+KBUILD_LDFLAGS += $(if $(CONFIG_LD_HAS_NO_WARN_RWX_SEGMENTS),--no-warn-rwx-segments)
endif
ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
diff --git a/arch/arm64/kernel/pi/Makefile b/arch/arm64/kernel/pi/Makefile
index be92d73c25b2..5aa8dffe492b 100644
--- a/arch/arm64/kernel/pi/Makefile
+++ b/arch/arm64/kernel/pi/Makefile
@@ -9,7 +9,7 @@ KBUILD_CFLAGS := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) -fpie \
-include $(srctree)/include/linux/hidden.h \
-D__DISABLE_EXPORTS -ffreestanding -D__NO_FORTIFY \
-fno-asynchronous-unwind-tables -fno-unwind-tables \
- $(call cc-option,-fno-addrsig)
+ $(if $(CONFIG_CC_HAS_NO_ADDRSIG),-fno-addrsig)
# this code may run with the MMU off so disable unaligned accesses
CFLAGS_map_range.o += -mstrict-align
diff --git a/arch/riscv/kernel/pi/Makefile b/arch/riscv/kernel/pi/Makefile
index bc098edac898..e0ed7ca7e347 100644
--- a/arch/riscv/kernel/pi/Makefile
+++ b/arch/riscv/kernel/pi/Makefile
@@ -8,7 +8,7 @@ KBUILD_CFLAGS := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) -fpie \
-include $(srctree)/include/linux/hidden.h \
-D__DISABLE_EXPORTS -ffreestanding \
-fno-asynchronous-unwind-tables -fno-unwind-tables \
- $(call cc-option,-fno-addrsig)
+ $(if $(CONFIG_CC_HAS_NO_ADDRSIG),-fno-addrsig)
# Disable LTO
KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 15fd9ec5ecac..be0624fee27a 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2364,6 +2364,23 @@ config CC_HAS_KCFI_ARITY
def_bool $(cc-option,-fsanitize=kcfi -fsanitize-kcfi-arity)
depends on CC_IS_CLANG && !RUST
+config CC_HAS_INDIRECT_BRANCH_CS_PREFIX
+ def_bool $(cc-option,-mindirect-branch-cs-prefix)
+
+config CC_HAS_CF_PROTECTION_NONE
+ def_bool $(cc-option,-fcf-protection=none)
+
+# with jump tables off: the compilers use NOTRACK for them, which kernel IBT
+# does not allow
+config CC_HAS_CF_PROTECTION_BRANCH
+ def_bool $(cc-option,-fcf-protection=branch -fno-jump-tables)
+
+config CC_HAS_FALIGN_JUMPS
+ def_bool $(cc-option,-falign-jumps=1)
+
+config CC_HAS_FALIGN_LOOPS
+ def_bool $(cc-option,-falign-loops=1)
+
config FUNCTION_PADDING_CFI
int
default 59 if FUNCTION_ALIGNMENT_64B
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 598f178102ee..29bb515df9f6 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -20,7 +20,7 @@ ifdef CONFIG_CC_IS_CLANG
RETPOLINE_CFLAGS := -mretpoline-external-thunk
RETPOLINE_VDSO_CFLAGS := -mretpoline
endif
-RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix)
+RETPOLINE_CFLAGS += $(if $(CONFIG_CC_HAS_INDIRECT_BRANCH_CS_PREFIX),-mindirect-branch-cs-prefix)
ifdef CONFIG_MITIGATION_RETHUNK
RETHUNK_CFLAGS := -mfunction-return=thunk-extern
@@ -52,7 +52,7 @@ REALMODE_CFLAGS := $(CC_FLAGS_DIALECT) -m16 -g -Os \
-DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS \
-Wall -Wstrict-prototypes -march=i386 -mregparm=3 \
-fno-strict-aliasing -fomit-frame-pointer -fno-pic \
- -mno-mmx -mno-sse $(call cc-option,-fcf-protection=none)
+ -mno-mmx -mno-sse $(if $(CONFIG_CC_HAS_CF_PROTECTION_NONE),-fcf-protection=none)
REALMODE_CFLAGS += -ffreestanding
REALMODE_CFLAGS += -fno-stack-protector
@@ -99,10 +99,10 @@ ifeq ($(CONFIG_X86_KERNEL_IBT),y)
#
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104816
#
-KBUILD_CFLAGS += $(call cc-option,-fcf-protection=branch -fno-jump-tables)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_CF_PROTECTION_BRANCH),-fcf-protection=branch -fno-jump-tables)
KBUILD_RUSTFLAGS += -Zcf-protection=branch $(if $(call rustc-min-version,109300),-Cjump-tables=n,-Zno-jump-tables)
else
-KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_CF_PROTECTION_NONE),-fcf-protection=none)
endif
ifeq ($(CONFIG_X86_32),y)
@@ -138,10 +138,10 @@ else
KBUILD_CFLAGS += -m64
# Align jump targets to 1 byte, not the default 16 bytes:
- KBUILD_CFLAGS += $(call cc-option,-falign-jumps=1)
+ KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_FALIGN_JUMPS),-falign-jumps=1)
# Pack loops tightly as well:
- KBUILD_CFLAGS += $(call cc-option,-falign-loops=1)
+ KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_FALIGN_LOOPS),-falign-loops=1)
# Don't autogenerate traditional x87 instructions
KBUILD_CFLAGS += -mno-80387
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 77a2b2d74f3f..80058bbddaf5 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -40,7 +40,7 @@ KBUILD_CFLAGS := $(subst $(CC_FLAGS_FTRACE),,$(cflags-y)) \
-D__NO_FORTIFY \
-ffreestanding \
-fno-stack-protector \
- $(call cc-option,-fno-addrsig) \
+ $(if $(CONFIG_CC_HAS_NO_ADDRSIG),-fno-addrsig) \
-D__DISABLE_EXPORTS
#
diff --git a/init/Kconfig b/init/Kconfig
index 8583d9f06c52..3c92c87254a3 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -144,6 +144,44 @@ config CC_HAS_ASSUME
config CC_HAS_NO_PROFILE_FN_ATTR
def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
+config CC_HAS_ZERO_INIT_PADDING_BITS
+ def_bool $(cc-option,-fzero-init-padding-bits=all)
+
+config CC_HAS_NO_STACK_CLASH_PROTECTION
+ def_bool $(cc-option,-fno-stack-clash-protection)
+
+config CC_HAS_NO_ADDRSIG
+ def_bool $(cc-option,-fno-addrsig)
+
+config CC_HAS_DIAGNOSTICS_SHOW_CONTEXT
+ def_bool $(cc-option,-fdiagnostics-show-context=2)
+
+config CC_HAS_DIAGNOSTICS_SHOW_INLINING_CHAIN
+ def_bool $(cc-option,-fdiagnostics-show-inlining-chain)
+
+config CC_HAS_STRICT_FLEX_ARRAYS
+ def_bool $(cc-option,-fstrict-flex-arrays=3)
+
+# gcc-10 renamed --param=allow-store-data-races=0 to -fno-allow-store-data-races
+config CC_HAS_ALLOW_STORE_DATA_RACES_PARAM
+ def_bool CC_IS_GCC && $(cc-option,--param=allow-store-data-races=0)
+
+config CC_HAS_NO_ALLOW_STORE_DATA_RACES
+ def_bool CC_IS_GCC && $(cc-option,-fno-allow-store-data-races)
+
+config CC_HAS_MNOP_MCOUNT
+ def_bool $(cc-option,-mnop-mcount)
+
+# s390-linux-gnu-gcc did not support -mfentry until gcc-9.
+config CC_HAS_MFENTRY
+ def_bool $(cc-option,-mfentry)
+
+config LD_HAS_FORCE_GROUP_ALLOCATION
+ def_bool $(ld-option,--force-group-allocation)
+
+config LD_HAS_NO_WARN_RWX_SEGMENTS
+ def_bool $(ld-option,--no-warn-rwx-segments)
+
config CC_HAS_COUNTED_BY
bool
# clang needs to be at least 20.1.0 to avoid potential crashes
@@ -1006,6 +1044,45 @@ config CC_STRINGOP_OVERFLOW
bool
default y if CC_IS_GCC && !CC_NO_STRINGOP_OVERFLOW
+config CC_HAS_WNO_ADDRESS_OF_PACKED_MEMBER
+ def_bool $(cc-option,-Wno-address-of-packed-member)
+
+config CC_HAS_WNO_FORMAT_OVERFLOW_NON_KPRINTF
+ def_bool CC_IS_CLANG && $(cc-option,-Wno-format-overflow-non-kprintf)
+
+config CC_HAS_WNO_FORMAT_TRUNCATION_NON_KPRINTF
+ def_bool CC_IS_CLANG && $(cc-option,-Wno-format-truncation-non-kprintf)
+
+config CC_HAS_WNO_DEFAULT_CONST_INIT_UNSAFE
+ def_bool CC_IS_CLANG && $(cc-option,-Wno-default-const-init-unsafe)
+
+config CC_HAS_WNO_DANGLING_POINTER
+ def_bool $(cc-option,-Wno-dangling-pointer)
+
+config CC_HAS_WVLA_LARGER_THAN
+ def_bool $(cc-option,-Wvla-larger-than=1)
+
+config CC_HAS_WSTRINGOP_OVERFLOW
+ def_bool $(cc-option,-Wstringop-overflow)
+
+config CC_HAS_WNO_UNTERMINATED_STRING_INITIALIZATION
+ def_bool $(cc-option,-Wno-unterminated-string-initialization)
+
+config CC_HAS_WERROR_DESIGNATED_INIT
+ def_bool $(cc-option,-Werror=designated-init)
+
+config CC_HAS_WENUM_CONVERSION
+ def_bool $(cc-option,-Wenum-conversion)
+
+config CC_HAS_WNO_PACKED_NOT_ALIGNED
+ def_bool $(cc-option,-Wno-packed-not-aligned)
+
+config CC_HAS_WNO_FORMAT_OVERFLOW
+ def_bool $(cc-option,-Wno-format-overflow)
+
+config CC_HAS_WNO_STRINGOP_TRUNCATION
+ def_bool $(cc-option,-Wno-stringop-truncation)
+
#
# For architectures that know their GCC __int128 support is sound
#
diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn
index 35af7d6c6d18..83d274fcbfaf 100644
--- a/scripts/Makefile.warn
+++ b/scripts/Makefile.warn
@@ -17,7 +17,7 @@ KBUILD_CFLAGS += -Werror=strict-prototypes
KBUILD_CFLAGS += -Wno-format-security
KBUILD_CFLAGS += -Wno-trigraphs
KBUILD_CFLAGS += -Wno-frame-address
-KBUILD_CFLAGS += $(call cc-option, -Wno-address-of-packed-member)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WNO_ADDRESS_OF_PACKED_MEMBER),-Wno-address-of-packed-member)
KBUILD_CFLAGS += -Wmissing-declarations
KBUILD_CFLAGS += -Wmissing-prototypes
@@ -30,8 +30,8 @@ KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
ifdef CONFIG_CC_IS_CLANG
# Clang checks for overflow/truncation with '%p', while GCC does not:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219
-KBUILD_CFLAGS += $(call cc-option, -Wno-format-overflow-non-kprintf)
-KBUILD_CFLAGS += $(call cc-option, -Wno-format-truncation-non-kprintf)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WNO_FORMAT_OVERFLOW_NON_KPRINTF),-Wno-format-overflow-non-kprintf)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WNO_FORMAT_TRUNCATION_NON_KPRINTF),-Wno-format-truncation-non-kprintf)
# Clang may emit a warning when a const variable, such as the dummy variables
# in typecheck(), or const member of an aggregate type are not initialized,
@@ -43,7 +43,7 @@ KBUILD_CFLAGS += $(call cc-option, -Wno-format-truncation-non-kprintf)
# disabled with this same switch, there should not be too much coverage lost
# because -Wuninitialized will still flag when an uninitialized const variable
# is used.
-KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WNO_DEFAULT_CONST_INIT_UNSAFE),-Wno-default-const-init-unsafe)
else
# gcc inanely warns about local variables called 'main'
@@ -54,7 +54,7 @@ endif
KBUILD_CFLAGS += -Wno-type-limits
# These result in bogus false positives
-KBUILD_CFLAGS += $(call cc-option, -Wno-dangling-pointer)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WNO_DANGLING_POINTER),-Wno-dangling-pointer)
# Stack Variable Length Arrays (VLAs) must not be used in the kernel.
# Function array parameters should, however, be usable, but -Wvla will
@@ -62,7 +62,7 @@ KBUILD_CFLAGS += $(call cc-option, -Wno-dangling-pointer)
# types, so depend on GCC for now to keep stack VLAs out of the tree.
# https://github.com/llvm/llvm-project/issues/57098
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98217
-KBUILD_CFLAGS += $(call cc-option,-Wvla-larger-than=1)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WVLA_LARGER_THAN),-Wvla-larger-than=1)
# disable pointer signed / unsigned warnings in gcc 4.0
KBUILD_CFLAGS += -Wno-pointer-sign
@@ -73,11 +73,11 @@ KBUILD_CFLAGS += -Wno-pointer-sign
KBUILD_CFLAGS += -Wcast-function-type
# Currently, disable -Wstringop-overflow for GCC 11, globally.
-KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow)
-KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow)
+KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(if $(CONFIG_CC_HAS_WSTRINGOP_OVERFLOW),-Wno-stringop-overflow)
+KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(if $(CONFIG_CC_HAS_WSTRINGOP_OVERFLOW),-Wstringop-overflow)
# Currently, disable -Wunterminated-string-initialization as broken
-KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WNO_UNTERMINATED_STRING_INITIALIZATION),-Wno-unterminated-string-initialization)
# The allocators already balk at large sizes, so silence the compiler
# warnings for bounds checks involving those possible values. While
@@ -100,10 +100,10 @@ KBUILD_CFLAGS += -Werror=date-time
KBUILD_CFLAGS += -Werror=incompatible-pointer-types
# Require designated initializers for all marked structures
-KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WERROR_DESIGNATED_INIT),-Werror=designated-init)
# Warn if there is an enum types mismatch
-KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WENUM_CONVERSION),-Wenum-conversion)
KBUILD_CFLAGS += -Wunused
@@ -125,12 +125,12 @@ else
# Suppress them by using -Wno... except for W=1.
KBUILD_CFLAGS += -Wno-unused-but-set-variable
KBUILD_CFLAGS += -Wno-unused-const-variable
-KBUILD_CFLAGS += $(call cc-option, -Wno-packed-not-aligned)
-KBUILD_CFLAGS += $(call cc-option, -Wno-format-overflow)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WNO_PACKED_NOT_ALIGNED),-Wno-packed-not-aligned)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WNO_FORMAT_OVERFLOW),-Wno-format-overflow)
ifdef CONFIG_CC_IS_GCC
KBUILD_CFLAGS += -Wno-format-truncation
endif
-KBUILD_CFLAGS += $(call cc-option, -Wno-stringop-truncation)
+KBUILD_CFLAGS += $(if $(CONFIG_CC_HAS_WNO_STRINGOP_TRUNCATION),-Wno-stringop-truncation)
KBUILD_CFLAGS += -Wno-override-init # alias for -Wno-initializer-overrides in clang
--
2.55.0
next prev parent reply other threads:[~2026-09-08 20:57 UTC|newest]
Thread overview: 91+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 20:55 [PATCH 00/23] kbuild: significantly speed up kernel builds Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 01/23] scripts/mksysmap: drop the MODULE_INFO() symbols from kallsyms Lorenzo Stoakes (ARM)
2026-09-09 19:47 ` Nicolas Schier
2026-09-10 11:00 ` Lorenzo Stoakes (ARM)
2026-09-10 4:19 ` Nathan Chancellor
2026-09-10 11:03 ` Lorenzo Stoakes (ARM)
2026-09-10 19:00 ` Nicolas Schier
2026-09-08 20:55 ` [PATCH 02/23] scripts/mksysmap: fix escape of '$' in the __pi_ pattern Lorenzo Stoakes (ARM)
2026-09-09 19:47 ` Nicolas Schier
2026-09-10 11:04 ` Lorenzo Stoakes (ARM)
2026-09-10 4:19 ` Nathan Chancellor
2026-09-10 11:21 ` Lorenzo Stoakes (ARM)
2026-09-10 19:00 ` Nicolas Schier
2026-09-08 20:55 ` [PATCH 03/23] kallsyms: index symbols by token to speed up table compression Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 04/23] kallsyms: output binary data to speed output and kallsyms assembly Lorenzo Stoakes (ARM)
2026-09-09 14:35 ` Linus Torvalds
2026-09-10 9:29 ` David Laight
2026-09-11 11:07 ` Lorenzo Stoakes (ARM)
2026-09-12 6:38 ` [4/23] " Markus Elfring
2026-09-08 20:55 ` [PATCH 05/23] kbuild: do not sort nm output where the order is irrelevant Lorenzo Stoakes (ARM)
2026-09-10 4:19 ` Nathan Chancellor
2026-09-08 20:55 ` [PATCH 06/23] kbuild: only emit vmlinux relocations when required Lorenzo Stoakes (ARM)
2026-09-10 4:19 ` Nathan Chancellor
2026-09-08 20:55 ` [PATCH 07/23] elf-parse: add section flags, symbol binding and a read-only mapping Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 08/23] kallsyms: reimplement mksysmap in C Lorenzo Stoakes (ARM)
2026-09-11 18:52 ` Markus Elfring
2026-09-11 19:15 ` Markus Elfring
2026-09-11 19:42 ` Markus Elfring
2026-09-08 20:55 ` [PATCH 09/23] kbuild: do not allocate .modinfo in vmlinux Lorenzo Stoakes (ARM)
2026-09-10 4:19 ` Nathan Chancellor
2026-09-10 10:59 ` Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 10/23] kbuild: cache list, composite object state per object Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 11/23] kbuild: implement and use depcheck to check dependency timestamps Lorenzo Stoakes (ARM)
2026-09-09 15:26 ` Linus Torvalds
2026-09-08 20:55 ` Lorenzo Stoakes (ARM) [this message]
2026-09-10 4:19 ` [PATCH 12/23] kbuild: avoid re-running compiler and linker probes Nathan Chancellor
2026-09-10 15:42 ` Nicolas Schier
2026-09-11 10:30 ` Lorenzo Stoakes (ARM)
2026-09-11 18:10 ` Nicolas Schier
2026-09-11 18:25 ` Lorenzo Stoakes (ARM)
2026-09-11 17:33 ` David Laight
2026-09-11 18:17 ` Nicolas Schier
2026-09-11 18:24 ` Lorenzo Stoakes (ARM)
2026-09-11 19:34 ` Nicolas Schier
2026-09-11 21:01 ` David Laight
2026-09-12 7:11 ` Nathan Chancellor
2026-09-11 10:26 ` Lorenzo Stoakes (ARM)
2026-09-12 6:51 ` Nathan Chancellor
2026-09-12 10:03 ` David Laight
2026-09-08 20:55 ` [PATCH 13/23] modpost: hash module source per-file, not per-byte Lorenzo Stoakes (ARM)
2026-09-10 12:52 ` Petr Pavlu
2026-09-11 10:41 ` Lorenzo Stoakes (ARM)
2026-09-11 11:57 ` Petr Pavlu
2026-09-11 12:21 ` Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 14/23] modpost: cache section relocation mismatch state Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 15/23] modpost: emit module descriptors as assembly Lorenzo Stoakes (ARM)
2026-09-09 14:59 ` Linus Torvalds
2026-09-08 20:55 ` [PATCH 16/23] kbuild: batch module finalisation Lorenzo Stoakes (ARM)
2026-09-10 15:48 ` Nicolas Schier
2026-09-11 10:23 ` Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 17/23] modpost: perform srcversion hashing in parallel Lorenzo Stoakes (ARM)
2026-09-10 10:32 ` David Laight
2026-09-11 10:49 ` Lorenzo Stoakes (ARM)
2026-09-12 11:50 ` Yann Droneaud
2026-09-08 20:55 ` [PATCH 18/23] objtool: cache relocations and function dead end state, do less work Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 19/23] objtool: decode instructions and resolve branch targets in parallel Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 20/23] kbuild: rust: parallelise rustc front end Lorenzo Stoakes (ARM)
2026-09-08 21:13 ` Miguel Ojeda
2026-09-09 14:22 ` Lorenzo Stoakes (ARM)
2026-09-09 10:22 ` Björn Baron
2026-09-09 12:59 ` Miguel Ojeda
2026-09-09 14:26 ` Lorenzo Stoakes (ARM)
2026-09-10 12:25 ` Nicolas Schier (FRITZ!)
2026-09-11 19:00 ` Nicolas Schier
2026-09-08 20:55 ` [PATCH 21/23] rust: make exports.o depend on the headers generated for it Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 22/23] kbuild: build rust crates in parallel with the rest of the build Lorenzo Stoakes (ARM)
2026-09-08 20:55 ` [PATCH 23/23] kbuild: use pigz for gzip compression if available Lorenzo Stoakes (ARM)
2026-09-10 4:19 ` Nathan Chancellor
2026-09-11 11:03 ` Lorenzo Stoakes (ARM)
2026-09-12 6:38 ` Nathan Chancellor
2026-09-08 21:06 ` [PATCH 00/23] kbuild: significantly speed up kernel builds Nick Desaulniers
2026-09-09 14:17 ` Lorenzo Stoakes (ARM)
2026-09-09 22:09 ` Nick Desaulniers
2026-09-11 11:25 ` Lorenzo Stoakes (ARM)
2026-09-09 15:37 ` Linus Torvalds
2026-09-09 16:30 ` Lorenzo Stoakes (ARM)
2026-09-09 21:58 ` Florian Fainelli
2026-09-11 11:28 ` Lorenzo Stoakes (ARM)
2026-09-12 6:44 ` Nathan Chancellor
2026-09-10 4:19 ` Nathan Chancellor
2026-09-11 11:13 ` Lorenzo Stoakes (ARM)
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=20260908-build-speedup-v1-12-5dc1ac01672d@kernel.org \
--to=ljs@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=alex@ghiti.fr \
--cc=aliceryhl@google.com \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dave.hansen@linux.intel.com \
--cc=gary@garyguo.net \
--cc=hpa@zytor.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jpoimboe@kernel.org \
--cc=justinstitt@google.com \
--cc=legion@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=lossin@kernel.org \
--cc=mark.rutland@arm.com \
--cc=masahiroy@kernel.org \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nsc@kernel.org \
--cc=ojeda@kernel.org \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tglx@kernel.org \
--cc=tmgross@umich.edu \
--cc=torvalds@linux-foundation.org \
--cc=will@kernel.org \
--cc=work@onurozkan.dev \
--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