Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ff10bce
scripts/mksysmap: drop the MODULE_INFO() symbols from kallsyms
Sep 8, 2026
1bbfcb3
scripts/mksysmap: fix escape of '$' in the __pi_ pattern
Sep 8, 2026
030bb5e
kallsyms: index symbols by token to speed up table compression
Sep 8, 2026
181fac3
kallsyms: output binary data to speed output and kallsyms assembly
Sep 8, 2026
573517c
kbuild: do not sort nm output where the order is irrelevant
Sep 8, 2026
af8624c
kbuild: only emit vmlinux relocations when required
Sep 8, 2026
c0622e7
elf-parse: add section flags, symbol binding and a read-only mapping
Sep 8, 2026
4f32df2
kallsyms: reimplement mksysmap in C
Sep 8, 2026
02aa346
kbuild: do not allocate .modinfo in vmlinux
Sep 8, 2026
64fa7cf
kbuild: cache list, composite object state per object
Sep 8, 2026
d9ead5a
kbuild: implement and use depcheck to check dependency timestamps
Sep 8, 2026
e15aabf
kbuild: avoid re-running compiler and linker probes
Sep 8, 2026
232ef20
modpost: hash module source per-file, not per-byte
Sep 8, 2026
a0c5d22
modpost: cache section relocation mismatch state
Sep 8, 2026
7f220a1
modpost: emit module descriptors as assembly
Sep 8, 2026
92f2255
kbuild: batch module finalisation
Sep 8, 2026
c9d7d74
modpost: perform srcversion hashing in parallel
Sep 8, 2026
b0e9759
objtool: cache relocations and function dead end state, do less work
Sep 8, 2026
5c5210b
objtool: decode instructions and resolve branch targets in parallel
Sep 8, 2026
e614801
kbuild: rust: parallelise rustc front end
Sep 8, 2026
9829357
rust: make exports.o depend on the headers generated for it
Sep 8, 2026
0961bb1
kbuild: build rust crates in parallel with the rest of the build
Sep 8, 2026
bca6415
kbuild: use pigz for gzip compression if available
Sep 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*.lzo
*.mod
*.mod.c
*.mod.S
*.o
*.o.*
*.patch
Expand Down
13 changes: 13 additions & 0 deletions Documentation/kbuild/kbuild.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ HOSTLDLIBS
----------
Additional libraries to link against when building host programs.

KGZIP
-----
The gzip compressor used for the compressed kernel image, compressed
modules and packaging.

If unset, it defaults to pigz (a parallel implementation of gzip) if available,
otherwise gzip.

KBZIP2, KLZOP, LZMA, LZ4, XZ, ZSTD
----------------------------------
The compressor programs for the other formats. Each defaults to the program
of the same name.

.. _userkbuildflags:

USERCFLAGS
Expand Down
16 changes: 16 additions & 0 deletions Documentation/kbuild/reproducible-builds.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ include generated files. You should ensure the source tree is
pristine by running ``make mrproper`` or ``git clean -d -f -x`` before
building a source package.

Compression tools
-----------------

The compressed kernel image, compressed modules and packages are produced
using the binary specified by the environment variable ``KGZIP`` (described
in Documentation/kbuild/kbuild.rst).

This variable defaults to ``pigz`` if installed (a parallel implementation
of gzip), or ``gzip`` otherwise.

The generated output between two invocations of identical builds with
either of the default tools will be byte-for-byte equivalent.

However, for reproducible builds, ensure the same tool is used on all build
hosts, as different tools may generate different output from one another.

Module signing
--------------

Expand Down
5 changes: 5 additions & 0 deletions Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,8 @@ obj-$(CONFIG_NET) += net/
obj-y += virt/
obj-y += $(ARCH_DRIVERS)
obj-$(CONFIG_DRM_HEADER_TEST) += include/

# Rust code elsewhere in the tree depends upon rust/.
ifdef CONFIG_RUST
$(KBUILD_RUST_DIRS): | rust
endif
49 changes: 32 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ PERL = perl
PYTHON3 = python3
CHECK = sparse
BASH = bash
KGZIP = gzip
KGZIP := $(if $(shell command -v pigz 2>/dev/null),pigz,gzip)
KBZIP2 = bzip2
KLZOP = lzop
LZMA = lzma
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1205,6 +1204,10 @@ KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/= --remap-path-scope=macro
endif
endif

ifdef CONFIG_RUST
KBUILD_RUSTFLAGS += $(if $(CONFIG_RUSTC_HAS_JOBS),-j8,$(if $(CONFIG_RUSTC_HAS_ZTHREADS),-Zthreads=8))
endif

# include additional Makefiles when needed
include-y := scripts/Makefile.warn
include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug
Expand Down Expand Up @@ -1240,11 +1243,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)
Expand All @@ -1263,8 +1266,10 @@ LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
endif

ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),)
LDFLAGS_vmlinux += --emit-relocs --discard-none
LDFLAGS_vmlinux += --discard-none
LDFLAGS_vmlinux_relocs := --emit-relocs
endif
export LDFLAGS_vmlinux_relocs

