Kbuild updates for v5.1

- do not generate unneeded top-level built-in.a
 
  - let git ignore O= directory entirely
 
  - optimize scripts/kallsyms slightly
 
  - exclude DWARF info from *.s regardless of config options
 
  - fix GCC toolchain search path for Clang to prepare ld.lld support
 
  - do not generate modules.order when CONFIG_MODULES is disabled
 
  - simplify single target rules and remove VPATH for external module build
 
  - allow to add optional flags to dpkg-buildpackage when building deb-pkg
 
  - move some compiler option tests from Makefile to Kconfig
 
  - various Makefile cleanups
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJcgxYUAAoJED2LAQed4NsGr7YQAJq4LmN/aZDI9Mt0YAQjEyyA
 PCpm8J2HI9HO1sMoY7J/ksWmV0BU25G+uspKD7dXAQo3l9fmahQM5e4dsyZ4Xqs8
 DyyYSGtJJnMJaWmupIZNA4UKDCVtwPoVW8YeuK9rwADVokCux9avogof9O1OoA/E
 Pylo+I4UCM82kbpZSd+UxnCx6B0v8XGtW+d31Q4yZXCkw5nw14chrlaprcqB3UgB
 +7C3xOnDWCi7gyxaTqmD7dLay2DM8KCDlznEvBL733Y/cK3to1fywzEPzp0JQCLX
 BLgmmpW13NF++q5BCoTW6sFjZAhBVbiYZwesMrCi75Y32T8zt4G5l4pkvGkSuGF/
 UQh5aoCxaMIp70VPj/loZ0lh78nwVGTok9zRb0rfztM0X4DbmiPi5MNiHRzRpIeE
 1jjEa/GK1t0TDnXc/MuDFK8cWwdhttIqUL5yWfAxjXbtP27eLtsopQUdW7EPHs7d
 sMnfuSUuhOC28yByVxIkBcwawLyYrcWRphJ3ixCO70CoJWt2DT6aOKxcFJefoJix
 Pto6Oo3oQ4iypMM5M9/0Uo+AK2TKRejWIqtZdbo+ir70tNxVH3WDZq++fG0drXOB
 r2I/GY6nRjuzLOe2jzEqywFTFd2xpk4Qo84LGb1R3U6aU5qS2gA0W/q00JS5c2qU
 R8uReJ7bvmLmrVNZ/NI4
 =y9YG
 -----END PGP SIGNATURE-----

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

Pull Kbuild updates from Masahiro Yamada:

 - do not generate unneeded top-level built-in.a

 - let git ignore O= directory entirely

 - optimize scripts/kallsyms slightly

 - exclude DWARF info from *.s regardless of config options

 - fix GCC toolchain search path for Clang to prepare ld.lld support

 - do not generate modules.order when CONFIG_MODULES is disabled

 - simplify single target rules and remove VPATH for external module
   build

 - allow to add optional flags to dpkg-buildpackage when building
   deb-pkg

 - move some compiler option tests from Makefile to Kconfig

 - various Makefile cleanups

* tag 'kbuild-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (40 commits)
  kbuild: remove scripts/basic/% build target
  kbuild: use -Werror=implicit-... instead of -Werror-implicit-...
  kbuild: clean up scripts/gcc-version.sh
  kbuild: remove cc-version macro
  kbuild: update comment block of scripts/clang-version.sh
  kbuild: remove commented-out INITRD_COMPRESS
  kbuild: move -gsplit-dwarf, -gdwarf-4 option tests to Kconfig
  kbuild: [bin]deb-pkg: add DPKG_FLAGS variable
  kbuild: move ".config not found!" message from Kconfig to Makefile
  kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing
  kbuild: simplify single target rules
  kbuild: remove empty rules for makefiles
  kbuild: make -r/-R effective in top Makefile for old Make versions
  kbuild: move tools_silent to a more relevant place
  kbuild: compute false-positive -Wmaybe-uninitialized cases in Kconfig
  kbuild: refactor cc-cross-prefix implementation
  kbuild: hardcode genksyms path and remove GENKSYMS variable
  scripts/gdb: refactor rules for symlink creation
  kbuild: create symlink to vmlinux-gdb.py in scripts_gdb target
  scripts/gdb: do not descend into scripts/gdb from scripts
  ...
This commit is contained in:
Linus Torvalds 2019-03-10 17:48:21 -07:00
commit ffd602eb46
33 changed files with 262 additions and 362 deletions

View File

@ -15,7 +15,7 @@ DT_TMP_SCHEMA := processed-schema.yaml
extra-y += $(DT_TMP_SCHEMA) extra-y += $(DT_TMP_SCHEMA)
quiet_cmd_mk_schema = SCHEMA $@ quiet_cmd_mk_schema = SCHEMA $@
cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(filter-out FORCE, $^) cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(real-prereqs)
DT_DOCS = $(shell \ DT_DOCS = $(shell \
cd $(srctree)/$(src) && \ cd $(srctree)/$(src) && \

View File

@ -232,17 +232,12 @@ KBUILD_LDS
-------------------------------------------------- --------------------------------------------------
The linker script with full path. Assigned by the top-level Makefile. The linker script with full path. Assigned by the top-level Makefile.
KBUILD_VMLINUX_INIT KBUILD_VMLINUX_OBJS
-------------------------------------------------- --------------------------------------------------
All object files for the init (first) part of vmlinux. All object files for vmlinux. They are linked to vmlinux in the same
Files specified with KBUILD_VMLINUX_INIT are linked first. order as listed in KBUILD_VMLINUX_OBJS.
KBUILD_VMLINUX_MAIN
--------------------------------------------------
All object files for the main part of vmlinux.
KBUILD_VMLINUX_LIBS KBUILD_VMLINUX_LIBS
-------------------------------------------------- --------------------------------------------------
All .a "lib" files for vmlinux. All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS
KBUILD_VMLINUX_INIT, KBUILD_VMLINUX_MAIN, and KBUILD_VMLINUX_LIBS together together specify all the object files used to link vmlinux.
specify all the object files used to link vmlinux.

View File

@ -154,13 +154,8 @@ more details, with real examples.
Kbuild compiles all the $(obj-y) files. It then calls Kbuild compiles all the $(obj-y) files. It then calls
"$(AR) rcSTP" to merge these files into one built-in.a file. "$(AR) rcSTP" to merge these files into one built-in.a file.
This is a thin archive without a symbol table, which makes it This is a thin archive without a symbol table. It will be later
unsuitable as a linker input. linked into vmlinux by scripts/link-vmlinux.sh
The scripts/link-vmlinux.sh script later makes an aggregate
built-in.a with "${AR} rcsTP", which creates the thin archive
with a symbol table and an index, making it a valid input for
the final vmlinux link passes.
The order of files in $(obj-y) is significant. Duplicates in The order of files in $(obj-y) is significant. Duplicates in
the lists are allowed: the first instance will be linked into the lists are allowed: the first instance will be linked into
@ -504,23 +499,6 @@ more details, with real examples.
In the above example, -Wno-unused-but-set-variable will be added to In the above example, -Wno-unused-but-set-variable will be added to
KBUILD_CFLAGS only if gcc really accepts it. KBUILD_CFLAGS only if gcc really accepts it.
cc-version
cc-version returns a numerical version of the $(CC) compiler version.
The format is <major><minor> where both are two digits. So for example
gcc 3.41 would return 0341.
cc-version is useful when a specific $(CC) version is faulty in one
area, for example -mregparm=3 was broken in some gcc versions
even though the option was accepted by gcc.
Example:
#arch/x86/Makefile
cflags-y += $(shell \
if [ $(cc-version) -ge 0300 ] ; then \
echo "-mregparm=3"; fi ;)
In the above example, -mregparm=3 is only used for gcc version greater
than or equal to gcc 3.0.
cc-ifversion cc-ifversion
cc-ifversion tests the version of $(CC) and equals the fourth parameter cc-ifversion tests the version of $(CC) and equals the fourth parameter
if version expression is true, or the fifth (if given) if the version if version expression is true, or the fifth (if given) if the version

View File

@ -140,7 +140,7 @@ executed to make module versioning work.
make -C $KDIR M=$PWD bar.lst make -C $KDIR M=$PWD bar.lst
make -C $KDIR M=$PWD baz.o make -C $KDIR M=$PWD baz.o
make -C $KDIR M=$PWD foo.ko make -C $KDIR M=$PWD foo.ko
make -C $KDIR M=$PWD / make -C $KDIR M=$PWD ./
=== 3. Creating a Kbuild File for an External Module === 3. Creating a Kbuild File for an External Module

29
Kbuild
View File

@ -1,16 +1,9 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# #
# Kbuild for top-level directory of the kernel # Kbuild for top-level directory of the kernel
# This file takes care of the following:
# 1) Generate bounds.h
# 2) Generate timeconst.h
# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
# 4) Check for missing system calls
# 5) check atomics headers are up-to-date
# 6) Generate constants.py (may need bounds.h)
##### #####
# 1) Generate bounds.h # Generate bounds.h
bounds-file := include/generated/bounds.h bounds-file := include/generated/bounds.h
@ -21,7 +14,7 @@ $(bounds-file): kernel/bounds.s FORCE
$(call filechk,offsets,__LINUX_BOUNDS_H__) $(call filechk,offsets,__LINUX_BOUNDS_H__)
##### #####
# 2) Generate timeconst.h # Generate timeconst.h
timeconst-file := include/generated/timeconst.h timeconst-file := include/generated/timeconst.h
@ -33,8 +26,7 @@ $(timeconst-file): kernel/time/timeconst.bc FORCE
$(call filechk,gentimeconst) $(call filechk,gentimeconst)
##### #####
# 3) Generate asm-offsets.h # Generate asm-offsets.h
#
offsets-file := include/generated/asm-offsets.h offsets-file := include/generated/asm-offsets.h
@ -47,8 +39,7 @@ $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
$(call filechk,offsets,__ASM_OFFSETS_H__) $(call filechk,offsets,__ASM_OFFSETS_H__)
##### #####
# 4) Check for missing system calls # Check for missing system calls
#
always += missing-syscalls always += missing-syscalls
targets += missing-syscalls targets += missing-syscalls
@ -60,8 +51,7 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
$(call cmd,syscalls) $(call cmd,syscalls)
##### #####
# 5) Check atomic headers are up-to-date # Check atomic headers are up-to-date
#
always += old-atomics always += old-atomics
targets += old-atomics targets += old-atomics
@ -72,14 +62,5 @@ quiet_cmd_atomics = CALL $<
old-atomics: scripts/atomic/check-atomics.sh FORCE old-atomics: scripts/atomic/check-atomics.sh FORCE
$(call cmd,atomics) $(call cmd,atomics)
#####
# 6) Generate constants for Python GDB integration
#
extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
build_constants_py: $(timeconst-file) $(bounds-file)
@$(MAKE) $(build)=scripts/gdb/linux $@
# Keep these three files during make clean # Keep these three files during make clean
no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file) no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)

