Kbuild updates for v6.2

- Support zstd-compressed debug info
 
  - Allow W=1 builds to detect objects shared among multiple modules
 
  - Add srcrpm-pkg target to generate a source RPM package
 
  - Make the -s option detection work for future GNU Make versions
 
  - Add -Werror to KBUILD_CPPFLAGS when CONFIG_WERROR=y
 
  - Allow W=1 builds to detect -Wundef warnings in any preprocessed files
 
  - Raise the minimum supported version of binutils to 2.25
 
  - Use $(intcmp ...) to compare integers if GNU Make >= 4.4 is used
 
  - Use $(file ...) to read a file if GNU Make >= 4.2 is used
 
  - Print error if GNU Make older than 3.82 is used
 
  - Allow modpost to detect section mismatches with Clang LTO
 
  - Include vmlinuz.efi into kernel tarballs for arm64 CONFIG_EFI_ZBOOT=y
 -----BEGIN PGP SIGNATURE-----
 
 iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmOeImsVHG1hc2FoaXJv
 eUBrZXJuZWwub3JnAAoJED2LAQed4NsG06IP/iVjuWFvnjDZT4X8X6zN8aKp1vtR
 EMkmoRtt5cD4CLb1MG4N7irYHgedQSx4rYceP45MyW1I3egl6Ct14RDyeQ1xSIZb
 XFTLDCZvfl/up3MdiqNAqKRS7x5lk9++7F0t+2SoQxKQyJvm735XreX+VhZ1FeLB
 qcHrmzJ5veky5Ry/3OkNUgKFBjKEAL+qKMc55uvkXqfTb3KoBa2r4VC1OaoYGRru
 R8oF9qQRnGVQAl/LbBVchmgSjxryxPrCvBGiKlK03VkXdzEMHMimEJh3BQ6e0PGo
 gajdk+4liy7z+jQnI7jFhvJjGKzkEP/Bc99M/uS92QX5MgpH6mqpHMoqqPiqW87K
 RmZH37FqRu1Vo8dpibmH6r2K6YD/HHRjaDHk1VuuCQYEn0dsNmokPXOqd/1v0I1i
 TXPjWOw1AID5vMJWllqxFhpeVvf0vx5BT/UNrh68MLqlJZzv2eMVJb4fNy6640ml
 U0NclMnOa3eOmf5z1T7/LqDRTa63Q0kpanRrBpcmVOaqW+ZpQ3SQjh4uBN1PyJHL
 cX3Skc341DyRlFiT54QhGKlm57MEb2gjhBZ3Z4J+b7sEFgvjXH/W8vcOGIKlppmA
 CfYMyres4OV+fJc89ONkWsvLiOP1OeUGPvytm33J5QMKXc8SzOLP0D/F8kjrDflm
 EROKuZ4EA5ej/rOy
 =Ig/Y
 -----END PGP SIGNATURE-----

Merge tag 'kbuild-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada:

 - Support zstd-compressed debug info

 - Allow W=1 builds to detect objects shared among multiple modules

 - Add srcrpm-pkg target to generate a source RPM package

 - Make the -s option detection work for future GNU Make versions

 - Add -Werror to KBUILD_CPPFLAGS when CONFIG_WERROR=y

 - Allow W=1 builds to detect -Wundef warnings in any preprocessed files

 - Raise the minimum supported version of binutils to 2.25

 - Use $(intcmp ...) to compare integers if GNU Make >= 4.4 is used

 - Use $(file ...) to read a file if GNU Make >= 4.2 is used

 - Print error if GNU Make older than 3.82 is used

 - Allow modpost to detect section mismatches with Clang LTO

 - Include vmlinuz.efi into kernel tarballs for arm64 CONFIG_EFI_ZBOOT=y

* tag 'kbuild-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (29 commits)
  buildtar: fix tarballs with EFI_ZBOOT enabled
  modpost: Include '.text.*' in TEXT_SECTIONS
  padata: Mark padata_work_init() as __ref
  kbuild: ensure Make >= 3.82 is used
  kbuild: refactor the prerequisites of the modpost rule
  kbuild: change module.order to list *.o instead of *.ko
  kbuild: use .NOTINTERMEDIATE for future GNU Make versions
  kconfig: refactor Makefile to reduce process forks
  kbuild: add read-file macro
  kbuild: do not sort after reading modules.order
  kbuild: add test-{ge,gt,le,lt} macros
  Documentation: raise minimum supported version of binutils to 2.25
  kbuild: add -Wundef to KBUILD_CPPFLAGS for W=1 builds
  kbuild: move -Werror from KBUILD_CFLAGS to KBUILD_CPPFLAGS
  kbuild: Port silent mode detection to future gnu make.
  init/version.c: remove #include <generated/utsrelease.h>
  firmware_loader: remove #include <generated/utsrelease.h>
  modpost: Mark uuid_le type to be suitable only for MEI
  kbuild: add ability to make source rpm buildable using koji
  kbuild: warn objects shared among multiple modules
  ...
This commit is contained in:
Linus Torvalds 2022-12-19 12:33:32 -06:00
commit 6feb57c2fd
42 changed files with 286 additions and 156 deletions

View File

@ -35,7 +35,7 @@ Rust (optional) 1.62.0 rustc --version
bindgen (optional) 0.56.0 bindgen --version bindgen (optional) 0.56.0 bindgen --version
GNU make 3.82 make --version GNU make 3.82 make --version
bash 4.2 bash --version bash 4.2 bash --version
binutils 2.23 ld -v binutils 2.25 ld -v
flex 2.5.35 flex --version flex 2.5.35 flex --version
bison 2.0 bison --version bison 2.0 bison --version
pahole 1.16 pahole --version pahole 1.16 pahole --version
@ -119,7 +119,7 @@ Bash 4.2 or newer is needed.
Binutils Binutils
-------- --------
Binutils 2.23 or newer is needed to build the kernel. Binutils 2.25 or newer is needed to build the kernel.
pkg-config pkg-config
---------- ----------

View File