# Align the architecture of userspace programs with the kernel
USERFLAGS_FROM_KERNEL := --target=%
Expand Down Expand Up @@ -1421,14 +1426,17 @@ archprepare: outputmakefile archheaders archscripts scripts include/config/kerne
include/generated/rustc_cfg remove-stale-files

prepare0: archprepare
$(Q)$(MAKE) $(build)=scripts/mod
$(Q)$(MAKE) $(build)=. prepare
$(Q)$(MAKE) $(build)=scripts/mod

ifdef CONFIG_RUST
export KBUILD_RUST_DIRS := drivers lib mm samples
endif

# All the preparing..
prepare: prepare0
ifdef CONFIG_RUST
+$(Q)$(CONFIG_SHELL) $(srctree)/scripts/rust_is_available.sh
$(Q)$(MAKE) $(build)=rust
endif

PHONY += remove-stale-files
Expand Down Expand Up @@ -1755,6 +1763,12 @@ modules: modules_prepare
# Target to prepare building external modules
modules_prepare: prepare
$(Q)$(MAKE) $(build)=scripts scripts/module.lds
ifdef CONFIG_RUST
# Ensure rust/ is build before any external rust module which will rely upon it.
ifeq ($(MAKECMDGOALS),modules_prepare)
$(Q)$(MAKE) $(build)=rust
endif
endif

endif # CONFIG_MODULES

Expand Down Expand Up @@ -2237,13 +2251,14 @@ clean: $(clean-dirs)
$(call cmd,rmfiles)
@find . $(RCS_FIND_IGNORE) \
\( -name '*.[aios]' -o -name '*.rsi' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '.depcheck.mk' -o -name '.depcheck.mk.tmp' \
-o -name '*.ko.*' -o -name '*.o.thinlto.bc' \
-o -name '*.dtb' -o -name '*.dtbo' \
-o -name '*.dtb.S' -o -name '*.dtbo.S' \
-o -name '*.dt.yaml' -o -name 'dtbs-list' \
-o -name '*.dwo' -o -name '*.lst' \
-o -name '*.su' -o -name '*.mod' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' -o -name '*.mod.S' \
-o -name '*.lex.c' -o -name '*.tab.[ch]' \
-o -name '*.asn1.[ch]' \
-o -name '*.symtypes' -o -name 'modules.order' \
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kernel/pi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/kernel/pi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
17 changes: 17 additions & 0 deletions arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions arch/x86/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ SETUP_OBJS = $(addprefix $(obj)/,$(setup-y))
sed-zoffset := -e 's/^\([0-9a-fA-F]*\) [a-zA-Z] \(startup_32\|efi.._stub_entry\|efi\(32\)\?_pe_entry\|input_data\|kernel_info\|_end\|_ehead\|_text\|_e\?data\|_e\?sbat\|z_.*\)$$/\#define ZO_\2 0x\1/p'

quiet_cmd_zoffset = ZOFFSET $@
cmd_zoffset = $(NM) $< | sed -n $(sed-zoffset) > $@
cmd_zoffset = $(NM) -p $< | sed -n $(sed-zoffset) > $@

targets += zoffset.h
$(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/boot/compressed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ HOST_EXTRACFLAGS += -I$(srctree)/tools/include
sed-voffset := -e 's/^\([0-9a-fA-F]*\) [ABbCDGRSTtVW] \(_text\|__start_rodata\|_sinittext\|__inittext_end\|__bss_start\|_end\)$$/\#define VO_\2 _AC(0x\1,UL)/p'

quiet_cmd_voffset = VOFFSET $@
cmd_voffset = $(NM) $< | sed -n $(sed-voffset) > $@
cmd_voffset = $(NM) -p $< | sed -n $(sed-voffset) > $@

targets += ../voffset.h

Expand Down
2 changes: 1 addition & 1 deletion drivers/firmware/efi/libstub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

#
Expand Down
2 changes: 1 addition & 1 deletion include/asm-generic/vmlinux.lds.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@
KLP_SYMID

#define MODINFO \
.modinfo : { *(.modinfo) . = ALIGN(8); }
.modinfo (INFO) : { *(.modinfo) . = ALIGN(8); }

#ifdef CONFIG_GENERIC_BUG
#define BUG_TABLE \
Expand Down
2 changes: 1 addition & 1 deletion include/linux/vermagic.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define _LINUX_VERMAGIC_H

#ifndef INCLUDE_VERMAGIC
#error "This header can be included from kernel/module.c or *.mod.c only"
#error "This header can be included from kernel/module.c or scripts/module-common.c only"
#endif

#include <generated/utsrelease.h>
Expand Down
Loading
Loading