217
Makefile
View File

@ -15,19 +15,6 @@ NAME = Shy Crocodile
PHONY := _all PHONY := _all
_all: _all:
# Do not use make's built-in rules and variables
# (this increases performance and avoids hard-to-debug behaviour)
MAKEFLAGS += -rR
# Avoid funny character set dependencies
unexport LC_ALL
LC_COLLATE=C
LC_NUMERIC=C
export LC_COLLATE LC_NUMERIC
# Avoid interference with shell env settings
unexport GREP_OPTIONS
# We are using a recursive build, so we need to do a little thinking # We are using a recursive build, so we need to do a little thinking
# to get the ordering right. # to get the ordering right.
# #
@ -44,6 +31,25 @@ unexport GREP_OPTIONS
# descending is started. They are now explicitly listed as the # descending is started. They are now explicitly listed as the
# prepare rule. # prepare rule.
ifneq ($(sub-make-done),1)
# Do not use make's built-in rules and variables
# (this increases performance and avoids hard-to-debug behaviour)
MAKEFLAGS += -rR
# 'MAKEFLAGS += -rR' does not become immediately effective for old
# GNU Make versions. Cancel implicit rules for this Makefile.
$(lastword $(MAKEFILE_LIST)): ;
# Avoid funny character set dependencies
unexport LC_ALL
LC_COLLATE=C
LC_NUMERIC=C
export LC_COLLATE LC_NUMERIC
# Avoid interference with shell env settings
unexport GREP_OPTIONS
# Beautify output # Beautify output
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# #
@ -90,7 +96,6 @@ endif
ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
quiet=silent_ quiet=silent_
tools_silent=s
endif endif
export quiet Q KBUILD_VERBOSE export quiet Q KBUILD_VERBOSE
@ -112,7 +117,6 @@ export quiet Q KBUILD_VERBOSE
# KBUILD_SRC is not intended to be used by the regular user (for now), # KBUILD_SRC is not intended to be used by the regular user (for now),
# it is set on invocation of make with KBUILD_OUTPUT or O= specified. # it is set on invocation of make with KBUILD_OUTPUT or O= specified.
ifeq ($(KBUILD_SRC),)
# OK, Make called in directory where kernel src resides # OK, Make called in directory where kernel src resides
# Do we want to locate output files in a separate directory? # Do we want to locate output files in a separate directory?
@ -120,9 +124,6 @@ ifeq ("$(origin O)", "command line")
KBUILD_OUTPUT := $(O) KBUILD_OUTPUT := $(O)
endif endif
# Cancel implicit rules on top Makefile
$(CURDIR)/Makefile Makefile: ;
ifneq ($(words $(subst :, ,$(CURDIR))), 1) ifneq ($(words $(subst :, ,$(CURDIR))), 1)
$(error main directory cannot contain spaces nor colons) $(error main directory cannot contain spaces nor colons)
endif endif
@ -142,6 +143,13 @@ $(if $(KBUILD_OUTPUT),, \
# 'sub-make' below. # 'sub-make' below.
MAKEFLAGS += --include-dir=$(CURDIR) MAKEFLAGS += --include-dir=$(CURDIR)
else
# Do not print "Entering directory ..." at all for in-tree build.
MAKEFLAGS += --no-print-directory
endif # ifneq ($(KBUILD_OUTPUT),)
PHONY += $(MAKECMDGOALS) sub-make PHONY += $(MAKECMDGOALS) sub-make
$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
@ -149,16 +157,12 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
# Invoke a second make in the output directory, passing relevant variables # Invoke a second make in the output directory, passing relevant variables
sub-make: sub-make:
$(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ $(Q)$(MAKE) sub-make-done=1 \
$(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \
-f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
# Leave processing to above invocation of make else # sub-make-done
skip-makefile := 1
endif # ifneq ($(KBUILD_OUTPUT),)
endif # ifeq ($(KBUILD_SRC),)
# We process the rest of the Makefile if this is the final invocation of make # We process the rest of the Makefile if this is the final invocation of make
ifeq ($(skip-makefile),)
# Do not print "Entering directory ...", # Do not print "Entering directory ...",
# but we want to display it when entering to the output directory # but we want to display it when entering to the output directory
@ -215,7 +219,7 @@ objtree := .
src := $(srctree) src := $(srctree)
obj := $(objtree) obj := $(objtree)
VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) VPATH := $(srctree)
export srctree objtree VPATH export srctree objtree VPATH
@ -300,8 +304,6 @@ __build_one_by_one:
else else
# We need some generic definitions (do not try to remake the file).
scripts/Kbuild.include: ;
include scripts/Kbuild.include include scripts/Kbuild.include
# Read KERNELRELEASE from include/config/kernel.release (if it exists) # Read KERNELRELEASE from include/config/kernel.release (if it exists)
@ -390,7 +392,6 @@ OBJDUMP = $(CROSS_COMPILE)objdump
LEX = flex LEX = flex
YACC = bison YACC = bison
AWK = awk AWK = awk
GENKSYMS = scripts/genksyms/genksyms
INSTALLKERNEL := installkernel INSTALLKERNEL := installkernel
DEPMOD = /sbin/depmod DEPMOD = /sbin/depmod
PERL = perl PERL = perl
@ -429,7 +430,7 @@ LINUXINCLUDE := \
KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
-Werror-implicit-function-declaration -Werror=implicit-int \ -Werror=implicit-function-declaration -Werror=implicit-int \
-Wno-format-security \ -Wno-format-security \
-std=gnu89 -std=gnu89
KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_CPPFLAGS := -D__KERNEL__
@ -443,7 +444,7 @@ GCC_PLUGINS_CFLAGS :=
export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS export CPP AR NM STRIP OBJCOPY OBJDUMP KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS
export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE export MAKE LEX YACC AWK INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE
export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
@ -476,23 +477,23 @@ scripts_basic:
$(Q)$(MAKE) $(build)=scripts/basic $(Q)$(MAKE) $(build)=scripts/basic
$(Q)rm -f .tmp_quiet_recordmcount $(Q)rm -f .tmp_quiet_recordmcount
# To avoid any implicit rule to kick in, define an empty command.
scripts/basic/%: scripts_basic ;
PHONY += outputmakefile PHONY += outputmakefile
# outputmakefile generates a Makefile in the output directory, if using a # outputmakefile generates a Makefile in the output directory, if using a
# separate output directory. This allows convenient use of make in the # separate output directory. This allows convenient use of make in the
# output directory. # output directory.
# At the same time when output Makefile generated, generate .gitignore to
# ignore whole output directory
outputmakefile: outputmakefile:
ifneq ($(KBUILD_SRC),) ifneq ($(KBUILD_SRC),)
$(Q)ln -fsn $(srctree) source $(Q)ln -fsn $(srctree) source
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
$(Q){ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
endif endif
ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
ifneq ($(CROSS_COMPILE),) ifneq ($(CROSS_COMPILE),)
CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD))) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
endif endif
@ -624,13 +625,22 @@ ifeq ($(may-sync-config),1)
# because some architectures define CROSS_COMPILE there. # because some architectures define CROSS_COMPILE there.
-include include/config/auto.conf.cmd -include include/config/auto.conf.cmd
# To avoid any implicit rule to kick in, define an empty command $(KCONFIG_CONFIG):
$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; @echo >&2 '***'
@echo >&2 '*** Configuration file "$@" not found!'
@echo >&2 '***'
@echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or'
@echo >&2 '*** "make menuconfig" or "make xconfig").'
@echo >&2 '***'
@/bin/false
# The actual configuration files used during the build are stored in # The actual configuration files used during the build are stored in
# include/generated/ and include/config/. Update them if .config is newer than # include/generated/ and include/config/. Update them if .config is newer than
# include/config/auto.conf (which mirrors .config). # include/config/auto.conf (which mirrors .config).
include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd #
# This exploits the 'multi-target pattern rule' trick.
# The syncconfig should be executed only once to make all the targets.
%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
else else
# External modules and some install targets need include/generated/autoconf.h # External modules and some install targets need include/generated/autoconf.h
@ -658,17 +668,13 @@ KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) KBUILD_CFLAGS += $(call cc-option,-Oz,-Os)
KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
else
ifdef CONFIG_PROFILE_ALL_BRANCHES
KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
else else
KBUILD_CFLAGS += -O2 KBUILD_CFLAGS += -O2
endif endif
endif
KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED
$(call cc-disable-warning,maybe-uninitialized,)) KBUILD_CFLAGS += -Wno-maybe-uninitialized
endif
# Tell gcc to never replace conditional load with a non-conditional one # Tell gcc to never replace conditional load with a non-conditional one
KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
@ -729,25 +735,28 @@ KBUILD_CFLAGS += -fomit-frame-pointer
endif endif
endif endif
KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments)
ifdef CONFIG_DEBUG_INFO ifdef CONFIG_DEBUG_INFO
ifdef CONFIG_DEBUG_INFO_SPLIT ifdef CONFIG_DEBUG_INFO_SPLIT
KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) DEBUG_CFLAGS += -gsplit-dwarf
else else
KBUILD_CFLAGS += -g DEBUG_CFLAGS += -g
endif endif
KBUILD_AFLAGS += -Wa,-gdwarf-2 KBUILD_AFLAGS += -Wa,-gdwarf-2
endif endif
ifdef CONFIG_DEBUG_INFO_DWARF4 ifdef CONFIG_DEBUG_INFO_DWARF4
KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,) DEBUG_CFLAGS += -gdwarf-4
endif endif
ifdef CONFIG_DEBUG_INFO_REDUCED ifdef CONFIG_DEBUG_INFO_REDUCED
KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
$(call cc-option,-fno-var-tracking) $(call cc-option,-fno-var-tracking)
endif endif
KBUILD_CFLAGS += $(DEBUG_CFLAGS)
export DEBUG_CFLAGS
ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_FUNCTION_TRACER
ifdef CONFIG_FTRACE_MCOUNT_RECORD ifdef CONFIG_FTRACE_MCOUNT_RECORD
# gcc 5 supports generating the mcount tables directly # gcc 5 supports generating the mcount tables directly
@ -922,19 +931,6 @@ ifdef CONFIG_MODULE_COMPRESS
endif # CONFIG_MODULE_COMPRESS endif # CONFIG_MODULE_COMPRESS
export mod_compress_cmd export mod_compress_cmd
# Select initial ramdisk compression format, default is gzip(1).
# This shall be used by the dracut(8) tool while creating an initramfs image.
#
INITRD_COMPRESS-y := gzip
INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2
INITRD_COMPRESS-$(CONFIG_RD_LZMA) := lzma
INITRD_COMPRESS-$(CONFIG_RD_XZ) := xz
INITRD_COMPRESS-$(CONFIG_RD_LZO) := lzo
INITRD_COMPRESS-$(CONFIG_RD_LZ4) := lz4
# do not export INITRD_COMPRESS, since we didn't actually
# choose a sane default compression above.
# export INITRD_COMPRESS := $(INITRD_COMPRESS-y)
ifdef CONFIG_MODULE_SIG_ALL ifdef CONFIG_MODULE_SIG_ALL
$(eval $(call config_filename,MODULE_SIG_KEY)) $(eval $(call config_filename,MODULE_SIG_KEY))
@ -976,15 +972,15 @@ libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y)))
virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) virt-y := $(patsubst %/, %/built-in.a, $(virt-y))
# Externally visible symbols (used by link-vmlinux.sh) # Externally visible symbols (used by link-vmlinux.sh)
export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \
export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y) $(drivers-y) $(net-y) $(virt-y)
export KBUILD_VMLINUX_LIBS := $(libs-y1) export KBUILD_VMLINUX_LIBS := $(libs-y1)
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
export LDFLAGS_vmlinux export LDFLAGS_vmlinux
# used by scripts/package/Makefile # used by scripts/package/Makefile
export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools)
vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
# Recurse until adjust_autoksyms.sh is satisfied # Recurse until adjust_autoksyms.sh is satisfied
PHONY += autoksyms_recursive PHONY += autoksyms_recursive
@ -1015,9 +1011,6 @@ cmd_link-vmlinux = \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
ifdef CONFIG_GDB_SCRIPTS
$(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
endif
+$(call if_changed,link-vmlinux) +$(call if_changed,link-vmlinux)
targets := vmlinux targets := vmlinux
@ -1062,7 +1055,7 @@ scripts: scripts_basic scripts_dtc
# archprepare is used in arch Makefiles and when processed asm symlink, # archprepare is used in arch Makefiles and when processed asm symlink,
# version.h and scripts_basic is processed / created. # version.h and scripts_basic is processed / created.
PHONY += prepare archprepare prepare1 prepare2 prepare3 PHONY += prepare archprepare prepare1 prepare3
# prepare3 is used to check if we are building in a separate output directory, # prepare3 is used to check if we are building in a separate output directory,
# and if so do: # and if so do:
@ -1077,12 +1070,8 @@ ifneq ($(KBUILD_SRC),)
fi; fi;
endif endif
# prepare2 creates a makefile if using a separate output directory. prepare1: prepare3 outputmakefile asm-generic $(version_h) $(autoksyms_h) \
# From this point forward, .config has been reprocessed, so any rules include/generated/utsrelease.h
# that need to depend on updated CONFIG_* values can be checked here.
prepare2: prepare3 outputmakefile asm-generic
prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h
$(cmd_crmodverdir) $(cmd_crmodverdir)
archprepare: archheaders archscripts prepare1 scripts archprepare: archheaders archscripts prepare1 scripts
@ -1517,6 +1506,18 @@ PHONY += $(DOC_TARGETS)
$(DOC_TARGETS): scripts_basic FORCE $(DOC_TARGETS): scripts_basic FORCE
$(Q)$(MAKE) $(build)=Documentation $@ $(Q)$(MAKE) $(build)=Documentation $@
# Misc
# ---------------------------------------------------------------------------
PHONY += scripts_gdb
scripts_gdb: prepare
$(Q)$(MAKE) $(build)=scripts/gdb
$(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
ifdef CONFIG_GDB_SCRIPTS
all: scripts_gdb
endif
else # KBUILD_EXTMOD else # KBUILD_EXTMOD
### ###
@ -1668,6 +1669,11 @@ image_name:
@echo $(KBUILD_IMAGE) @echo $(KBUILD_IMAGE)
# Clear a bunch of variables before executing the submake # Clear a bunch of variables before executing the submake
ifeq ($(quiet),silent_)
tools_silent=s
endif
tools/: FORCE tools/: FORCE
$(Q)mkdir -p $(objtree)/tools $(Q)mkdir -p $(objtree)/tools
$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/
@ -1686,45 +1692,32 @@ tools/%: FORCE
# target-dir => where to store outputfile # target-dir => where to store outputfile
# build-dir => directory in kernel source tree to use # build-dir => directory in kernel source tree to use
ifeq ($(KBUILD_EXTMOD),) build-target = $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD)/)$@
build-dir = $(patsubst %/,%,$(dir $@)) build-dir = $(patsubst %/,%,$(dir $(build-target)))
target-dir = $(dir $@)
else
zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
endif
%.s: %.c prepare FORCE %.i: prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
%.i: %.c prepare FORCE %.ll: prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
%.o: %.c prepare FORCE %.lst: prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
%.lst: %.c prepare FORCE %.o: prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
%.s: %.S prepare FORCE %.s: prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
%.o: %.S prepare FORCE %.symtypes: prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
%.symtypes: %.c prepare FORCE %.ko: %.o
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
%.ll: %.c prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
# Modules # Modules
/: prepare FORCE PHONY += /
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ /: ./
$(build)=$(build-dir)
# Make sure the latest headers are built for Documentation # Make sure the latest headers are built for Documentation
Documentation/ samples/: headers_install Documentation/ samples/: headers_install
%/: prepare FORCE %/: prepare FORCE
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir)
$(build)=$(build-dir)
%.ko: prepare FORCE
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir) $(@:.ko=.o)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
# FIXME Should go into a make.lib or something # FIXME Should go into a make.lib or something
# =========================================================================== # ===========================================================================
@ -1748,13 +1741,11 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \
# read saved command lines for existing targets # read saved command lines for existing targets
existing-targets := $(wildcard $(sort $(targets))) existing-targets := $(wildcard $(sort $(targets)))
cmd_files := $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
$(cmd_files): ; # Do not try to update included dependency files
-include $(cmd_files)
endif # ifeq ($(config-targets),1) endif # ifeq ($(config-targets),1)
endif # ifeq ($(mixed-targets),1) endif # ifeq ($(mixed-targets),1)
endif # skip-makefile endif # sub-make-done
PHONY += FORCE PHONY += FORCE
FORCE: FORCE:

View File

@ -115,7 +115,7 @@ endif
targets += vmlinux.its.S targets += vmlinux.its.S
quiet_cmd_its_cat = CAT $@ quiet_cmd_its_cat = CAT $@
cmd_its_cat = cat $(filter-out $(PHONY), $^) >$@ cmd_its_cat = cat $(real-prereqs) >$@
$(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE $(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE
$(call if_changed,its_cat) $(call if_changed,its_cat)

View File

@ -218,7 +218,7 @@ quiet_cmd_bootas = BOOTAS $@
cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
quiet_cmd_bootar = BOOTAR $@ quiet_cmd_bootar = BOOTAR $@
cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(real-prereqs); mv $@.$$$$ $@
$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE $(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
$(call if_changed_dep,bootcc) $(call if_changed_dep,bootcc)

View File

@ -58,7 +58,7 @@ $(obj)/compressed/vmlinux: $(obj)/startup.a FORCE
$(Q)$(MAKE) $(build)=$(obj)/compressed $@ $(Q)$(MAKE) $(build)=$(obj)/compressed $@
quiet_cmd_ar = AR $@ quiet_cmd_ar = AR $@
cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(filter $(OBJECTS), $^) cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
$(obj)/startup.a: $(OBJECTS) FORCE $(obj)/startup.a: $(OBJECTS) FORCE
$(call if_changed,ar) $(call if_changed,ar)
@ -67,6 +67,6 @@ install: $(CONFIGURE) $(obj)/bzImage
sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \ sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
System.map "$(INSTALL_PATH)" System.map "$(INSTALL_PATH)"
chkbss := $(OBJECTS) chkbss := $(obj-y)
chkbss-target := $(obj)/startup.a chkbss-target := startup.a
include $(srctree)/arch/s390/scripts/Makefile.chkbss include $(srctree)/arch/s390/scripts/Makefile.chkbss

View File

@ -63,6 +63,6 @@ OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section
$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE $(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
$(call if_changed,objcopy) $(call if_changed,objcopy)
chkbss := $(filter-out $(obj)/piggy.o $(obj)/info.o,$(OBJECTS)) chkbss := $(filter-out piggy.o info.o, $(obj-y))
chkbss-target := $(obj)/vmlinux.bin chkbss-target := vmlinux.bin
include $(srctree)/arch/s390/scripts/Makefile.chkbss include $(srctree)/arch/s390/scripts/Makefile.chkbss

View File

@ -1,23 +1,20 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
chkbss-target ?= built-in.a
$(obj)/$(chkbss-target): chkbss
chkbss-files := $(addsuffix .chkbss, $(chkbss))
clean-files += $(chkbss-files)
PHONY += chkbss
chkbss: $(addprefix $(obj)/, $(chkbss-files))
quiet_cmd_chkbss = CHKBSS $< quiet_cmd_chkbss = CHKBSS $<
define cmd_chkbss cmd_chkbss = \
rm -f $@; \
if ! $(OBJDUMP) -j .bss -w -h $< | awk 'END { if ($$3) exit 1 }'; then \ if ! $(OBJDUMP) -j .bss -w -h $< | awk 'END { if ($$3) exit 1 }'; then \
echo "error: $< .bss section is not empty" >&2; exit 1; \ echo "error: $< .bss section is not empty" >&2; exit 1; \
fi; \ fi; \
touch $@; touch $@;
endef
chkbss-target ?= $(obj)/built-in.a $(obj)/%.o.chkbss: $(obj)/%.o
ifneq (,$(findstring /,$(chkbss)))
chkbss-files := $(patsubst %, %.chkbss, $(chkbss))
else
chkbss-files := $(patsubst %, $(obj)/%.chkbss, $(chkbss))
endif
$(chkbss-target): $(chkbss-files)
targets += $(notdir $(chkbss-files))
%.o.chkbss: %.o
$(call cmd,chkbss) $(call cmd,chkbss)

View File

@ -37,8 +37,7 @@ REALMODE_OBJS = $(addprefix $(obj)/,$(realmode-y))
sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p' sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p'
quiet_cmd_pasyms = PASYMS $@ quiet_cmd_pasyms = PASYMS $@
cmd_pasyms = $(NM) $(filter-out FORCE,$^) | \ cmd_pasyms = $(NM) $(real-prereqs) | sed $(sed-pasyms) | sort | uniq > $@
sed $(sed-pasyms) | sort | uniq > $@
targets += pasyms.h targets += pasyms.h
$(obj)/pasyms.h: $(REALMODE_OBJS) FORCE $(obj)/pasyms.h: $(REALMODE_OBJS) FORCE

View File

@ -13,7 +13,7 @@ config CC_IS_GCC
config GCC_VERSION config GCC_VERSION
int int
default $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') if CC_IS_GCC default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC
default 0 default 0
config CC_IS_CLANG config CC_IS_CLANG
@ -26,6 +26,22 @@ config CLANG_VERSION
config CC_HAS_ASM_GOTO config CC_HAS_ASM_GOTO
def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
config CC_HAS_WARN_MAYBE_UNINITIALIZED
def_bool $(cc-option,-Wmaybe-uninitialized)
help
GCC >= 4.7 supports this option.
config CC_DISABLE_WARN_MAYBE_UNINITIALIZED
bool
depends on CC_HAS_WARN_MAYBE_UNINITIALIZED
default CC_IS_GCC && GCC_VERSION < 40900 # unreliable for GCC < 4.9
help
GCC's -Wmaybe-uninitialized is not reliable by definition.
Lots of false positive warnings are produced in some cases.
If this option is enabled, -Wno-maybe-uninitialzed is passed
to the compiler to suppress maybe-uninitialized warnings.
config CONSTRUCTORS config CONSTRUCTORS
bool bool
depends on !UML depends on !UML
@ -1114,6 +1130,7 @@ config CC_OPTIMIZE_FOR_PERFORMANCE
config CC_OPTIMIZE_FOR_SIZE config CC_OPTIMIZE_FOR_SIZE
bool "Optimize for size" bool "Optimize for size"
imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
help help
Enabling this option will pass "-Os" instead of "-O2" to Enabling this option will pass "-Os" instead of "-O2" to
your compiler resulting in a smaller kernel. your compiler resulting in a smaller kernel.

View File

@ -370,6 +370,7 @@ config PROFILE_ANNOTATED_BRANCHES
config PROFILE_ALL_BRANCHES config PROFILE_ALL_BRANCHES
bool "Profile all if conditionals" if !FORTIFY_SOURCE bool "Profile all if conditionals" if !FORTIFY_SOURCE
select TRACE_BRANCH_PROFILING select TRACE_BRANCH_PROFILING
imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
help help
This tracer profiles all branch conditions. Every if () This tracer profiles all branch conditions. Every if ()
taken in the kernel is recorded whether it hit or miss. taken in the kernel is recorded whether it hit or miss.

View File

@ -196,6 +196,7 @@ config DEBUG_INFO_REDUCED
config DEBUG_INFO_SPLIT config DEBUG_INFO_SPLIT
bool "Produce split debuginfo in .dwo files" bool "Produce split debuginfo in .dwo files"
depends on DEBUG_INFO depends on DEBUG_INFO
depends on $(cc-option,-gsplit-dwarf)
help help
Generate debug info into separate .dwo files. This significantly Generate debug info into separate .dwo files. This significantly
reduces the build directory size for builds with DEBUG_INFO, reduces the build directory size for builds with DEBUG_INFO,
@ -211,6 +212,7 @@ config DEBUG_INFO_SPLIT
config DEBUG_INFO_DWARF4 config DEBUG_INFO_DWARF4
bool "Generate dwarf4 debuginfo" bool "Generate dwarf4 debuginfo"
depends on DEBUG_INFO depends on DEBUG_INFO
depends on $(cc-option,-gdwarf-4)
help help
Generate dwarf4 debug info. This requires recent versions Generate dwarf4 debug info. This requires recent versions
of gcc and gdb. It makes the debug information larger. of gcc and gdb. It makes the debug information larger.

View File

@ -23,6 +23,10 @@ depfile = $(subst $(comma),_,$(dot-target).d)
# filename of target with directory and extension stripped # filename of target with directory and extension stripped
basetarget = $(basename $(notdir $@)) basetarget = $(basename $(notdir $@))
###
# real prerequisites without phony targets
real-prereqs = $(filter-out $(PHONY), $^)
### ###
# Escape single quote for use in echo statements # Escape single quote for use in echo statements
escsq = $(subst $(squote),'\$(squote)',$1) escsq = $(subst $(squote),'\$(squote)',$1)
@ -67,14 +71,10 @@ endef
# cc-cross-prefix # cc-cross-prefix
# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
# Return first prefix where a prefix$(CC) is found in PATH. # Return first <prefix> where a <prefix>gcc is found in PATH.
# If no $(CC) found in PATH with listed prefixes return nothing # If no gcc found in PATH with listed prefixes return nothing
cc-cross-prefix = \ cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \
$(word 1, $(foreach c,$(1), \ $(if $(shell which $(c)gcc), $(c))))
$(shell set -e; \
if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \
echo $(c); \
fi)))
# output directory for tests below # output directory for tests below
TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
@ -134,12 +134,9 @@ cc-option-yn = $(call try-run,\
cc-disable-warning = $(call try-run,\ cc-disable-warning = $(call try-run,\
$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
# cc-version
cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
# cc-ifversion # cc-ifversion
# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)) cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))
# cc-ldoption # cc-ldoption
# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)

View File

@ -27,4 +27,4 @@ cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null)
ld-option = $(success,$(LD) -v $(1)) ld-option = $(success,$(LD) -v $(1))
# gcc version including patch level # gcc version including patch level
gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))

View File

@ -39,7 +39,6 @@ build_unifdef: $(obj)/unifdef
subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins
subdir-$(CONFIG_MODVERSIONS) += genksyms subdir-$(CONFIG_MODVERSIONS) += genksyms
subdir-$(CONFIG_SECURITY_SELINUX) += selinux subdir-$(CONFIG_SECURITY_SELINUX) += selinux
subdir-$(CONFIG_GDB_SCRIPTS) += gdb
# Let clean descend into subdirs # Let clean descend into subdirs
subdir- += basic dtc kconfig mod package subdir- += basic dtc gdb kconfig mod package

View File

@ -63,7 +63,9 @@ ifneq ($(strip $(real-obj-y) $(need-builtin)),)
builtin-target := $(obj)/built-in.a builtin-target := $(obj)/built-in.a
endif endif
ifdef CONFIG_MODULES
modorder-target := $(obj)/modules.order modorder-target := $(obj)/modules.order
endif
# We keep a list of all modules in $(MODVERDIR) # We keep a list of all modules in $(MODVERDIR)
@ -104,7 +106,7 @@ modkern_cflags = \
quiet_modtag = $(if $(part-of-module),[M], ) quiet_modtag = $(if $(part-of-module),[M], )
quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
$(obj)/%.s: $(src)/%.c FORCE $(obj)/%.s: $(src)/%.c FORCE
$(call if_changed_dep,cc_s_c) $(call if_changed_dep,cc_s_c)
@ -118,7 +120,7 @@ $(obj)/%.i: $(src)/%.c FORCE
# These mirror gensymtypes_S and co below, keep them in synch. # These mirror gensymtypes_S and co below, keep them in synch.
cmd_gensymtypes_c = \ cmd_gensymtypes_c = \
$(CPP) -D__GENKSYMS__ $(c_flags) $< | \ $(CPP) -D__GENKSYMS__ $(c_flags) $< | \
$(GENKSYMS) $(if $(1), -T $(2)) \ scripts/genksyms/genksyms $(if $(1), -T $(2)) \
$(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \
$(if $(KBUILD_PRESERVE),-p) \ $(if $(KBUILD_PRESERVE),-p) \
-r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
@ -312,13 +314,13 @@ $(real-obj-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
# #
# These mirror gensymtypes_c and co above, keep them in synch. # These mirror gensymtypes_c and co above, keep them in synch.
cmd_gensymtypes_S = \ cmd_gensymtypes_S = \
(echo "\#include <linux/kernel.h>" ; \ { echo "\#include <linux/kernel.h>" ; \
echo "\#include <asm/asm-prototypes.h>" ; \ echo "\#include <asm/asm-prototypes.h>" ; \
$(CPP) $(a_flags) $< | \ $(CPP) $(a_flags) $< | \
grep "\<___EXPORT_SYMBOL\>" | \ grep "\<___EXPORT_SYMBOL\>" | \
sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ) | \ sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \
$(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \
$(GENKSYMS) $(if $(1), -T $(2)) \ scripts/genksyms/genksyms $(if $(1), -T $(2)) \
$(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \
$(if $(KBUILD_PRESERVE),-p) \ $(if $(KBUILD_PRESERVE),-p) \
-r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
@ -394,17 +396,12 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
$(sort $(subdir-obj-y)): $(subdir-ym) ; $(sort $(subdir-obj-y)): $(subdir-ym) ;
# #
# Rule to compile a set of .o files into one .o file # Rule to compile a set of .o files into one .a file (without symbol table)
# #
ifdef builtin-target ifdef builtin-target
# built-in.a archives are made with no symbol table or index which
# makes them small and fast, but unable to be used by the linker.
# scripts/link-vmlinux.sh builds an aggregate built-in.a with a symbol
# table and index.
quiet_cmd_ar_builtin = AR $@ quiet_cmd_ar_builtin = AR $@
cmd_ar_builtin = rm -f $@; \ cmd_ar_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
$(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^)
$(builtin-target): $(real-obj-y) FORCE $(builtin-target): $(real-obj-y) FORCE
$(call if_changed,ar_builtin) $(call if_changed,ar_builtin)
@ -426,13 +423,13 @@ $(modorder-target): $(subdir-ym) FORCE
$(Q)(cat /dev/null; $(modorder-cmds)) > $@ $(Q)(cat /dev/null; $(modorder-cmds)) > $@
# #
# Rule to compile a set of .o files into one .a file # Rule to compile a set of .o files into one .a file (with symbol table)
# #
ifdef lib-target ifdef lib-target
quiet_cmd_link_l_target = AR $@ quiet_cmd_link_l_target = AR $@
# lib target archives do get a symbol table and index # lib target archives do get a symbol table and index
cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y) cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
$(lib-target): $(lib-y) FORCE $(lib-target): $(lib-y) FORCE
$(call if_changed,link_l_target) $(call if_changed,link_l_target)
@ -457,6 +454,10 @@ targets += $(obj)/lib-ksyms.o
endif endif
# NOTE:
# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
# module is turned into a multi object module, $^ will contain header file
# dependencies recorded in the .*.cmd file.
quiet_cmd_link_multi-m = LD [M] $@ quiet_cmd_link_multi-m = LD [M] $@
cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis) cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis)

View File

@ -67,13 +67,15 @@ _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
$(HOSTCXXFLAGS_$(basetarget).o) $(HOSTCXXFLAGS_$(basetarget).o)
ifeq ($(KBUILD_SRC),)
__hostc_flags = $(_hostc_flags) __hostc_flags = $(_hostc_flags)
__hostcxx_flags = $(_hostcxx_flags) __hostcxx_flags = $(_hostcxx_flags)
else
ifeq ($(KBUILD_EXTMOD),)
ifneq ($(KBUILD_SRC),)
__hostc_flags = -I$(obj) $(call flags,_hostc_flags) __hostc_flags = -I$(obj) $(call flags,_hostc_flags)
__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) __hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags)
endif endif
endif
hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)

View File

@ -137,14 +137,14 @@ _c_flags += $(if $(patsubst n%,, \
$(CFLAGS_KCOV)) $(CFLAGS_KCOV))
endif endif
# If building the kernel in a separate objtree expand all occurrences
# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
ifeq ($(KBUILD_SRC),)
__c_flags = $(_c_flags) __c_flags = $(_c_flags)
__a_flags = $(_a_flags) __a_flags = $(_a_flags)
__cpp_flags = $(_cpp_flags) __cpp_flags = $(_cpp_flags)
else
# If building the kernel in a separate objtree expand all occurrences
# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
ifeq ($(KBUILD_EXTMOD),)
ifneq ($(KBUILD_SRC),)
# -I$(obj) locates generated .h files # -I$(obj) locates generated .h files
# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
@ -155,6 +155,7 @@ __c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \
__a_flags = $(call flags,_a_flags) __a_flags = $(call flags,_a_flags)
__cpp_flags = $(call flags,_cpp_flags) __cpp_flags = $(call flags,_cpp_flags)
endif endif
endif
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
-include $(srctree)/include/linux/compiler_types.h \ -include $(srctree)/include/linux/compiler_types.h \
@ -230,7 +231,7 @@ $(obj)/%: $(src)/%_shipped
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
quiet_cmd_ld = LD $@ quiet_cmd_ld = LD $@
cmd_ld = $(LD) $(ld_flags) $(filter-out FORCE,$^) -o $@ cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@
# Objcopy # Objcopy
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@ -242,7 +243,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
quiet_cmd_gzip = GZIP $@ quiet_cmd_gzip = GZIP $@
cmd_gzip = cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@ cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@
# DTC # DTC
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@ -270,7 +271,7 @@ DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
# Generate an assembly file to wrap the output of the device tree compiler # Generate an assembly file to wrap the output of the device tree compiler
quiet_cmd_dt_S_dtb= DTB $@ quiet_cmd_dt_S_dtb= DTB $@
cmd_dt_S_dtb= \ cmd_dt_S_dtb= \
( \ { \
echo '\#include <asm-generic/vmlinux.lds.h>'; \ echo '\#include <asm-generic/vmlinux.lds.h>'; \
echo '.section .dtb.init.rodata,"a"'; \ echo '.section .dtb.init.rodata,"a"'; \
echo '.balign STRUCT_ALIGNMENT'; \ echo '.balign STRUCT_ALIGNMENT'; \
@ -280,7 +281,7 @@ cmd_dt_S_dtb= \
echo '__dtb_$(subst -,_,$(*F))_end:'; \ echo '__dtb_$(subst -,_,$(*F))_end:'; \
echo '.global __dtb_$(subst -,_,$(*F))_end'; \ echo '.global __dtb_$(subst -,_,$(*F))_end'; \
echo '.balign STRUCT_ALIGNMENT'; \ echo '.balign STRUCT_ALIGNMENT'; \
) > $@ } > $@
$(obj)/%.dtb.S: $(obj)/%.dtb FORCE $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
$(call if_changed,dt_S_dtb) $(call if_changed,dt_S_dtb)
@ -320,7 +321,7 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
# append the size as a 32-bit littleendian number as gzip does. # append the size as a 32-bit littleendian number as gzip does.
size_append = printf $(shell \ size_append = printf $(shell \
dec_size=0; \ dec_size=0; \
for F in $1; do \ for F in $(real-prereqs); do \
fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \
dec_size=$$(expr $$dec_size + $$fsize); \ dec_size=$$(expr $$dec_size + $$fsize); \
done; \ done; \
@ -334,23 +335,20 @@ printf "%08x\n" $$dec_size | \
) )
quiet_cmd_bzip2 = BZIP2 $@ quiet_cmd_bzip2 = BZIP2 $@
cmd_bzip2 = (cat $(filter-out FORCE,$^) | \ cmd_bzip2 = { cat $(real-prereqs) | bzip2 -9 && $(size_append); } > $@
bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@
# Lzma # Lzma
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
quiet_cmd_lzma = LZMA $@ quiet_cmd_lzma = LZMA $@
cmd_lzma = (cat $(filter-out FORCE,$^) | \ cmd_lzma = { cat $(real-prereqs) | lzma -9 && $(size_append); } > $@
lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@
quiet_cmd_lzo = LZO $@ quiet_cmd_lzo = LZO $@
cmd_lzo = (cat $(filter-out FORCE,$^) | \ cmd_lzo = { cat $(real-prereqs) | lzop -9 && $(size_append); } > $@
lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@
quiet_cmd_lz4 = LZ4 $@ quiet_cmd_lz4 = LZ4 $@
cmd_lz4 = (cat $(filter-out FORCE,$^) | \ cmd_lz4 = { cat $(real-prereqs) | lz4c -l -c1 stdin stdout && \
lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ $(size_append); } > $@
# U-Boot mkimage # U-Boot mkimage
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@ -392,13 +390,11 @@ quiet_cmd_uimage = UIMAGE $@
# big dictionary would increase the memory usage too much in the multi-call # big dictionary would increase the memory usage too much in the multi-call
# decompression mode. A BCJ filter isn't used either. # decompression mode. A BCJ filter isn't used either.
quiet_cmd_xzkern = XZKERN $@ quiet_cmd_xzkern = XZKERN $@
cmd_xzkern = (cat $(filter-out FORCE,$^) | \ cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh && \
sh $(srctree)/scripts/xz_wrap.sh && \ $(size_append); } > $@
$(call size_append, $(filter-out FORCE,$^))) > $@
quiet_cmd_xzmisc = XZMISC $@ quiet_cmd_xzmisc = XZMISC $@
cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ cmd_xzmisc = cat $(real-prereqs) | xz --check=crc32 --lzma2=dict=1MiB > $@
xz --check=crc32 --lzma2=dict=1MiB) > $@
# ASM offsets # ASM offsets
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

View File

@ -122,7 +122,7 @@ quiet_cmd_ld_ko_o = LD [M] $@
cmd_ld_ko_o = \ cmd_ld_ko_o = \
$(LD) -r $(KBUILD_LDFLAGS) \ $(LD) -r $(KBUILD_LDFLAGS) \
$(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
-o $@ $(filter-out FORCE,$^) ; \ -o $@ $(real-prereqs) ; \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
$(modules): %.ko :%.o %.mod.o FORCE $(modules): %.ko :%.o %.mod.o FORCE

View File

@ -1,14 +1,10 @@
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# #
# clang-version [-p] clang-command # clang-version clang-command
#
# Prints the compiler version of `clang-command' in a canonical 4-digit form
# such as `0500' for clang-5.0 etc.
#
# With the -p option, prints the patchlevel as well, for example `050001' for
# clang-5.0.1 etc.
# #
# Print the compiler version of `clang-command' in a 5 or 6-digit form
# such as `50001' for clang-5.0.1 etc.
compiler="$*" compiler="$*"

View File

@ -1,33 +1,20 @@
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# #
# gcc-version [-p] gcc-command # gcc-version gcc-command
# #
# Prints the gcc version of `gcc-command' in a canonical 4-digit form # Print the gcc version of `gcc-command' in a 5 or 6-digit form
# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. # such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc.
#
# With the -p option, prints the patchlevel as well, for example `029503' for
# gcc-2.95.3, `030301' for gcc-3.3.1, etc.
#
if [ "$1" = "-p" ] ; then
with_patchlevel=1;
shift;
fi
compiler="$*" compiler="$*"
if [ ${#compiler} -eq 0 ]; then if [ ${#compiler} -eq 0 ]; then
echo "Error: No compiler specified." echo "Error: No compiler specified." >&2
printf "Usage:\n\t$0 <gcc-command>\n" printf "Usage:\n\t$0 <gcc-command>\n" >&2
exit 1 exit 1
fi fi
MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1) MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1)
MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1) MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1)
if [ "x$with_patchlevel" != "x" ] ; then PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1)
PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
else
printf "%02d%02d\\n" $MAJOR $MINOR
fi

View File

@ -1,24 +1,25 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
always := gdb-scripts
SRCTREE := $(abspath $(srctree))
$(obj)/gdb-scripts:
ifneq ($(KBUILD_SRC),) ifneq ($(KBUILD_SRC),)
$(Q)ln -fsn $(SRCTREE)/$(obj)/*.py $(objtree)/$(obj)
symlinks := $(patsubst $(srctree)/$(src)/%,%,$(wildcard $(srctree)/$(src)/*.py))
quiet_cmd_symlink = SYMLINK $@
cmd_symlink = ln -fsn $(patsubst $(obj)/%,$(abspath $(srctree))/$(src)/%,$@) $@
extra-y += $(symlinks)
$(addprefix $(obj)/, $(symlinks)): FORCE
$(call if_changed,symlink)
endif endif
@:
quiet_cmd_gen_constants_py = GEN $@ quiet_cmd_gen_constants_py = GEN $@
cmd_gen_constants_py = \ cmd_gen_constants_py = \
$(CPP) -E -x c -P $(c_flags) $< > $@ ;\ $(CPP) -E -x c -P $(c_flags) $< > $@ ;\
sed -i '1,/<!-- end-c-headers -->/d;' $@ sed -i '1,/<!-- end-c-headers -->/d;' $@
targets += constants.py extra-y += constants.py
$(obj)/constants.py: $(SRCTREE)/$(obj)/constants.py.in FORCE $(obj)/constants.py: $(src)/constants.py.in FORCE
$(call if_changed_dep,gen_constants_py) $(call if_changed_dep,gen_constants_py)
build_constants_py: $(obj)/constants.py clean-files := *.pyc *.pyo
@:
clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py) $(obj)/constants.py

View File

@ -62,11 +62,11 @@ static int all_symbols = 0;
static int absolute_percpu = 0; static int absolute_percpu = 0;
static int base_relative = 0; static int base_relative = 0;
int token_profit[0x10000]; static int token_profit[0x10000];
/* the table that holds the result of the compression */ /* the table that holds the result of the compression */
unsigned char best_table[256][2]; static unsigned char best_table[256][2];
unsigned char best_table_len[256]; static unsigned char best_table_len[256];
static void usage(void) static void usage(void)
@ -80,7 +80,7 @@ static void usage(void)
* This ignores the intensely annoying "mapping symbols" found * This ignores the intensely annoying "mapping symbols" found
* in ARM ELF files: $a, $t and $d. * in ARM ELF files: $a, $t and $d.
*/ */
static inline int is_arm_mapping_symbol(const char *str) static int is_arm_mapping_symbol(const char *str)
{ {
return str[0] == '$' && strchr("axtd", str[1]) return str[0] == '$' && strchr("axtd", str[1])
&& (str[2] == '\0' || str[2] == '.'); && (str[2] == '\0' || str[2] == '.');
@ -331,7 +331,7 @@ static void write_src(void)
unsigned int *markers; unsigned int *markers;
char buf[KSYM_NAME_LEN]; char buf[KSYM_NAME_LEN];
printf("#include <asm/types.h>\n"); printf("#include <asm/bitsperlong.h>\n");
printf("#if BITS_PER_LONG == 64\n"); printf("#if BITS_PER_LONG == 64\n");
printf("#define PTR .quad\n"); printf("#define PTR .quad\n");
printf("#define ALGN .balign 8\n"); printf("#define ALGN .balign 8\n");
@ -596,9 +596,6 @@ static void insert_real_symbols_in_table(void)
{ {
unsigned int i, j, c; unsigned int i, j, c;
memset(best_table, 0, sizeof(best_table));
memset(best_table_len, 0, sizeof(best_table_len));
for (i = 0; i < table_cnt; i++) { for (i = 0; i < table_cnt; i++) {
for (j = 0; j < table[i].len; j++) { for (j = 0; j < table[i].len; j++) {
c = table[i].sym[j]; c = table[i].sym[j];

View File

@ -488,7 +488,6 @@ int main(int ac, char **av)
const char *progname = av[0]; const char *progname = av[0];
int opt; int opt;
const char *name, *defconfig_file = NULL /* gcc uninit */; const char *name, *defconfig_file = NULL /* gcc uninit */;
struct stat tmpstat;
int no_conf_write = 0; int no_conf_write = 0;
tty_stdio = isatty(0) && isatty(1); tty_stdio = isatty(0) && isatty(1);
@ -560,18 +559,6 @@ int main(int ac, char **av)
name = av[optind]; name = av[optind];
conf_parse(name); conf_parse(name);
//zconfdump(stdout); //zconfdump(stdout);
if (sync_kconfig) {
name = conf_get_configname();
if (stat(name, &tmpstat)) {
fprintf(stderr, "***\n"
"*** Configuration file \"%s\" not found!\n"
"***\n"
"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
"*** \"make menuconfig\" or \"make xconfig\").\n"
"***\n", name);
exit(1);
}
}
switch (input_mode) { switch (input_mode) {
case defconfig: case defconfig:

View File

@ -3,22 +3,17 @@
# #
# link vmlinux # link vmlinux
# #
# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and
# $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files # $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories
# from top-level directories in the kernel tree, others are specified in # in the kernel tree, others are specified in arch/$(ARCH)/Makefile.
# arch/$(ARCH)/Makefile. Ordering when linking is important, and # $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally
# $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives # (not within --whole-archive), and do not require symbol indexes added.
# which are linked conditionally (not within --whole-archive), and do not
# require symbol indexes added.
# #
# vmlinux # vmlinux
# ^ # ^
# | # |
# +-< $(KBUILD_VMLINUX_INIT) # +--< $(KBUILD_VMLINUX_OBJS)
# | +--< init/version.o + more # | +--< init/built-in.a drivers/built-in.a mm/built-in.a + more
# |
# +--< $(KBUILD_VMLINUX_MAIN)
# | +--< drivers/built-in.a mm/built-in.a + more
# | # |
# +--< $(KBUILD_VMLINUX_LIBS) # +--< $(KBUILD_VMLINUX_LIBS)
# | +--< lib/lib.a + more # | +--< lib/lib.a + more
@ -44,24 +39,6 @@ info()
fi fi
} }
# Thin archive build here makes a final archive with symbol table and indexes
# from vmlinux objects INIT and MAIN, which can be used as input to linker.
# KBUILD_VMLINUX_LIBS archives should already have symbol table and indexes
# added.
#
# Traditional incremental style of link does not require this step
#
# built-in.a output file
#
archive_builtin()
{
info AR built-in.a
rm -f built-in.a;
${AR} rcsTP${KBUILD_ARFLAGS} built-in.a \
${KBUILD_VMLINUX_INIT} \
${KBUILD_VMLINUX_MAIN}
}
# Link of vmlinux.o used for section mismatch analysis # Link of vmlinux.o used for section mismatch analysis
# ${1} output file # ${1} output file
modpost_link() modpost_link()
@ -69,7 +46,7 @@ modpost_link()
local objects local objects
objects="--whole-archive \ objects="--whole-archive \
built-in.a \ ${KBUILD_VMLINUX_OBJS} \
--no-whole-archive \ --no-whole-archive \
--start-group \ --start-group \
${KBUILD_VMLINUX_LIBS} \ ${KBUILD_VMLINUX_LIBS} \
@ -88,7 +65,7 @@ vmlinux_link()
if [ "${SRCARCH}" != "um" ]; then if [ "${SRCARCH}" != "um" ]; then
objects="--whole-archive \ objects="--whole-archive \
built-in.a \ ${KBUILD_VMLINUX_OBJS} \
--no-whole-archive \ --no-whole-archive \
--start-group \ --start-group \
${KBUILD_VMLINUX_LIBS} \ ${KBUILD_VMLINUX_LIBS} \
@ -99,7 +76,7 @@ vmlinux_link()
-T ${lds} ${objects} -T ${lds} ${objects}
else else
objects="-Wl,--whole-archive \ objects="-Wl,--whole-archive \
built-in.a \ ${KBUILD_VMLINUX_OBJS} \
-Wl,--no-whole-archive \ -Wl,--no-whole-archive \
-Wl,--start-group \ -Wl,--start-group \
${KBUILD_VMLINUX_LIBS} \ ${KBUILD_VMLINUX_LIBS} \
@ -160,7 +137,6 @@ cleanup()
rm -f .tmp_System.map rm -f .tmp_System.map
rm -f .tmp_kallsyms* rm -f .tmp_kallsyms*
rm -f .tmp_vmlinux* rm -f .tmp_vmlinux*
rm -f built-in.a
rm -f System.map rm -f System.map
rm -f vmlinux rm -f vmlinux
rm -f vmlinux.o rm -f vmlinux.o
@ -217,8 +193,6 @@ fi;
# final build of init/ # final build of init/
${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
archive_builtin
#link vmlinux.o #link vmlinux.o
info LD vmlinux.o info LD vmlinux.o
modpost_link vmlinux.o modpost_link vmlinux.o

View File

@ -62,7 +62,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
# Generate a temporary compile.h # Generate a temporary compile.h
( echo /\* This file is auto generated, version $VERSION \*/ { echo /\* This file is auto generated, version $VERSION \*/
if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi
echo \#define UTS_MACHINE \"$ARCH\" echo \#define UTS_MACHINE \"$ARCH\"
@ -73,7 +73,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\" echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\"
) > .tmpcompile } > .tmpcompile
# Only replace the real compile.h if the new one is different, # Only replace the real compile.h if the new one is different,
# in order to preserve the timestamp and avoid unnecessary # in order to preserve the timestamp and avoid unnecessary

View File

@ -59,7 +59,7 @@ rpm-pkg: FORCE
# binrpm-pkg # binrpm-pkg
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
binrpm-pkg: FORCE binrpm-pkg: FORCE
$(MAKE) KBUILD_SRC= $(MAKE) -f $(srctree)/Makefile
$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
+rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
$(UTS_MACHINE) -bb $(objtree)/binkernel.spec $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
@ -72,11 +72,11 @@ deb-pkg: FORCE
$(call cmd,src_tar,$(KDEB_SOURCENAME)) $(call cmd,src_tar,$(KDEB_SOURCENAME))
origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\ origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -i.git -us -uc +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc
bindeb-pkg: FORCE bindeb-pkg: FORCE
$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -b -nc -uc +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
intdeb-pkg: FORCE intdeb-pkg: FORCE
+$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
@ -102,7 +102,7 @@ clean-dirs += $(objtree)/snap/
# tarball targets # tarball targets
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
tar%pkg: FORCE tar%pkg: FORCE
$(MAKE) KBUILD_SRC= $(MAKE) -f $(srctree)/Makefile
$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
clean-dirs += $(objtree)/tar-install/ clean-dirs += $(objtree)/tar-install/

View File

@ -86,12 +86,12 @@ cp "$($MAKE -s -f $srctree/Makefile image_name)" "$tmpdir/$installed_image_path"
if grep -q "^CONFIG_OF_EARLY_FLATTREE=y" $KCONFIG_CONFIG ; then if grep -q "^CONFIG_OF_EARLY_FLATTREE=y" $KCONFIG_CONFIG ; then
# Only some architectures with OF support have this target # Only some architectures with OF support have this target
if [ -d "${srctree}/arch/$SRCARCH/boot/dts" ]; then if [ -d "${srctree}/arch/$SRCARCH/boot/dts" ]; then
$MAKE KBUILD_SRC= INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install $MAKE -f $srctree/Makefile INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install
fi fi
fi fi
if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_install
rm -f "$tmpdir/lib/modules/$version/build" rm -f "$tmpdir/lib/modules/$version/build"
rm -f "$tmpdir/lib/modules/$version/source" rm -f "$tmpdir/lib/modules/$version/source"
if [ "$ARCH" = "um" ] ; then if [ "$ARCH" = "um" ] ; then
@ -113,14 +113,14 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
# resign stripped modules # resign stripped modules
MODULE_SIG_ALL="$(grep -s '^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true)" MODULE_SIG_ALL="$(grep -s '^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true)"
if [ -n "$MODULE_SIG_ALL" ]; then if [ -n "$MODULE_SIG_ALL" ]; then
INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_sign INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_sign
fi fi
fi fi
fi fi
if [ "$ARCH" != "um" ]; then if [ "$ARCH" != "um" ]; then
$MAKE headers_check KBUILD_SRC= $MAKE -f $srctree/Makefile headers_check
$MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr" $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH="$libc_headers_dir/usr"
fi fi
# Install the maintainer scripts # Install the maintainer scripts

View File

@ -57,7 +57,7 @@ dirs=boot
# Try to install modules # Try to install modules
# #
if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then
make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install
dirs="$dirs lib" dirs="$dirs lib"
fi fi

View File

@ -205,13 +205,15 @@ EOF
cat <<EOF > debian/rules cat <<EOF > debian/rules
#!$(command -v $MAKE) -f #!$(command -v $MAKE) -f
srctree ?= .
build: build:
\$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \
KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile
binary-arch: binary-arch:
\$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \
KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= intdeb-pkg KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg
clean: clean:
rm -rf debian/*tmp debian/files rm -rf debian/*tmp debian/files