@ -11,6 +11,10 @@ NAME = Hurr durr I'ma ninja sloth
# Comments in this file are targeted only to the developer, do not # Comments in this file are targeted only to the developer, do not
# expect to learn how to build the kernel reading this file. # expect to learn how to build the kernel reading this file.
ifeq ($(filter undefine,$(.FEATURES)),)
$(error GNU Make >= 3.82 is required. Your Make version is $(MAKE_VERSION))
endif
$(if $(filter __%, $(MAKECMDGOALS)), \ $(if $(filter __%, $(MAKECMDGOALS)), \
$(error targets prefixed with '__' are only for internal use)) $(error targets prefixed with '__' are only for internal use))
@ -93,8 +97,15 @@ endif
# If the user is running make -s (silent mode), suppress echoing of # If the user is running make -s (silent mode), suppress echoing of
# commands # commands
# make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS.
ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) ifeq ($(filter 3.%,$(MAKE_VERSION)),)
silence:=$(findstring s,$(firstword -$(MAKEFLAGS)))
else
silence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS)))
endif
ifeq ($(silence),s)
quiet=silent_ quiet=silent_
KBUILD_VERBOSE = 0 KBUILD_VERBOSE = 0
endif endif
@ -369,7 +380,7 @@ else # !mixed-build
include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Kbuild.include
# Read KERNELRELEASE from include/config/kernel.release (if it exists) # Read KERNELRELEASE from include/config/kernel.release (if it exists)
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) KERNELRELEASE = $(call read-file, include/config/kernel.release)
KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
@ -859,7 +870,8 @@ stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
KBUILD_CFLAGS += $(stackp-flags-y) KBUILD_CFLAGS += $(stackp-flags-y)
KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y)
KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings
@ -990,7 +1002,7 @@ KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
# Check for frame size exceeding threshold during prolog/epilog insertion # Check for frame size exceeding threshold during prolog/epilog insertion
# when using lld < 13.0.0. # when using lld < 13.0.0.
ifneq ($(CONFIG_FRAME_WARN),0) ifneq ($(CONFIG_FRAME_WARN),0)
ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0) ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN) KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
endif endif
endif endif
@ -1560,7 +1572,7 @@ __modinst_pre:
rm -f $(MODLIB)/build ; \ rm -f $(MODLIB)/build ; \
ln -s $(CURDIR) $(MODLIB)/build ; \ ln -s $(CURDIR) $(MODLIB)/build ; \
fi fi
@sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order @sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
@cp -f modules.builtin $(MODLIB)/ @cp -f modules.builtin $(MODLIB)/
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/

View File

@ -37,7 +37,7 @@ else
endif endif
ifeq ($(CONFIG_LD_IS_LLD),y) ifeq ($(CONFIG_LD_IS_LLD),y)
ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 150000; echo $$?),0) ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 150000),y)
KBUILD_CFLAGS += -mno-relax KBUILD_CFLAGS += -mno-relax
KBUILD_AFLAGS += -mno-relax KBUILD_AFLAGS += -mno-relax
ifndef CONFIG_AS_IS_LLVM ifndef CONFIG_AS_IS_LLVM

View File

@ -217,7 +217,7 @@ endif
KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE) KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
ifdef CONFIG_LTO_CLANG ifdef CONFIG_LTO_CLANG
ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0) ifeq ($(call test-lt, $(CONFIG_LLD_VERSION), 130000),y)
KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8) KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8)
endif endif
endif endif

View File

@ -9,8 +9,6 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <generated/utsrelease.h>
/** /**
* enum fw_opt - options to control firmware loading behaviour * enum fw_opt - options to control firmware loading behaviour
* *

View File

@ -15,7 +15,6 @@
#include <linux/printk.h> #include <linux/printk.h>
#include <linux/uts.h> #include <linux/uts.h>
#include <linux/utsname.h> #include <linux/utsname.h>
#include <generated/utsrelease.h>
#include <linux/proc_ns.h> #include <linux/proc_ns.h>
static int __init early_hostname(char *arg) static int __init early_hostname(char *arg)

View File

@ -83,7 +83,15 @@ static struct padata_work *padata_work_alloc(void)
return pw; return pw;
} }
static void padata_work_init(struct padata_work *pw, work_func_t work_fn, /*
* This function is marked __ref because this function may be optimized in such
* a way that it directly refers to work_fn's address, which causes modpost to
* complain when work_fn is marked __init. This scenario was observed with clang
* LTO, where padata_work_init() was optimized to refer directly to
* padata_mt_helper() because the calls to padata_work_init() with other work_fn
* values were eliminated or inlined.
*/
static void __ref padata_work_init(struct padata_work *pw, work_func_t work_fn,
void *data, int flags) void *data, int flags)
{ {
if (flags & PADATA_WORK_ONSTACK) if (flags & PADATA_WORK_ONSTACK)

View File

@ -312,8 +312,21 @@ config DEBUG_INFO_REDUCED
DEBUG_INFO build and compile times are reduced too. DEBUG_INFO build and compile times are reduced too.
Only works with newer gcc versions. Only works with newer gcc versions.
config DEBUG_INFO_COMPRESSED choice
bool "Compressed debugging information" prompt "Compressed Debug information"
help
Compress the resulting debug info. Results in smaller debug info sections,
but requires that consumers are able to decompress the results.
If unsure, choose DEBUG_INFO_COMPRESSED_NONE.
config DEBUG_INFO_COMPRESSED_NONE
bool "Don't compress debug information"
help
Don't compress debug info sections.
config DEBUG_INFO_COMPRESSED_ZLIB
bool "Compress debugging information with zlib"
depends on $(cc-option,-gz=zlib) depends on $(cc-option,-gz=zlib)
depends on $(ld-option,--compress-debug-sections=zlib) depends on $(ld-option,--compress-debug-sections=zlib)
help help
@ -327,6 +340,18 @@ config DEBUG_INFO_COMPRESSED
preferable to setting $KDEB_COMPRESS to "none" which would be even preferable to setting $KDEB_COMPRESS to "none" which would be even
larger. larger.
config DEBUG_INFO_COMPRESSED_ZSTD
bool "Compress debugging information with zstd"
depends on $(cc-option,-gz=zstd)
depends on $(ld-option,--compress-debug-sections=zstd)
help
Compress the debug information using zstd. This may provide better
compression than zlib, for about the same time costs, but requires newer
toolchain support. Requires GCC 13.0+ or Clang 16.0+, binutils 2.40+, and
zstd.
endchoice # "Compressed Debug information"
config DEBUG_INFO_SPLIT config DEBUG_INFO_SPLIT
bool "Produce split debuginfo in .dwo files" bool "Produce split debuginfo in .dwo files"
depends on $(cc-option,-gsplit-dwarf) depends on $(cc-option,-gsplit-dwarf)

View File

@ -10,6 +10,26 @@ empty :=
space := $(empty) $(empty) space := $(empty) $(empty)
space_escape := _-_SPACE_-_ space_escape := _-_SPACE_-_
pound := \# pound := \#
define newline
endef
###
# Comparison macros.
# Usage: $(call test-lt, $(CONFIG_LLD_VERSION), 150000)
#
# Use $(intcmp ...) if supported. (Make >= 4.4)
# Otherwise, fall back to the 'test' shell command.
ifeq ($(intcmp 1,0,,,y),y)
test-ge = $(intcmp $(strip $1)0, $(strip $2)0,,y,y)
test-gt = $(intcmp $(strip $1)0, $(strip $2)0,,,y)
else
test-ge = $(shell test $(strip $1)0 -ge $(strip $2)0 && echo y)
test-gt = $(shell test $(strip $1)0 -gt $(strip $2)0 && echo y)
endif
test-le = $(call test-ge, $2, $1)
test-lt = $(call test-gt, $2, $1)
### ###
# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o # Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o
@ -40,6 +60,21 @@ escsq = $(subst $(squote),'\$(squote)',$1)
# Quote a string to pass it to C files. foo => '"foo"' # Quote a string to pass it to C files. foo => '"foo"'
stringify = $(squote)$(quote)$1$(quote)$(squote) stringify = $(squote)$(quote)$1$(quote)$(squote)
###
# The path to Kbuild or Makefile. Kbuild has precedence over Makefile.
kbuild-dir = $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
kbuild-file = $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
###
# Read a file, replacing newlines with spaces
#
# Make 4.2 or later can read a file by using its builtin function.
ifneq ($(filter-out 3.% 4.0 4.1, $(MAKE_VERSION)),)
read-file = $(subst $(newline),$(space),$(file < $1))
else
read-file = $(shell cat $1 2>/dev/null)
endif
### ###
# Easy method for doing a status message # Easy method for doing a status message
kecho := : kecho := :
@ -150,9 +185,6 @@ endif
make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))) make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))))
# Find any prerequisites that are newer than target or that do not exist. # Find any prerequisites that are newer than target or that do not exist.
# (This is not true for now; $? should contain any non-existent prerequisites,
# but it does not work as expected when .SECONDARY is present. This seems a bug
# of GNU Make.)
# PHONY targets skipped in both cases. # PHONY targets skipped in both cases.
newer-prereqs = $(filter-out $(PHONY),$?) newer-prereqs = $(filter-out $(PHONY),$?)
@ -228,4 +260,14 @@ endif
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
# do not delete intermediate files automatically # do not delete intermediate files automatically
#
# .NOTINTERMEDIATE is more correct, but only available on newer Make versions.
# Make 4.4 introduced .NOTINTERMEDIATE, and it appears in .FEATURES, but the
# global .NOTINTERMEDIATE does not work. We can use it on Make > 4.4.
# Use .SECONDARY for older Make versions, but "newer-prereq" cannot detect
# deleted files.
ifneq ($(and $(filter notintermediate, $(.FEATURES)),$(filter-out 4.4,$(MAKE_VERSION))),)
.NOTINTERMEDIATE:
else
.SECONDARY: .SECONDARY:
endif

View File

@ -10,15 +10,15 @@ PHONY := all
all: all:
src := $(subst /generated,,$(obj)) src := $(subst /generated,,$(obj))
-include $(src)/Kbuild
include $(srctree)/scripts/Kbuild.include
-include $(kbuild-file)
# $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case. # $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case.
ifneq ($(SRCARCH),um) ifneq ($(SRCARCH),um)
include $(srctree)/$(generic)/Kbuild include $(srctree)/$(generic)/Kbuild
endif endif
include $(srctree)/scripts/Kbuild.include
redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y)) redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y))
redundant += $(foreach f, $(generic-y), $(if $(wildcard $(srctree)/$(src)/$(f)),$(f))) redundant += $(foreach f, $(generic-y), $(if $(wildcard $(srctree)/$(src)/$(f)),$(f)))
redundant := $(sort $(redundant)) redundant := $(sort $(redundant))

View File

@ -38,11 +38,7 @@ subdir-ccflags-y :=
include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Kbuild.include
include $(srctree)/scripts/Makefile.compiler include $(srctree)/scripts/Makefile.compiler
include $(kbuild-file)
# The filename Kbuild has precedence over Makefile
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
include $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
include $(srctree)/scripts/Makefile.lib include $(srctree)/scripts/Makefile.lib
# Do not include hostprogs rules unless needed. # Do not include hostprogs rules unless needed.
@ -226,6 +222,10 @@ endif
cmd_check_local_export = $(srctree)/scripts/check-local-export $@ cmd_check_local_export = $(srctree)/scripts/check-local-export $@
ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),)
cmd_warn_shared_object = $(if $(word 2, $(modname-multi)),$(warning $(kbuild-file): $*.o is added to multiple modules: $(modname-multi)))
endif
define rule_cc_o_c define rule_cc_o_c
$(call cmd_and_fixdep,cc_o_c) $(call cmd_and_fixdep,cc_o_c)
$(call cmd,gen_ksymdeps) $(call cmd,gen_ksymdeps)
@ -235,6 +235,7 @@ define rule_cc_o_c
$(call cmd,gen_objtooldep) $(call cmd,gen_objtooldep)
$(call cmd,gen_symversions_c) $(call cmd,gen_symversions_c)
$(call cmd,record_mcount) $(call cmd,record_mcount)
$(call cmd,warn_shared_object)
endef endef
define rule_as_o_S define rule_as_o_S
@ -243,6 +244,7 @@ define rule_as_o_S
$(call cmd,check_local_export) $(call cmd,check_local_export)
$(call cmd,gen_objtooldep) $(call cmd,gen_objtooldep)
$(call cmd,gen_symversions_S) $(call cmd,gen_symversions_S)
$(call cmd,warn_shared_object)
endef endef
# Built-in and composite module parts # Built-in and composite module parts
@ -433,7 +435,7 @@ $(obj)/built-in.a: $(real-obj-y) FORCE
# modules.order unless contained modules are updated. # modules.order unless contained modules are updated.
cmd_modules_order = { $(foreach m, $(real-prereqs), \ cmd_modules_order = { $(foreach m, $(real-prereqs), \
$(if $(filter %/modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m));) :; } \ $(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \
> $@ > $@
$(obj)/modules.order: $(obj-m) FORCE $(obj)/modules.order: $(obj-m) FORCE

View File

@ -9,10 +9,7 @@ PHONY := __clean
__clean: __clean:
include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Kbuild.include
include $(kbuild-file)
# The filename Kbuild has precedence over Makefile
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
include $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
# Figure out what we need to build from the various variables # Figure out what we need to build from the various variables
# ========================================================================== # ==========================================================================

View File

@ -63,11 +63,11 @@ cc-disable-warning = $(call try-run,\
# gcc-min-version # gcc-min-version
# Usage: cflags-$(call gcc-min-version, 70100) += -foo # Usage: cflags-$(call gcc-min-version, 70100) += -foo
gcc-min-version = $(shell [ $(CONFIG_GCC_VERSION)0 -ge $(1)0 ] && echo y) gcc-min-version = $(call test-ge, $(CONFIG_GCC_VERSION), $1)
# clang-min-version # clang-min-version
# Usage: cflags-$(call clang-min-version, 110000) += -foo # Usage: cflags-$(call clang-min-version, 110000) += -foo
clang-min-version = $(shell [ $(CONFIG_CLANG_VERSION)0 -ge $(1)0 ] && echo y) clang-min-version = $(call test-ge, $(CONFIG_CLANG_VERSION), $1)
# ld-option # ld-option
# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) # Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y)

View File

@ -27,10 +27,14 @@ else
DEBUG_RUSTFLAGS += -Cdebuginfo=2 DEBUG_RUSTFLAGS += -Cdebuginfo=2
endif endif
ifdef CONFIG_DEBUG_INFO_COMPRESSED ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZLIB
DEBUG_CFLAGS += -gz=zlib DEBUG_CFLAGS += -gz=zlib
KBUILD_AFLAGS += -gz=zlib KBUILD_AFLAGS += -gz=zlib
KBUILD_LDFLAGS += --compress-debug-sections=zlib KBUILD_LDFLAGS += --compress-debug-sections=zlib
else ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZSTD
DEBUG_CFLAGS += -gz=zstd
KBUILD_AFLAGS += -gz=zstd
KBUILD_LDFLAGS += --compress-debug-sections=zstd
endif endif
KBUILD_CFLAGS += $(DEBUG_CFLAGS) KBUILD_CFLAGS += $(DEBUG_CFLAGS)

View File

@ -15,7 +15,7 @@ __dtbs_install:
include include/config/auto.conf include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Kbuild.include
include $(src)/Makefile include $(kbuild-file)
dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-))) dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-)))
subdirs := $(addprefix $(obj)/, $(subdir-y) $(subdir-m)) subdirs := $(addprefix $(obj)/, $(subdir-y) $(subdir-m))

View File

@ -38,6 +38,7 @@ KBUILD_CFLAGS += -Wno-sign-compare
KBUILD_CFLAGS += -Wno-type-limits KBUILD_CFLAGS += -Wno-type-limits
KBUILD_CFLAGS += -Wno-shift-negative-value KBUILD_CFLAGS += -Wno-shift-negative-value
KBUILD_CPPFLAGS += -Wundef
KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1 KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
else else

View File

@ -13,9 +13,9 @@ include $(srctree)/scripts/Kbuild.include
include $(srctree)/scripts/Makefile.lib include $(srctree)/scripts/Makefile.lib
# find all modules listed in modules.order # find all modules listed in modules.order
modules := $(sort $(shell cat $(MODORDER))) modules := $(call read-file, $(MODORDER))
__modfinal: $(modules) __modfinal: $(modules:%.o=%.ko)
@: @:
# modname and part-of-module are set to make c_flags define proper module flags # modname and part-of-module are set to make c_flags define proper module flags
@ -57,13 +57,13 @@ if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check), \
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
# Re-generate module BTFs if either module's .ko or vmlinux changed # Re-generate module BTFs if either module's .ko or vmlinux changed
$(modules): %.ko: %.o %.mod.o scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),vmlinux) FORCE %.ko: %.o %.mod.o scripts/module.lds $(and $(CONFIG_DEBUG_INFO_BTF_MODULES),$(KBUILD_BUILTIN),vmlinux) FORCE
+$(call if_changed_except,ld_ko_o,vmlinux) +$(call if_changed_except,ld_ko_o,vmlinux)
ifdef CONFIG_DEBUG_INFO_BTF_MODULES ifdef CONFIG_DEBUG_INFO_BTF_MODULES
+$(if $(newer-prereqs),$(call cmd,btf_ko)) +$(if $(newer-prereqs),$(call cmd,btf_ko))
endif endif
targets += $(modules) $(modules:.ko=.mod.o) targets += $(modules:%.o=%.ko) $(modules:%.o=%.mod.o)
# Add FORCE to the prequisites of a target to force it to be always rebuilt. # Add FORCE to the prequisites of a target to force it to be always rebuilt.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

View File

@ -9,7 +9,7 @@ __modinst:
include include/config/auto.conf include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Kbuild.include
modules := $(sort $(shell cat $(MODORDER))) modules := $(call read-file, $(MODORDER))
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
dst := $(MODLIB)/kernel dst := $(MODLIB)/kernel
@ -26,7 +26,7 @@ suffix-$(CONFIG_MODULE_COMPRESS_GZIP) := .gz
suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz suffix-$(CONFIG_MODULE_COMPRESS_XZ) := .xz
suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst suffix-$(CONFIG_MODULE_COMPRESS_ZSTD) := .zst
modules := $(patsubst $(extmod_prefix)%, $(dst)/%$(suffix-y), $(modules)) modules := $(patsubst $(extmod_prefix)%.o, $(dst)/%.ko$(suffix-y), $(modules))
__modinst: $(modules) __modinst: $(modules)
@: @:

View File

@ -38,6 +38,8 @@ __modpost:
include include/config/auto.conf include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Kbuild.include
MODPOST = scripts/mod/modpost
modpost-args = \ modpost-args = \
$(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODVERSIONS),-m) \
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
@ -46,6 +48,8 @@ modpost-args = \
$(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \ $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) \
-o $@ -o $@
modpost-deps := $(MODPOST)
# 'make -i -k' ignores compile errors, and builds as many modules as possible. # 'make -i -k' ignores compile errors, and builds as many modules as possible.
ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
modpost-args += -n modpost-args += -n
@ -78,12 +82,13 @@ targets += .vmlinux.objs
.vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE .vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
$(call if_changed,vmlinux_objs) $(call if_changed,vmlinux_objs)
vmlinux.o-if-present := $(wildcard vmlinux.o) ifeq ($(wildcard vmlinux.o),)
output-symdump := vmlinux.symvers missing-input := vmlinux.o
output-symdump := modules-only.symvers
ifdef KBUILD_MODULES else
output-symdump := $(if $(vmlinux.o-if-present), Module.symvers, modules-only.symvers) modpost-args += vmlinux.o
missing-input := $(filter-out $(vmlinux.o-if-present),vmlinux.o) modpost-deps += vmlinux.o
output-symdump := $(if $(KBUILD_MODULES), Module.symvers, vmlinux.symvers)
endif endif
else else
@ -93,13 +98,18 @@ obj := $(KBUILD_EXTMOD)
src := $(obj) src := $(obj)
# Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS
include $(or $(wildcard $(src)/Kbuild), $(src)/Makefile) include $(kbuild-file)
module.symvers-if-present := $(wildcard Module.symvers)
output-symdump := $(KBUILD_EXTMOD)/Module.symvers output-symdump := $(KBUILD_EXTMOD)/Module.symvers
missing-input := $(filter-out $(module.symvers-if-present), Module.symvers)
modpost-args += -e $(addprefix -i ,$(module.symvers-if-present) $(KBUILD_EXTRA_SYMBOLS)) ifeq ($(wildcard Module.symvers),)
missing-input := Module.symvers
else
modpost-args += -i Module.symvers
modpost-deps += Module.symvers
endif
modpost-args += -e $(addprefix -i , $(KBUILD_EXTRA_SYMBOLS))
endif # ($(KBUILD_EXTMOD),) endif # ($(KBUILD_EXTMOD),)
@ -107,9 +117,10 @@ ifneq ($(KBUILD_MODPOST_WARN)$(missing-input),)
modpost-args += -w modpost-args += -w
endif endif
modorder-if-needed := $(if $(KBUILD_MODULES), $(MODORDER)) ifdef KBUILD_MODULES
modpost-args += -T $(MODORDER)
MODPOST = scripts/mod/modpost modpost-deps += $(MODORDER)
endif
# Read out modules.order to pass in modpost. # Read out modules.order to pass in modpost.
# Otherwise, allmodconfig would fail with "Argument list too long". # Otherwise, allmodconfig would fail with "Argument list too long".
@ -119,10 +130,10 @@ quiet_cmd_modpost = MODPOST $@
echo >&2 "WARNING: $(missing-input) is missing."; \ echo >&2 "WARNING: $(missing-input) is missing."; \
echo >&2 " Modules may not have dependencies or modversions."; \ echo >&2 " Modules may not have dependencies or modversions."; \
echo >&2 " You may get many unresolved symbol warnings.";) \ echo >&2 " You may get many unresolved symbol warnings.";) \
sed 's/ko$$/o/' $(or $(modorder-if-needed), /dev/null) | $(MODPOST) $(modpost-args) -T - $(vmlinux.o-if-present) $(MODPOST) $(modpost-args)
targets += $(output-symdump) targets += $(output-symdump)
$(output-symdump): $(modorder-if-needed) $(vmlinux.o-if-present) $(module.symvers-if-present) $(MODPOST) FORCE $(output-symdump): $(modpost-deps) FORCE
$(call if_changed,modpost) $(call if_changed,modpost)
__modpost: $(output-symdump) __modpost: $(output-symdump)

View File

@ -62,6 +62,16 @@ rpm-pkg:
+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ta $(KERNELPATH).tar.gz \ +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ta $(KERNELPATH).tar.gz \
--define='_smp_mflags %{nil}' --define='_smp_mflags %{nil}'
# srcrpm-pkg
# ---------------------------------------------------------------------------
PHONY += srcrpm-pkg
srcrpm-pkg:
$(MAKE) clean
$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
$(call cmd,src_tar,$(KERNELPATH),kernel.spec)
+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ts $(KERNELPATH).tar.gz \
--define='_smp_mflags %{nil}' --define='_srcrpmdir $(srctree)'
# binrpm-pkg # binrpm-pkg
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
PHONY += binrpm-pkg PHONY += binrpm-pkg

View File

@ -138,10 +138,10 @@ def cmdfiles_for_modorder(modorder):
""" """
with open(modorder) as f: with open(modorder) as f:
for line in f: for line in f:
ko = line.rstrip() obj = line.rstrip()
base, ext = os.path.splitext(ko) base, ext = os.path.splitext(obj)
if ext != '.ko': if ext != '.o':
sys.exit('{}: module path must end with .ko'.format(ko)) sys.exit('{}: module path must end with .o'.format(obj))
mod = base + '.mod' mod = base + '.mod'
# Read from *.mod, to get a list of objects that compose the module. # Read from *.mod, to get a list of objects that compose the module.
with open(mod) as m: with open(mod) as m:

View File

@ -48,7 +48,7 @@ cat > "$output_file" << EOT
EOT EOT
{ {
[ -n "${read_modorder}" ] && sed 's/ko$/usyms/' modules.order | xargs cat [ -n "${read_modorder}" ] && sed 's/o$/usyms/' modules.order | xargs cat
echo "$needed_symbols" echo "$needed_symbols"
[ -n "$ksym_wl" ] && cat "$ksym_wl" [ -n "$ksym_wl" ] && cat "$ksym_wl"
} | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' | } | sed -e 's/ /\n/g' | sed -n -e '/^$/!p' |

View File

@ -23,7 +23,9 @@ try:
opts = [x for x in flags.split(" ") if x.startswith("--jobserver")] opts = [x for x in flags.split(" ") if x.startswith("--jobserver")]
# Parse out R,W file descriptor numbers and set them nonblocking. # Parse out R,W file descriptor numbers and set them nonblocking.
fds = opts[0].split("=", 1)[1] # If the MAKEFLAGS variable contains multiple instances of the
# --jobserver-auth= option, the last one is relevant.
fds = opts[-1].split("=", 1)[1]
reader, writer = [int(x) for x in fds.split(",", 1)] reader, writer = [int(x) for x in fds.split(",", 1)]
# Open a private copy of reader to avoid setting nonblocking # Open a private copy of reader to avoid setting nonblocking
# on an unexpecting process with the same reader fd. # on an unexpecting process with the same reader fd.

View File

@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
/conf /conf
/[gmnq]conf /[gmnq]conf
/[gmnq]conf-cfg /[gmnq]conf-cflags
/[gmnq]conf-libs
/qconf-bin
/qconf-moc.cc /qconf-moc.cc

View File

@ -159,11 +159,12 @@ conf-objs := conf.o $(common-objs)
hostprogs += nconf hostprogs += nconf
nconf-objs := nconf.o nconf.gui.o $(common-objs) nconf-objs := nconf.o nconf.gui.o $(common-objs)
HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs) HOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs)
HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) HOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags)
HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) HOSTCFLAGS_nconf.gui.o = $(call read-file, $(obj)/nconf-cflags)
$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg $(obj)/nconf: | $(obj)/nconf-libs
$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags
# mconf: Used for the menuconfig target based on lxdialog # mconf: Used for the menuconfig target based on lxdialog
hostprogs += mconf hostprogs += mconf
@ -171,27 +172,28 @@ lxdialog := $(addprefix lxdialog/, \
checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
mconf-objs := mconf.o $(lxdialog) $(common-objs) mconf-objs := mconf.o $(lxdialog) $(common-objs)
HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs) HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs)
$(foreach f, mconf.o $(lxdialog), \ $(foreach f, mconf.o $(lxdialog), \
$(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags))) $(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags)))
$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg $(obj)/mconf: | $(obj)/mconf-libs
$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags
# qconf: Used for the xconfig target based on Qt # qconf: Used for the xconfig target based on Qt
hostprogs += qconf hostprogs += qconf
qconf-cxxobjs := qconf.o qconf-moc.o qconf-cxxobjs := qconf.o qconf-moc.o
qconf-objs := images.o $(common-objs) qconf-objs := images.o $(common-objs)
HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) HOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs)
HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) HOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) HOSTCXXFLAGS_qconf-moc.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
$(obj)/qconf: | $(obj)/qconf-libs
$(obj)/qconf.o: $(obj)/qconf-cfg $(obj)/qconf.o $(obj)/qconf-moc.o: | $(obj)/qconf-cflags
quiet_cmd_moc = MOC $@ quiet_cmd_moc = MOC $@
cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@ cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@
$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE $(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin
$(call if_changed,moc) $(call if_changed,moc)
targets += qconf-moc.cc targets += qconf-moc.cc
@ -200,15 +202,16 @@ targets += qconf-moc.cc
hostprogs += gconf hostprogs += gconf
gconf-objs := gconf.o images.o $(common-objs) gconf-objs := gconf.o images.o $(common-objs)
HOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs) HOSTLDLIBS_gconf = $(call read-file, $(obj)/gconf-libs)
HOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags) HOSTCFLAGS_gconf.o = $(call read-file, $(obj)/gconf-cflags)
$(obj)/gconf.o: $(obj)/gconf-cfg $(obj)/gconf: | $(obj)/gconf-libs
$(obj)/gconf.o: | $(obj)/gconf-cflags
# check if necessary packages are available, and configure build flags # check if necessary packages are available, and configure build flags
filechk_conf_cfg = $(CONFIG_SHELL) $< cmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin)
$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE $(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh
$(call filechk,conf_cfg) $(call cmd,conf_cfg)
clean-files += *conf-cfg clean-files += *conf-cflags *conf-libs *conf-bin

View File

@ -1,6 +1,9 @@
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
cflags=$1
libs=$2
PKG="gtk+-2.0 gmodule-2.0 libglade-2.0" PKG="gtk+-2.0 gmodule-2.0 libglade-2.0"
if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
@ -26,5 +29,5 @@ if ! ${HOSTPKG_CONFIG} --atleast-version=2.0.0 gtk+-2.0; then
exit 1 exit 1
fi fi
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG)\" ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\" ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}

View File

@ -76,7 +76,7 @@ struct gstr str_new(void);
void str_free(struct gstr *gs); void str_free(struct gstr *gs);
void str_append(struct gstr *gs, const char *s); void str_append(struct gstr *gs, const char *s);
void str_printf(struct gstr *gs, const char *fmt, ...); void str_printf(struct gstr *gs, const char *fmt, ...);
const char *str_get(struct gstr *gs); char *str_get(struct gstr *gs);
/* menu.c */ /* menu.c */
void _menu_init(void); void _menu_init(void);

View File

@ -1,19 +1,22 @@
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
cflags=$1
libs=$2
PKG="ncursesw" PKG="ncursesw"
PKG2="ncurses" PKG2="ncurses"
if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then
if ${HOSTPKG_CONFIG} --exists $PKG; then if ${HOSTPKG_CONFIG} --exists $PKG; then
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG)\" ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\" ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}
exit 0 exit 0
fi fi
if ${HOSTPKG_CONFIG} --exists $PKG2; then if ${HOSTPKG_CONFIG} --exists ${PKG2}; then
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG2)\" ${HOSTPKG_CONFIG} --cflags ${PKG2} > ${cflags}
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG2)\" ${HOSTPKG_CONFIG} --libs ${PKG2} > ${libs}
exit 0 exit 0
fi fi
fi fi
@ -22,22 +25,22 @@ fi
# (Even if it is installed, some distributions such as openSUSE cannot # (Even if it is installed, some distributions such as openSUSE cannot
# find ncurses by pkg-config.) # find ncurses by pkg-config.)
if [ -f /usr/include/ncursesw/ncurses.h ]; then if [ -f /usr/include/ncursesw/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags}
echo libs=\"-lncursesw\" echo -lncursesw > ${libs}
exit 0 exit 0
fi fi
if [ -f /usr/include/ncurses/ncurses.h ]; then if [ -f /usr/include/ncurses/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\" echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags}
echo libs=\"-lncurses\" echo -lncurses > ${libs}
exit 0 exit 0
fi fi
# As a final fallback before giving up, check if $HOSTCC knows of a default # As a final fallback before giving up, check if $HOSTCC knows of a default
# ncurses installation (e.g. from a vendor-specific sysroot). # ncurses installation (e.g. from a vendor-specific sysroot).
if echo '#include <ncurses.h>' | ${HOSTCC} -E - >/dev/null 2>&1; then if echo '#include <ncurses.h>' | ${HOSTCC} -E - >/dev/null 2>&1; then
echo cflags=\"-D_GNU_SOURCE\" echo -D_GNU_SOURCE > ${cflags}
echo libs=\"-lncurses\" echo -lncurses > ${libs}
exit 0 exit 0
fi fi

View File

@ -440,9 +440,8 @@ again:
res = get_relations_str(sym_arr, &head); res = get_relations_str(sym_arr, &head);
set_subtitle(); set_subtitle();
dres = show_textbox_ext("Search Results", (char *) dres = show_textbox_ext("Search Results", str_get(&res), 0, 0,
str_get(&res), 0, 0, keys, &vscroll, keys, &vscroll, &hscroll, &update_text,
&hscroll, &update_text, (void *)
&data); &data);
again = false; again = false;
for (i = 0; i < JUMP_NB && keys[i]; i++) for (i = 0; i < JUMP_NB && keys[i]; i++)

View File

@ -724,10 +724,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
menu = prop->menu; menu = prop->menu;
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) { for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
bool accessible = menu_is_visible(menu);
submenu[i++] = menu; submenu[i++] = menu;
if (location == NULL && accessible) if (location == NULL && menu_is_visible(menu))
location = menu; location = menu;
} }
if (head && location) { if (head && location) {

View File

@ -1,19 +1,22 @@
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
cflags=$1
libs=$2
PKG="ncursesw menuw panelw" PKG="ncursesw menuw panelw"
PKG2="ncurses menu panel" PKG2="ncurses menu panel"
if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then
if ${HOSTPKG_CONFIG} --exists $PKG; then if ${HOSTPKG_CONFIG} --exists $PKG; then
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG)\" ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\" ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}
exit 0 exit 0
fi fi
if ${HOSTPKG_CONFIG} --exists $PKG2; then if ${HOSTPKG_CONFIG} --exists $PKG2; then
echo cflags=\"$(${HOSTPKG_CONFIG} --cflags $PKG2)\" ${HOSTPKG_CONFIG} --cflags ${PKG2} > ${cflags}
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG2)\" ${HOSTPKG_CONFIG} --libs ${PKG2} > ${libs}
exit 0 exit 0
fi fi
fi fi
@ -22,20 +25,20 @@ fi
# (Even if it is installed, some distributions such as openSUSE cannot # (Even if it is installed, some distributions such as openSUSE cannot
# find ncurses by pkg-config.) # find ncurses by pkg-config.)
if [ -f /usr/include/ncursesw/ncurses.h ]; then if [ -f /usr/include/ncursesw/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags}
echo libs=\"-lncursesw -lmenuw -lpanelw\" echo -lncursesw -lmenuw -lpanelw > ${libs}
exit 0 exit 0
fi fi
if [ -f /usr/include/ncurses/ncurses.h ]; then if [ -f /usr/include/ncurses/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\" echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags}
echo libs=\"-lncurses -lmenu -lpanel\" echo -lncurses -lmenu -lpanel > ${libs}
exit 0 exit 0
fi fi
if [ -f /usr/include/ncurses.h ]; then if [ -f /usr/include/ncurses.h ]; then
echo cflags=\"-D_GNU_SOURCE\" echo -D_GNU_SOURCE > ${cflags}
echo libs=\"-lncurses -lmenu -lpanel\" echo -lncurses -lmenu -lpanel > ${libs}
exit 0 exit 0
fi fi

View File

@ -1,6 +1,10 @@
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
cflags=$1
libs=$2
bin=$3
PKG="Qt5Core Qt5Gui Qt5Widgets" PKG="Qt5Core Qt5Gui Qt5Widgets"
if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
@ -11,9 +15,9 @@ if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
fi fi
if ${HOSTPKG_CONFIG} --exists $PKG; then if ${HOSTPKG_CONFIG} --exists $PKG; then
echo cflags=\"-std=c++11 -fPIC $(${HOSTPKG_CONFIG} --cflags $PKG)\" ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
echo libs=\"$(${HOSTPKG_CONFIG} --libs $PKG)\" ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}
echo moc=\"$(${HOSTPKG_CONFIG} --variable=host_bins Qt5Core)/moc\" ${HOSTPKG_CONFIG} --variable=host_bins Qt5Core > ${bin}
exit 0 exit 0
fi fi

View File

@ -74,7 +74,7 @@ void str_printf(struct gstr *gs, const char *fmt, ...)
} }
/* Retrieve value of growable string */ /* Retrieve value of growable string */
const char *str_get(struct gstr *gs) char *str_get(struct gstr *gs)
{ {
return gs->s; return gs->s;
} }

View File

@ -14,7 +14,7 @@ fi
case "$1" in case "$1" in
binutils) binutils)
echo 2.23.0 echo 2.25.0
;; ;;
gcc) gcc)
echo 5.1.0 echo 5.1.0

View File

@ -34,19 +34,23 @@ typedef Elf64_Addr kernel_ulong_t;
typedef uint32_t __u32; typedef uint32_t __u32;
typedef uint16_t __u16; typedef uint16_t __u16;
typedef unsigned char __u8; typedef unsigned char __u8;
/* UUID types for backward compatibility, don't use in new code */
typedef struct { typedef struct {
__u8 b[16]; __u8 b[16];
} guid_t; } guid_t;
/* backwards compatibility, don't use in new code */
typedef struct {
__u8 b[16];
} uuid_le;
typedef struct { typedef struct {
__u8 b[16]; __u8 b[16];
} uuid_t; } uuid_t;
#define UUID_STRING_LEN 36 #define UUID_STRING_LEN 36
/* MEI UUID type, don't use anywhere else */
typedef struct {
__u8 b[16];
} uuid_le;
/* Big exception to the "don't include kernel headers into userspace, which /* Big exception to the "don't include kernel headers into userspace, which
* even potentially has different endianness and word sizes, since * even potentially has different endianness and word sizes, since
* we handle those differences explicitly below */ * we handle those differences explicitly below */
@ -140,25 +144,22 @@ static void device_id_check(const char *modname, const char *device_id,
int i; int i;
if (size % id_size || size < id_size) { if (size % id_size || size < id_size) {
fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo of the size of section __mod_%s__<identifier>_device_table=%lu.\n"
"of the size of " "Fix definition of struct %s_device_id in mod_devicetable.h\n",
"section __mod_%s__<identifier>_device_table=%lu.\n"
"Fix definition of struct %s_device_id "
"in mod_devicetable.h\n",
modname, device_id, id_size, device_id, size, device_id); modname, device_id, id_size, device_id, size, device_id);
} }
/* Verify last one is a terminator */ /* Verify last one is a terminator */
for (i = 0; i < id_size; i++ ) { for (i = 0; i < id_size; i++ ) {
if (*(uint8_t*)(symval+size-id_size+i)) { if (*(uint8_t*)(symval+size-id_size+i)) {
fprintf(stderr,"%s: struct %s_device_id is %lu bytes. " fprintf(stderr,
"The last of %lu is:\n", "%s: struct %s_device_id is %lu bytes. The last of %lu is:\n",
modname, device_id, id_size, size / id_size); modname, device_id, id_size, size / id_size);
for (i = 0; i < id_size; i++ ) for (i = 0; i < id_size; i++ )
fprintf(stderr,"0x%02x ", fprintf(stderr,"0x%02x ",
*(uint8_t*)(symval+size-id_size+i) ); *(uint8_t*)(symval+size-id_size+i) );
fprintf(stderr,"\n"); fprintf(stderr,"\n");
fatal("%s: struct %s_device_id is not terminated " fatal("%s: struct %s_device_id is not terminated with a NULL entry!\n",
"with a NULL entry!\n", modname, device_id); modname, device_id);
} }
} }
} }
@ -1154,8 +1155,7 @@ static int do_amba_entry(const char *filename,
DEF_FIELD(symval, amba_id, mask); DEF_FIELD(symval, amba_id, mask);
if ((id & mask) != id) if ((id & mask) != id)
fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: " fatal("%s: Masked-off bit(s) of AMBA device ID are non-zero: id=0x%08X, mask=0x%08X. Please fix this driver.\n",
"id=0x%08X, mask=0x%08X. Please fix this driver.\n",
filename, id, mask); filename, id, mask);
p += sprintf(alias, "amba:d"); p += sprintf(alias, "amba:d");

View File

@ -519,9 +519,8 @@ static int parse_elf(struct elf_info *info, const char *filename)
int nobits = sechdrs[i].sh_type == SHT_NOBITS; int nobits = sechdrs[i].sh_type == SHT_NOBITS;
if (!nobits && sechdrs[i].sh_offset > info->size) { if (!nobits && sechdrs[i].sh_offset > info->size) {
fatal("%s is truncated. sechdrs[i].sh_offset=%lu > " fatal("%s is truncated. sechdrs[i].sh_offset=%lu > sizeof(*hrd)=%zu\n",
"sizeof(*hrd)=%zu\n", filename, filename, (unsigned long)sechdrs[i].sh_offset,
(unsigned long)sechdrs[i].sh_offset,
sizeof(*hdr)); sizeof(*hdr));
return 0; return 0;
} }
@ -823,10 +822,10 @@ static void check_section(const char *modname, struct elf_info *elf,
#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
#define DATA_SECTIONS ".data", ".data.rel" #define DATA_SECTIONS ".data", ".data.rel"
#define TEXT_SECTIONS ".text", ".text.unlikely", ".sched.text", \ #define TEXT_SECTIONS ".text", ".text.*", ".sched.text", \
".kprobes.text", ".cpuidle.text", ".noinstr.text" ".kprobes.text", ".cpuidle.text", ".noinstr.text"
#define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \ #define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \
".fixup", ".entry.text", ".exception.text", ".text.*", \ ".fixup", ".entry.text", ".exception.text", \
".coldtext", ".softirqentry.text" ".coldtext", ".softirqentry.text"
#define INIT_SECTIONS ".init.*" #define INIT_SECTIONS ".init.*"
@ -1355,8 +1354,7 @@ static void report_extable_warnings(const char* modname, struct elf_info* elf,
get_pretty_name(is_function(tosym), get_pretty_name(is_function(tosym),
&to_pretty_name, &to_pretty_name_p); &to_pretty_name, &to_pretty_name_p);
warn("%s(%s+0x%lx): Section mismatch in reference" warn("%s(%s+0x%lx): Section mismatch in reference from the %s %s%s to the %s %s:%s%s\n",
" from the %s %s%s to the %s %s:%s%s\n",
modname, fromsec, (long)r->r_offset, from_pretty_name, modname, fromsec, (long)r->r_offset, from_pretty_name,
fromsym_name, from_pretty_name_p, fromsym_name, from_pretty_name_p,
to_pretty_name, tosec, tosym_name, to_pretty_name_p); to_pretty_name, tosec, tosym_name, to_pretty_name_p);
@ -1871,11 +1869,9 @@ static void read_symbols_from_files(const char *filename)
FILE *in = stdin; FILE *in = stdin;
char fname[PATH_MAX]; char fname[PATH_MAX];
if (strcmp(filename, "-") != 0) {
in = fopen(filename, "r"); in = fopen(filename, "r");
if (!in) if (!in)
fatal("Can't open filenames file %s: %m", filename); fatal("Can't open filenames file %s: %m", filename);
}
while (fgets(fname, PATH_MAX, in) != NULL) { while (fgets(fname, PATH_MAX, in) != NULL) {
if (strends(fname, "\n")) if (strends(fname, "\n"))
@ -1883,7 +1879,6 @@ static void read_symbols_from_files(const char *filename)
read_symbols(fname); read_symbols(fname);
} }
if (in != stdin)
fclose(in); fclose(in);
} }

View File

@ -153,7 +153,7 @@ static void md4_transform(uint32_t *hash, uint32_t const *in)
static inline void md4_transform_helper(struct md4_ctx *ctx) static inline void md4_transform_helper(struct md4_ctx *ctx)
{ {
le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(uint32_t)); le32_to_cpu_array(ctx->block, ARRAY_SIZE(ctx->block));
md4_transform(ctx->hash, ctx->block); md4_transform(ctx->hash, ctx->block);
} }
@ -216,7 +216,7 @@ static void md4_final_ascii(struct md4_ctx *mctx, char *out, unsigned int len)
le32_to_cpu_array(mctx->block, (sizeof(mctx->block) - le32_to_cpu_array(mctx->block, (sizeof(mctx->block) -
sizeof(uint64_t)) / sizeof(uint32_t)); sizeof(uint64_t)) / sizeof(uint32_t));
md4_transform(mctx->hash, mctx->block); md4_transform(mctx->hash, mctx->block);
cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(uint32_t)); cpu_to_le32_array(mctx->hash, ARRAY_SIZE(mctx->hash));
snprintf(out, len, "%08X%08X%08X%08X", snprintf(out, len, "%08X%08X%08X%08X",
mctx->hash[0], mctx->hash[1], mctx->hash[2], mctx->hash[3]); mctx->hash[0], mctx->hash[1], mctx->hash[2], mctx->hash[3]);

View File

@ -16,7 +16,7 @@ check_same_name_modules()
for m in $(sed 's:.*/::' "$1" | sort | uniq -d) for m in $(sed 's:.*/::' "$1" | sort | uniq -d)
do do
echo "error: the following would cause module name conflict:" >&2 echo "error: the following would cause module name conflict:" >&2
sed -n "/\/$m/s:^: :p" "$1" >&2 sed -n "/\/$m/s:^\(.*\)\.o\$: \1.ko:p" "$1" >&2
exit_code=1 exit_code=1
done done
} }

View File

@ -122,7 +122,7 @@ case "${ARCH}" in
fi fi
;; ;;
arm64) arm64)
for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo ; do for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo vmlinuz.efi ; do
if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then
cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
break break

View File

@ -175,7 +175,7 @@ Section: kernel
Priority: optional Priority: optional
Maintainer: $maintainer Maintainer: $maintainer
Rules-Requires-Root: no Rules-Requires-Root: no
Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends Build-Depends: bc, rsync, kmod, cpio, bison, flex $extra_build_depends
Homepage: https://www.kernel.org/ Homepage: https://www.kernel.org/
Package: $packagename-$version Package: $packagename-$version

View File

@ -33,6 +33,8 @@ EXCLUDES="$RCS_TAR_IGNORE --exclude=*vmlinux* --exclude=*.mod \
--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \ --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
--exclude=.config.old --exclude=.missing-syscalls.d --exclude=*.s" --exclude=.config.old --exclude=.missing-syscalls.d --exclude=*.s"
test -n "$LOCALVERSION" && MAKE="$MAKE LOCALVERSION=$LOCALVERSION"
# We can label the here-doc lines for conditional output to the spec file # We can label the here-doc lines for conditional output to the spec file
# #
# Labels: # Labels:
@ -49,6 +51,9 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
URL: https://www.kernel.org URL: https://www.kernel.org
$S Source: kernel-$__KERNELRELEASE.tar.gz $S Source: kernel-$__KERNELRELEASE.tar.gz
Provides: $PROVIDES Provides: $PROVIDES
$S BuildRequires: bc binutils bison dwarves elfutils-libelf-devel flex
$S BuildRequires: gcc make openssl openssl-devel perl python3 rsync
# $UTS_MACHINE as a fallback of _arch in case # $UTS_MACHINE as a fallback of _arch in case
# /usr/lib/rpm/platform/*/macros was not included. # /usr/lib/rpm/platform/*/macros was not included.
%define _arch %{?_arch:$UTS_MACHINE} %define _arch %{?_arch:$UTS_MACHINE}
@ -80,6 +85,8 @@ $S$M against the $__KERNELRELEASE kernel package.
$S$M $S$M
$S %prep $S %prep
$S %setup -q $S %setup -q
$S rm -f scripts/basic/fixdep scripts/kconfig/conf
$S rm -f tools/objtool/{fixdep,objtool}
$S $S
$S %build $S %build
$S $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release} $S $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}

View File

@ -47,3 +47,5 @@ rm -f arch/riscv/purgatory/kexec-purgatory.c
rm -f scripts/extract-cert rm -f scripts/extract-cert
rm -f arch/x86/purgatory/kexec-purgatory.c rm -f arch/x86/purgatory/kexec-purgatory.c
rm -f scripts/kconfig/[gmnq]conf-cfg