Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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
...

+262 -362
+1 -1
Documentation/devicetree/bindings/Makefile
··· 15 15 extra-y += $(DT_TMP_SCHEMA) 16 16 17 17 quiet_cmd_mk_schema = SCHEMA $@ 18 - cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(filter-out FORCE, $^) 18 + cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(real-prereqs) 19 19 20 20 DT_DOCS = $(shell \ 21 21 cd $(srctree)/$(src) && \
+5 -10
Documentation/kbuild/kbuild.txt
··· 232 232 -------------------------------------------------- 233 233 The linker script with full path. Assigned by the top-level Makefile. 234 234 235 - KBUILD_VMLINUX_INIT 235 + KBUILD_VMLINUX_OBJS 236 236 -------------------------------------------------- 237 - All object files for the init (first) part of vmlinux. 238 - Files specified with KBUILD_VMLINUX_INIT are linked first. 239 - 240 - KBUILD_VMLINUX_MAIN 241 - -------------------------------------------------- 242 - All object files for the main part of vmlinux. 237 + All object files for vmlinux. They are linked to vmlinux in the same 238 + order as listed in KBUILD_VMLINUX_OBJS. 243 239 244 240 KBUILD_VMLINUX_LIBS 245 241 -------------------------------------------------- 246 - All .a "lib" files for vmlinux. 247 - KBUILD_VMLINUX_INIT, KBUILD_VMLINUX_MAIN, and KBUILD_VMLINUX_LIBS together 248 - specify all the object files used to link vmlinux. 242 + All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS 243 + together specify all the object files used to link vmlinux.
+2 -24
Documentation/kbuild/makefiles.txt
··· 154 154 155 155 Kbuild compiles all the $(obj-y) files. It then calls 156 156 "$(AR) rcSTP" to merge these files into one built-in.a file. 157 - This is a thin archive without a symbol table, which makes it 158 - unsuitable as a linker input. 159 - 160 - The scripts/link-vmlinux.sh script later makes an aggregate 161 - built-in.a with "${AR} rcsTP", which creates the thin archive 162 - with a symbol table and an index, making it a valid input for 163 - the final vmlinux link passes. 157 + This is a thin archive without a symbol table. It will be later 158 + linked into vmlinux by scripts/link-vmlinux.sh 164 159 165 160 The order of files in $(obj-y) is significant. Duplicates in 166 161 the lists are allowed: the first instance will be linked into ··· 498 503 499 504 In the above example, -Wno-unused-but-set-variable will be added to 500 505 KBUILD_CFLAGS only if gcc really accepts it. 501 - 502 - cc-version 503 - cc-version returns a numerical version of the $(CC) compiler version. 504 - The format is <major><minor> where both are two digits. So for example 505 - gcc 3.41 would return 0341. 506 - cc-version is useful when a specific $(CC) version is faulty in one 507 - area, for example -mregparm=3 was broken in some gcc versions 508 - even though the option was accepted by gcc. 509 - 510 - Example: 511 - #arch/x86/Makefile 512 - cflags-y += $(shell \ 513 - if [ $(cc-version) -ge 0300 ] ; then \ 514 - echo "-mregparm=3"; fi ;) 515 - 516 - In the above example, -mregparm=3 is only used for gcc version greater 517 - than or equal to gcc 3.0. 518 506 519 507 cc-ifversion 520 508 cc-ifversion tests the version of $(CC) and equals the fourth parameter
+1 -1
Documentation/kbuild/modules.txt
··· 140 140 make -C $KDIR M=$PWD bar.lst 141 141 make -C $KDIR M=$PWD baz.o 142 142 make -C $KDIR M=$PWD foo.ko 143 - make -C $KDIR M=$PWD / 143 + make -C $KDIR M=$PWD ./ 144 144 145 145 146 146 === 3. Creating a Kbuild File for an External Module
+5 -24
Kbuild
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # 3 3 # Kbuild for top-level directory of the kernel 4 - # This file takes care of the following: 5 - # 1) Generate bounds.h 6 - # 2) Generate timeconst.h 7 - # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h) 8 - # 4) Check for missing system calls 9 - # 5) check atomics headers are up-to-date 10 - # 6) Generate constants.py (may need bounds.h) 11 4 12 5 ##### 13 - # 1) Generate bounds.h 6 + # Generate bounds.h 14 7 15 8 bounds-file := include/generated/bounds.h 16 9 ··· 14 21 $(call filechk,offsets,__LINUX_BOUNDS_H__) 15 22 16 23 ##### 17 - # 2) Generate timeconst.h 24 + # Generate timeconst.h 18 25 19 26 timeconst-file := include/generated/timeconst.h 20 27 ··· 26 33 $(call filechk,gentimeconst) 27 34 28 35 ##### 29 - # 3) Generate asm-offsets.h 30 - # 36 + # Generate asm-offsets.h 31 37 32 38 offsets-file := include/generated/asm-offsets.h 33 39 ··· 39 47 $(call filechk,offsets,__ASM_OFFSETS_H__) 40 48 41 49 ##### 42 - # 4) Check for missing system calls 43 - # 50 + # Check for missing system calls 44 51 45 52 always += missing-syscalls 46 53 targets += missing-syscalls ··· 51 60 $(call cmd,syscalls) 52 61 53 62 ##### 54 - # 5) Check atomic headers are up-to-date 55 - # 63 + # Check atomic headers are up-to-date 56 64 57 65 always += old-atomics 58 66 targets += old-atomics ··· 61 71 62 72 old-atomics: scripts/atomic/check-atomics.sh FORCE 63 73 $(call cmd,atomics) 64 - 65 - ##### 66 - # 6) Generate constants for Python GDB integration 67 - # 68 - 69 - extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py 70 - 71 - build_constants_py: $(timeconst-file) $(bounds-file) 72 - @$(MAKE) $(build)=scripts/gdb/linux $@ 73 74 74 75 # Keep these three files during make clean 75 76 no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)
+104 -113
Makefile
··· 15 15 PHONY := _all 16 16 _all: 17 17 18 - # Do not use make's built-in rules and variables 19 - # (this increases performance and avoids hard-to-debug behaviour) 20 - MAKEFLAGS += -rR 21 - 22 - # Avoid funny character set dependencies 23 - unexport LC_ALL 24 - LC_COLLATE=C 25 - LC_NUMERIC=C 26 - export LC_COLLATE LC_NUMERIC 27 - 28 - # Avoid interference with shell env settings 29 - unexport GREP_OPTIONS 30 - 31 18 # We are using a recursive build, so we need to do a little thinking 32 19 # to get the ordering right. 33 20 # ··· 30 43 # effects are thus separated out and done before the recursive 31 44 # descending is started. They are now explicitly listed as the 32 45 # prepare rule. 46 + 47 + ifneq ($(sub-make-done),1) 48 + 49 + # Do not use make's built-in rules and variables 50 + # (this increases performance and avoids hard-to-debug behaviour) 51 + MAKEFLAGS += -rR 52 + 53 + # 'MAKEFLAGS += -rR' does not become immediately effective for old 54 + # GNU Make versions. Cancel implicit rules for this Makefile. 55 + $(lastword $(MAKEFILE_LIST)): ; 56 + 57 + # Avoid funny character set dependencies 58 + unexport LC_ALL 59 + LC_COLLATE=C 60 + LC_NUMERIC=C 61 + export LC_COLLATE LC_NUMERIC 62 + 63 + # Avoid interference with shell env settings 64 + unexport GREP_OPTIONS 33 65 34 66 # Beautify output 35 67 # --------------------------------------------------------------------------- ··· 96 90 97 91 ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 98 92 quiet=silent_ 99 - tools_silent=s 100 93 endif 101 94 102 95 export quiet Q KBUILD_VERBOSE ··· 117 112 118 113 # KBUILD_SRC is not intended to be used by the regular user (for now), 119 114 # it is set on invocation of make with KBUILD_OUTPUT or O= specified. 120 - ifeq ($(KBUILD_SRC),) 121 115 122 116 # OK, Make called in directory where kernel src resides 123 117 # Do we want to locate output files in a separate directory? 124 118 ifeq ("$(origin O)", "command line") 125 119 KBUILD_OUTPUT := $(O) 126 120 endif 127 - 128 - # Cancel implicit rules on top Makefile 129 - $(CURDIR)/Makefile Makefile: ; 130 121 131 122 ifneq ($(words $(subst :, ,$(CURDIR))), 1) 132 123 $(error main directory cannot contain spaces nor colons) ··· 143 142 # 'sub-make' below. 144 143 MAKEFLAGS += --include-dir=$(CURDIR) 145 144 145 + else 146 + 147 + # Do not print "Entering directory ..." at all for in-tree build. 148 + MAKEFLAGS += --no-print-directory 149 + 150 + endif # ifneq ($(KBUILD_OUTPUT),) 151 + 146 152 PHONY += $(MAKECMDGOALS) sub-make 147 153 148 154 $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make ··· 157 149 158 150 # Invoke a second make in the output directory, passing relevant variables 159 151 sub-make: 160 - $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ 152 + $(Q)$(MAKE) sub-make-done=1 \ 153 + $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \ 161 154 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) 162 155 163 - # Leave processing to above invocation of make 164 - skip-makefile := 1 165 - endif # ifneq ($(KBUILD_OUTPUT),) 166 - endif # ifeq ($(KBUILD_SRC),) 167 - 156 + else # sub-make-done 168 157 # We process the rest of the Makefile if this is the final invocation of make 169 - ifeq ($(skip-makefile),) 170 158 171 159 # Do not print "Entering directory ...", 172 160 # but we want to display it when entering to the output directory ··· 219 215 src := $(srctree) 220 216 obj := $(objtree) 221 217 222 - VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) 218 + VPATH := $(srctree) 223 219 224 220 export srctree objtree VPATH 225 221 ··· 304 300 305 301 else 306 302 307 - # We need some generic definitions (do not try to remake the file). 308 - scripts/Kbuild.include: ; 309 303 include scripts/Kbuild.include 310 304 311 305 # Read KERNELRELEASE from include/config/kernel.release (if it exists) ··· 392 390 LEX = flex 393 391 YACC = bison 394 392 AWK = awk 395 - GENKSYMS = scripts/genksyms/genksyms 396 393 INSTALLKERNEL := installkernel 397 394 DEPMOD = /sbin/depmod 398 395 PERL = perl ··· 430 429 KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE 431 430 KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ 432 431 -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ 433 - -Werror-implicit-function-declaration -Werror=implicit-int \ 432 + -Werror=implicit-function-declaration -Werror=implicit-int \ 434 433 -Wno-format-security \ 435 434 -std=gnu89 436 435 KBUILD_CPPFLAGS := -D__KERNEL__ ··· 444 443 445 444 export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC 446 445 export CPP AR NM STRIP OBJCOPY OBJDUMP KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS 447 - export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE 446 + export MAKE LEX YACC AWK INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE 448 447 export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS 449 448 450 449 export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS ··· 477 476 $(Q)$(MAKE) $(build)=scripts/basic 478 477 $(Q)rm -f .tmp_quiet_recordmcount 479 478 480 - # To avoid any implicit rule to kick in, define an empty command. 481 - scripts/basic/%: scripts_basic ; 482 - 483 479 PHONY += outputmakefile 484 480 # outputmakefile generates a Makefile in the output directory, if using a 485 481 # separate output directory. This allows convenient use of make in the 486 482 # output directory. 483 + # At the same time when output Makefile generated, generate .gitignore to 484 + # ignore whole output directory 487 485 outputmakefile: 488 486 ifneq ($(KBUILD_SRC),) 489 487 $(Q)ln -fsn $(srctree) source 490 488 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) 489 + $(Q){ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore 491 490 endif 492 491 493 492 ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) 494 493 ifneq ($(CROSS_COMPILE),) 495 494 CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) 496 - GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD))) 495 + GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) 497 496 CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) 498 497 GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) 499 498 endif ··· 625 624 # because some architectures define CROSS_COMPILE there. 626 625 -include include/config/auto.conf.cmd 627 626 628 - # To avoid any implicit rule to kick in, define an empty command 629 - $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; 627 + $(KCONFIG_CONFIG): 628 + @echo >&2 '***' 629 + @echo >&2 '*** Configuration file "$@" not found!' 630 + @echo >&2 '***' 631 + @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or' 632 + @echo >&2 '*** "make menuconfig" or "make xconfig").' 633 + @echo >&2 '***' 634 + @/bin/false 630 635 631 636 # The actual configuration files used during the build are stored in 632 637 # include/generated/ and include/config/. Update them if .config is newer than 633 638 # include/config/auto.conf (which mirrors .config). 634 - include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd 639 + # 640 + # This exploits the 'multi-target pattern rule' trick. 641 + # The syncconfig should be executed only once to make all the targets. 642 + %/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG) 635 643 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig 636 644 else 637 645 # External modules and some install targets need include/generated/autoconf.h ··· 668 658 669 659 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 670 660 KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) 671 - KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,) 672 - else 673 - ifdef CONFIG_PROFILE_ALL_BRANCHES 674 - KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,) 675 661 else 676 662 KBUILD_CFLAGS += -O2 677 663 endif 678 - endif 679 664 680 - KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ 681 - $(call cc-disable-warning,maybe-uninitialized,)) 665 + ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED 666 + KBUILD_CFLAGS += -Wno-maybe-uninitialized 667 + endif 682 668 683 669 # Tell gcc to never replace conditional load with a non-conditional one 684 670 KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) ··· 735 729 endif 736 730 endif 737 731 738 - KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) 732 + DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments) 739 733 740 734 ifdef CONFIG_DEBUG_INFO 741 735 ifdef CONFIG_DEBUG_INFO_SPLIT 742 - KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) 736 + DEBUG_CFLAGS += -gsplit-dwarf 743 737 else 744 - KBUILD_CFLAGS += -g 738 + DEBUG_CFLAGS += -g 745 739 endif 746 740 KBUILD_AFLAGS += -Wa,-gdwarf-2 747 741 endif 748 742 ifdef CONFIG_DEBUG_INFO_DWARF4 749 - KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,) 743 + DEBUG_CFLAGS += -gdwarf-4 750 744 endif 751 745 752 746 ifdef CONFIG_DEBUG_INFO_REDUCED 753 - KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ 747 + DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ 754 748 $(call cc-option,-fno-var-tracking) 755 749 endif 750 + 751 + KBUILD_CFLAGS += $(DEBUG_CFLAGS) 752 + export DEBUG_CFLAGS 756 753 757 754 ifdef CONFIG_FUNCTION_TRACER 758 755 ifdef CONFIG_FTRACE_MCOUNT_RECORD ··· 931 922 endif # CONFIG_MODULE_COMPRESS 932 923 export mod_compress_cmd 933 924 934 - # Select initial ramdisk compression format, default is gzip(1). 935 - # This shall be used by the dracut(8) tool while creating an initramfs image. 936 - # 937 - INITRD_COMPRESS-y := gzip 938 - INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2 939 - INITRD_COMPRESS-$(CONFIG_RD_LZMA) := lzma 940 - INITRD_COMPRESS-$(CONFIG_RD_XZ) := xz 941 - INITRD_COMPRESS-$(CONFIG_RD_LZO) := lzo 942 - INITRD_COMPRESS-$(CONFIG_RD_LZ4) := lz4 943 - # do not export INITRD_COMPRESS, since we didn't actually 944 - # choose a sane default compression above. 945 - # export INITRD_COMPRESS := $(INITRD_COMPRESS-y) 946 - 947 925 ifdef CONFIG_MODULE_SIG_ALL 948 926 $(eval $(call config_filename,MODULE_SIG_KEY)) 949 927 ··· 972 976 virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) 973 977 974 978 # Externally visible symbols (used by link-vmlinux.sh) 975 - export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) 976 - export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y) 979 + export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \ 980 + $(drivers-y) $(net-y) $(virt-y) 977 981 export KBUILD_VMLINUX_LIBS := $(libs-y1) 978 982 export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds 979 983 export LDFLAGS_vmlinux 980 984 # used by scripts/package/Makefile 981 985 export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) 982 986 983 - vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) 987 + vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) 984 988 985 989 # Recurse until adjust_autoksyms.sh is satisfied 986 990 PHONY += autoksyms_recursive ··· 1011 1015 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 1012 1016 1013 1017 vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE 1014 - ifdef CONFIG_GDB_SCRIPTS 1015 - $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) 1016 - endif 1017 1018 +$(call if_changed,link-vmlinux) 1018 1019 1019 1020 targets := vmlinux ··· 1055 1062 # archprepare is used in arch Makefiles and when processed asm symlink, 1056 1063 # version.h and scripts_basic is processed / created. 1057 1064 1058 - PHONY += prepare archprepare prepare1 prepare2 prepare3 1065 + PHONY += prepare archprepare prepare1 prepare3 1059 1066 1060 1067 # prepare3 is used to check if we are building in a separate output directory, 1061 1068 # and if so do: ··· 1070 1077 fi; 1071 1078 endif 1072 1079 1073 - # prepare2 creates a makefile if using a separate output directory. 1074 - # From this point forward, .config has been reprocessed, so any rules 1075 - # that need to depend on updated CONFIG_* values can be checked here. 1076 - prepare2: prepare3 outputmakefile asm-generic 1077 - 1078 - prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h 1080 + prepare1: prepare3 outputmakefile asm-generic $(version_h) $(autoksyms_h) \ 1081 + include/generated/utsrelease.h 1079 1082 $(cmd_crmodverdir) 1080 1083 1081 1084 archprepare: archheaders archscripts prepare1 scripts ··· 1506 1517 $(DOC_TARGETS): scripts_basic FORCE 1507 1518 $(Q)$(MAKE) $(build)=Documentation $@ 1508 1519 1520 + # Misc 1521 + # --------------------------------------------------------------------------- 1522 + 1523 + PHONY += scripts_gdb 1524 + scripts_gdb: prepare 1525 + $(Q)$(MAKE) $(build)=scripts/gdb 1526 + $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) 1527 + 1528 + ifdef CONFIG_GDB_SCRIPTS 1529 + all: scripts_gdb 1530 + endif 1531 + 1509 1532 else # KBUILD_EXTMOD 1510 1533 1511 1534 ### ··· 1669 1668 @echo $(KBUILD_IMAGE) 1670 1669 1671 1670 # Clear a bunch of variables before executing the submake 1671 + 1672 + ifeq ($(quiet),silent_) 1673 + tools_silent=s 1674 + endif 1675 + 1672 1676 tools/: FORCE 1673 1677 $(Q)mkdir -p $(objtree)/tools 1674 1678 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ ··· 1692 1686 # target-dir => where to store outputfile 1693 1687 # build-dir => directory in kernel source tree to use 1694 1688 1695 - ifeq ($(KBUILD_EXTMOD),) 1696 - build-dir = $(patsubst %/,%,$(dir $@)) 1697 - target-dir = $(dir $@) 1698 - else 1699 - zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) 1700 - build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) 1701 - target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) 1702 - endif 1689 + build-target = $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD)/)$@ 1690 + build-dir = $(patsubst %/,%,$(dir $(build-target))) 1703 1691 1704 - %.s: %.c prepare FORCE 1705 - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1706 - %.i: %.c prepare FORCE 1707 - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1708 - %.o: %.c prepare FORCE 1709 - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1710 - %.lst: %.c prepare FORCE 1711 - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1712 - %.s: %.S prepare FORCE 1713 - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1714 - %.o: %.S prepare FORCE 1715 - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1716 - %.symtypes: %.c prepare FORCE 1717 - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1718 - %.ll: %.c prepare FORCE 1719 - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1692 + %.i: prepare FORCE 1693 + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1694 + %.ll: prepare FORCE 1695 + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1696 + %.lst: prepare FORCE 1697 + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1698 + %.o: prepare FORCE 1699 + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1700 + %.s: prepare FORCE 1701 + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1702 + %.symtypes: prepare FORCE 1703 + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) 1704 + %.ko: %.o 1705 + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1720 1706 1721 1707 # Modules 1722 - /: prepare FORCE 1723 - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1724 - $(build)=$(build-dir) 1708 + PHONY += / 1709 + /: ./ 1710 + 1725 1711 # Make sure the latest headers are built for Documentation 1726 1712 Documentation/ samples/: headers_install 1727 1713 %/: prepare FORCE 1728 - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1729 - $(build)=$(build-dir) 1730 - %.ko: prepare FORCE 1731 - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1732 - $(build)=$(build-dir) $(@:.ko=.o) 1733 - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1714 + $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) 1734 1715 1735 1716 # FIXME Should go into a make.lib or something 1736 1717 # =========================================================================== ··· 1741 1748 # read saved command lines for existing targets 1742 1749 existing-targets := $(wildcard $(sort $(targets))) 1743 1750 1744 - cmd_files := $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 1745 - $(cmd_files): ; # Do not try to update included dependency files 1746 - -include $(cmd_files) 1751 + -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 1747 1752 1748 1753 endif # ifeq ($(config-targets),1) 1749 1754 endif # ifeq ($(mixed-targets),1) 1750 - endif # skip-makefile 1755 + endif # sub-make-done 1751 1756 1752 1757 PHONY += FORCE 1753 1758 FORCE:
+1 -1
arch/mips/boot/Makefile
··· 115 115 targets += vmlinux.its.S 116 116 117 117 quiet_cmd_its_cat = CAT $@ 118 - cmd_its_cat = cat $(filter-out $(PHONY), $^) >$@ 118 + cmd_its_cat = cat $(real-prereqs) >$@ 119 119 120 120 $(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE 121 121 $(call if_changed,its_cat)
+1 -1
arch/powerpc/boot/Makefile
··· 218 218 cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< 219 219 220 220 quiet_cmd_bootar = BOOTAR $@ 221 - cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ 221 + cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(real-prereqs); mv $@.$$$$ $@ 222 222 223 223 $(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE 224 224 $(call if_changed_dep,bootcc)
+3 -3
arch/s390/boot/Makefile
··· 58 58 $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 59 59 60 60 quiet_cmd_ar = AR $@ 61 - cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(filter $(OBJECTS), $^) 61 + cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) 62 62 63 63 $(obj)/startup.a: $(OBJECTS) FORCE 64 64 $(call if_changed,ar) ··· 67 67 sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \ 68 68 System.map "$(INSTALL_PATH)" 69 69 70 - chkbss := $(OBJECTS) 71 - chkbss-target := $(obj)/startup.a 70 + chkbss := $(obj-y) 71 + chkbss-target := startup.a 72 72 include $(srctree)/arch/s390/scripts/Makefile.chkbss
+2 -2
arch/s390/boot/compressed/Makefile
··· 63 63 $(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE 64 64 $(call if_changed,objcopy) 65 65 66 - chkbss := $(filter-out $(obj)/piggy.o $(obj)/info.o,$(OBJECTS)) 67 - chkbss-target := $(obj)/vmlinux.bin 66 + chkbss := $(filter-out piggy.o info.o, $(obj-y)) 67 + chkbss-target := vmlinux.bin 68 68 include $(srctree)/arch/s390/scripts/Makefile.chkbss
+11 -14
arch/s390/scripts/Makefile.chkbss
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 + chkbss-target ?= built-in.a 4 + $(obj)/$(chkbss-target): chkbss 5 + 6 + chkbss-files := $(addsuffix .chkbss, $(chkbss)) 7 + clean-files += $(chkbss-files) 8 + 9 + PHONY += chkbss 10 + chkbss: $(addprefix $(obj)/, $(chkbss-files)) 11 + 3 12 quiet_cmd_chkbss = CHKBSS $< 4 - define cmd_chkbss 5 - rm -f $@; \ 13 + cmd_chkbss = \ 6 14 if ! $(OBJDUMP) -j .bss -w -h $< | awk 'END { if ($$3) exit 1 }'; then \ 7 15 echo "error: $< .bss section is not empty" >&2; exit 1; \ 8 16 fi; \ 9 17 touch $@; 10 - endef 11 18 12 - chkbss-target ?= $(obj)/built-in.a 13 - ifneq (,$(findstring /,$(chkbss))) 14 - chkbss-files := $(patsubst %, %.chkbss, $(chkbss)) 15 - else 16 - chkbss-files := $(patsubst %, $(obj)/%.chkbss, $(chkbss)) 17 - endif 18 - 19 - $(chkbss-target): $(chkbss-files) 20 - targets += $(notdir $(chkbss-files)) 21 - 22 - %.o.chkbss: %.o 19 + $(obj)/%.o.chkbss: $(obj)/%.o 23 20 $(call cmd,chkbss)
+1 -2
arch/x86/realmode/rm/Makefile
··· 37 37 sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p' 38 38 39 39 quiet_cmd_pasyms = PASYMS $@ 40 - cmd_pasyms = $(NM) $(filter-out FORCE,$^) | \ 41 - sed $(sed-pasyms) | sort | uniq > $@ 40 + cmd_pasyms = $(NM) $(real-prereqs) | sed $(sed-pasyms) | sort | uniq > $@ 42 41 43 42 targets += pasyms.h 44 43 $(obj)/pasyms.h: $(REALMODE_OBJS) FORCE
+18 -1
init/Kconfig
··· 13 13 14 14 config GCC_VERSION 15 15 int 16 - default $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') if CC_IS_GCC 16 + default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC 17 17 default 0 18 18 19 19 config CC_IS_CLANG ··· 25 25 26 26 config CC_HAS_ASM_GOTO 27 27 def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) 28 + 29 + config CC_HAS_WARN_MAYBE_UNINITIALIZED 30 + def_bool $(cc-option,-Wmaybe-uninitialized) 31 + help 32 + GCC >= 4.7 supports this option. 33 + 34 + config CC_DISABLE_WARN_MAYBE_UNINITIALIZED 35 + bool 36 + depends on CC_HAS_WARN_MAYBE_UNINITIALIZED 37 + default CC_IS_GCC && GCC_VERSION < 40900 # unreliable for GCC < 4.9 38 + help 39 + GCC's -Wmaybe-uninitialized is not reliable by definition. 40 + Lots of false positive warnings are produced in some cases. 41 + 42 + If this option is enabled, -Wno-maybe-uninitialzed is passed 43 + to the compiler to suppress maybe-uninitialized warnings. 28 44 29 45 config CONSTRUCTORS 30 46 bool ··· 1130 1114 1131 1115 config CC_OPTIMIZE_FOR_SIZE 1132 1116 bool "Optimize for size" 1117 + imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives 1133 1118 help 1134 1119 Enabling this option will pass "-Os" instead of "-O2" to 1135 1120 your compiler resulting in a smaller kernel.
+1
kernel/trace/Kconfig
··· 370 370 config PROFILE_ALL_BRANCHES 371 371 bool "Profile all if conditionals" if !FORTIFY_SOURCE 372 372 select TRACE_BRANCH_PROFILING 373 + imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives 373 374 help 374 375 This tracer profiles all branch conditions. Every if () 375 376 taken in the kernel is recorded whether it hit or miss.
+2
lib/Kconfig.debug
··· 196 196 config DEBUG_INFO_SPLIT 197 197 bool "Produce split debuginfo in .dwo files" 198 198 depends on DEBUG_INFO 199 + depends on $(cc-option,-gsplit-dwarf) 199 200 help 200 201 Generate debug info into separate .dwo files. This significantly 201 202 reduces the build directory size for builds with DEBUG_INFO, ··· 212 211 config DEBUG_INFO_DWARF4 213 212 bool "Generate dwarf4 debuginfo" 214 213 depends on DEBUG_INFO 214 + depends on $(cc-option,-gdwarf-4) 215 215 help 216 216 Generate dwarf4 debug info. This requires recent versions 217 217 of gcc and gdb. It makes the debug information larger.
+9 -12
scripts/Kbuild.include
··· 24 24 basetarget = $(basename $(notdir $@)) 25 25 26 26 ### 27 + # real prerequisites without phony targets 28 + real-prereqs = $(filter-out $(PHONY), $^) 29 + 30 + ### 27 31 # Escape single quote for use in echo statements 28 32 escsq = $(subst $(squote),'\$(squote)',$1) 29 33 ··· 71 67 72 68 # cc-cross-prefix 73 69 # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) 74 - # Return first prefix where a prefix$(CC) is found in PATH. 75 - # If no $(CC) found in PATH with listed prefixes return nothing 76 - cc-cross-prefix = \ 77 - $(word 1, $(foreach c,$(1), \ 78 - $(shell set -e; \ 79 - if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \ 80 - echo $(c); \ 81 - fi))) 70 + # Return first <prefix> where a <prefix>gcc is found in PATH. 71 + # If no gcc found in PATH with listed prefixes return nothing 72 + cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \ 73 + $(if $(shell which $(c)gcc), $(c)))) 82 74 83 75 # output directory for tests below 84 76 TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) ··· 134 134 cc-disable-warning = $(call try-run,\ 135 135 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) 136 136 137 - # cc-version 138 - cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) 139 - 140 137 # cc-ifversion 141 138 # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) 142 - cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)) 139 + cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4)) 143 140 144 141 # cc-ldoption 145 142 # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
+1 -1
scripts/Kconfig.include
··· 27 27 ld-option = $(success,$(LD) -v $(1)) 28 28 29 29 # gcc version including patch level 30 - gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') 30 + gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))
+1 -2
scripts/Makefile
··· 39 39 subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins 40 40 subdir-$(CONFIG_MODVERSIONS) += genksyms 41 41 subdir-$(CONFIG_SECURITY_SELINUX) += selinux 42 - subdir-$(CONFIG_GDB_SCRIPTS) += gdb 43 42 44 43 # Let clean descend into subdirs 45 - subdir- += basic dtc kconfig mod package 44 + subdir- += basic dtc gdb kconfig mod package
+15 -14
scripts/Makefile.build
··· 63 63 builtin-target := $(obj)/built-in.a 64 64 endif 65 65 66 + ifdef CONFIG_MODULES 66 67 modorder-target := $(obj)/modules.order 68 + endif 67 69 68 70 # We keep a list of all modules in $(MODVERDIR) 69 71 ··· 106 104 quiet_modtag = $(if $(part-of-module),[M], ) 107 105 108 106 quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ 109 - cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< 107 + cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< 110 108 111 109 $(obj)/%.s: $(src)/%.c FORCE 112 110 $(call if_changed_dep,cc_s_c) ··· 120 118 # These mirror gensymtypes_S and co below, keep them in synch. 121 119 cmd_gensymtypes_c = \ 122 120 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ 123 - $(GENKSYMS) $(if $(1), -T $(2)) \ 121 + scripts/genksyms/genksyms $(if $(1), -T $(2)) \ 124 122 $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ 125 123 $(if $(KBUILD_PRESERVE),-p) \ 126 124 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) ··· 314 312 # 315 313 # These mirror gensymtypes_c and co above, keep them in synch. 316 314 cmd_gensymtypes_S = \ 317 - (echo "\#include <linux/kernel.h>" ; \ 315 + { echo "\#include <linux/kernel.h>" ; \ 318 316 echo "\#include <asm/asm-prototypes.h>" ; \ 319 317 $(CPP) $(a_flags) $< | \ 320 318 grep "\<___EXPORT_SYMBOL\>" | \ 321 - sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ) | \ 319 + sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \ 322 320 $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ 323 - $(GENKSYMS) $(if $(1), -T $(2)) \ 321 + scripts/genksyms/genksyms $(if $(1), -T $(2)) \ 324 322 $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ 325 323 $(if $(KBUILD_PRESERVE),-p) \ 326 324 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) ··· 396 394 $(sort $(subdir-obj-y)): $(subdir-ym) ; 397 395 398 396 # 399 - # Rule to compile a set of .o files into one .o file 397 + # Rule to compile a set of .o files into one .a file (without symbol table) 400 398 # 401 399 ifdef builtin-target 402 400 403 - # built-in.a archives are made with no symbol table or index which 404 - # makes them small and fast, but unable to be used by the linker. 405 - # scripts/link-vmlinux.sh builds an aggregate built-in.a with a symbol 406 - # table and index. 407 401 quiet_cmd_ar_builtin = AR $@ 408 - cmd_ar_builtin = rm -f $@; \ 409 - $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^) 402 + cmd_ar_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) 410 403 411 404 $(builtin-target): $(real-obj-y) FORCE 412 405 $(call if_changed,ar_builtin) ··· 423 426 $(Q)(cat /dev/null; $(modorder-cmds)) > $@ 424 427 425 428 # 426 - # Rule to compile a set of .o files into one .a file 429 + # Rule to compile a set of .o files into one .a file (with symbol table) 427 430 # 428 431 ifdef lib-target 429 432 quiet_cmd_link_l_target = AR $@ 430 433 431 434 # lib target archives do get a symbol table and index 432 - cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y) 435 + cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) 433 436 434 437 $(lib-target): $(lib-y) FORCE 435 438 $(call if_changed,link_l_target) ··· 454 457 455 458 endif 456 459 460 + # NOTE: 461 + # Do not replace $(filter %.o,^) with $(real-prereqs). When a single object 462 + # module is turned into a multi object module, $^ will contain header file 463 + # dependencies recorded in the .*.cmd file. 457 464 quiet_cmd_link_multi-m = LD [M] $@ 458 465 cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis) 459 466
+4 -2
scripts/Makefile.host
··· 67 67 _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ 68 68 $(HOSTCXXFLAGS_$(basetarget).o) 69 69 70 - ifeq ($(KBUILD_SRC),) 71 70 __hostc_flags = $(_hostc_flags) 72 71 __hostcxx_flags = $(_hostcxx_flags) 73 - else 72 + 73 + ifeq ($(KBUILD_EXTMOD),) 74 + ifneq ($(KBUILD_SRC),) 74 75 __hostc_flags = -I$(obj) $(call flags,_hostc_flags) 75 76 __hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) 77 + endif 76 78 endif 77 79 78 80 hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
+19 -23
scripts/Makefile.lib
··· 137 137 $(CFLAGS_KCOV)) 138 138 endif 139 139 140 - # If building the kernel in a separate objtree expand all occurrences 141 - # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). 142 - 143 - ifeq ($(KBUILD_SRC),) 144 140 __c_flags = $(_c_flags) 145 141 __a_flags = $(_a_flags) 146 142 __cpp_flags = $(_cpp_flags) 147 - else 143 + 144 + # If building the kernel in a separate objtree expand all occurrences 145 + # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). 146 + ifeq ($(KBUILD_EXTMOD),) 147 + ifneq ($(KBUILD_SRC),) 148 148 149 149 # -I$(obj) locates generated .h files 150 150 # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files ··· 154 154 $(call flags,_c_flags) 155 155 __a_flags = $(call flags,_a_flags) 156 156 __cpp_flags = $(call flags,_cpp_flags) 157 + endif 157 158 endif 158 159 159 160 c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ ··· 231 230 # --------------------------------------------------------------------------- 232 231 233 232 quiet_cmd_ld = LD $@ 234 - cmd_ld = $(LD) $(ld_flags) $(filter-out FORCE,$^) -o $@ 233 + cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@ 235 234 236 235 # Objcopy 237 236 # --------------------------------------------------------------------------- ··· 243 242 # --------------------------------------------------------------------------- 244 243 245 244 quiet_cmd_gzip = GZIP $@ 246 - cmd_gzip = cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@ 245 + cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@ 247 246 248 247 # DTC 249 248 # --------------------------------------------------------------------------- ··· 271 270 # Generate an assembly file to wrap the output of the device tree compiler 272 271 quiet_cmd_dt_S_dtb= DTB $@ 273 272 cmd_dt_S_dtb= \ 274 - ( \ 273 + { \ 275 274 echo '\#include <asm-generic/vmlinux.lds.h>'; \ 276 275 echo '.section .dtb.init.rodata,"a"'; \ 277 276 echo '.balign STRUCT_ALIGNMENT'; \ ··· 281 280 echo '__dtb_$(subst -,_,$(*F))_end:'; \ 282 281 echo '.global __dtb_$(subst -,_,$(*F))_end'; \ 283 282 echo '.balign STRUCT_ALIGNMENT'; \ 284 - ) > $@ 283 + } > $@ 285 284 286 285 $(obj)/%.dtb.S: $(obj)/%.dtb FORCE 287 286 $(call if_changed,dt_S_dtb) ··· 321 320 # append the size as a 32-bit littleendian number as gzip does. 322 321 size_append = printf $(shell \ 323 322 dec_size=0; \ 324 - for F in $1; do \ 323 + for F in $(real-prereqs); do \ 325 324 fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ 326 325 dec_size=$$(expr $$dec_size + $$fsize); \ 327 326 done; \ ··· 335 334 ) 336 335 337 336 quiet_cmd_bzip2 = BZIP2 $@ 338 - cmd_bzip2 = (cat $(filter-out FORCE,$^) | \ 339 - bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ 337 + cmd_bzip2 = { cat $(real-prereqs) | bzip2 -9 && $(size_append); } > $@ 340 338 341 339 # Lzma 342 340 # --------------------------------------------------------------------------- 343 341 344 342 quiet_cmd_lzma = LZMA $@ 345 - cmd_lzma = (cat $(filter-out FORCE,$^) | \ 346 - lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ 343 + cmd_lzma = { cat $(real-prereqs) | lzma -9 && $(size_append); } > $@ 347 344 348 345 quiet_cmd_lzo = LZO $@ 349 - cmd_lzo = (cat $(filter-out FORCE,$^) | \ 350 - lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ 346 + cmd_lzo = { cat $(real-prereqs) | lzop -9 && $(size_append); } > $@ 351 347 352 348 quiet_cmd_lz4 = LZ4 $@ 353 - cmd_lz4 = (cat $(filter-out FORCE,$^) | \ 354 - lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ 349 + cmd_lz4 = { cat $(real-prereqs) | lz4c -l -c1 stdin stdout && \ 350 + $(size_append); } > $@ 355 351 356 352 # U-Boot mkimage 357 353 # --------------------------------------------------------------------------- ··· 390 392 # big dictionary would increase the memory usage too much in the multi-call 391 393 # decompression mode. A BCJ filter isn't used either. 392 394 quiet_cmd_xzkern = XZKERN $@ 393 - cmd_xzkern = (cat $(filter-out FORCE,$^) | \ 394 - sh $(srctree)/scripts/xz_wrap.sh && \ 395 - $(call size_append, $(filter-out FORCE,$^))) > $@ 395 + cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh && \ 396 + $(size_append); } > $@ 396 397 397 398 quiet_cmd_xzmisc = XZMISC $@ 398 - cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ 399 - xz --check=crc32 --lzma2=dict=1MiB) > $@ 399 + cmd_xzmisc = cat $(real-prereqs) | xz --check=crc32 --lzma2=dict=1MiB > $@ 400 400 401 401 # ASM offsets 402 402 # ---------------------------------------------------------------------------
+1 -1
scripts/Makefile.modpost
··· 122 122 cmd_ld_ko_o = \ 123 123 $(LD) -r $(KBUILD_LDFLAGS) \ 124 124 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ 125 - -o $@ $(filter-out FORCE,$^) ; \ 125 + -o $@ $(real-prereqs) ; \ 126 126 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 127 127 128 128 $(modules): %.ko :%.o %.mod.o FORCE
+3 -7
scripts/clang-version.sh
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # 4 - # clang-version [-p] clang-command 4 + # clang-version clang-command 5 5 # 6 - # Prints the compiler version of `clang-command' in a canonical 4-digit form 7 - # such as `0500' for clang-5.0 etc. 8 - # 9 - # With the -p option, prints the patchlevel as well, for example `050001' for 10 - # clang-5.0.1 etc. 11 - # 6 + # Print the compiler version of `clang-command' in a 5 or 6-digit form 7 + # such as `50001' for clang-5.0.1 etc. 12 8 13 9 compiler="$*" 14 10
+7 -20
scripts/gcc-version.sh
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # 4 - # gcc-version [-p] gcc-command 4 + # gcc-version gcc-command 5 5 # 6 - # Prints the gcc version of `gcc-command' in a canonical 4-digit form 7 - # such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. 8 - # 9 - # With the -p option, prints the patchlevel as well, for example `029503' for 10 - # gcc-2.95.3, `030301' for gcc-3.3.1, etc. 11 - # 12 - 13 - if [ "$1" = "-p" ] ; then 14 - with_patchlevel=1; 15 - shift; 16 - fi 6 + # Print the gcc version of `gcc-command' in a 5 or 6-digit form 7 + # such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc. 17 8 18 9 compiler="$*" 19 10 20 11 if [ ${#compiler} -eq 0 ]; then 21 - echo "Error: No compiler specified." 22 - printf "Usage:\n\t$0 <gcc-command>\n" 12 + echo "Error: No compiler specified." >&2 13 + printf "Usage:\n\t$0 <gcc-command>\n" >&2 23 14 exit 1 24 15 fi 25 16 26 17 MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1) 27 18 MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1) 28 - if [ "x$with_patchlevel" != "x" ] ; then 29 - PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) 30 - printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL 31 - else 32 - printf "%02d%02d\\n" $MAJOR $MINOR 33 - fi 19 + PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) 20 + printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
+13 -12
scripts/gdb/linux/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - always := gdb-scripts 3 2 4 - SRCTREE := $(abspath $(srctree)) 5 - 6 - $(obj)/gdb-scripts: 7 3 ifneq ($(KBUILD_SRC),) 8 - $(Q)ln -fsn $(SRCTREE)/$(obj)/*.py $(objtree)/$(obj) 4 + 5 + symlinks := $(patsubst $(srctree)/$(src)/%,%,$(wildcard $(srctree)/$(src)/*.py)) 6 + 7 + quiet_cmd_symlink = SYMLINK $@ 8 + cmd_symlink = ln -fsn $(patsubst $(obj)/%,$(abspath $(srctree))/$(src)/%,$@) $@ 9 + 10 + extra-y += $(symlinks) 11 + $(addprefix $(obj)/, $(symlinks)): FORCE 12 + $(call if_changed,symlink) 13 + 9 14 endif 10 - @: 11 15 12 16 quiet_cmd_gen_constants_py = GEN $@ 13 17 cmd_gen_constants_py = \ 14 18 $(CPP) -E -x c -P $(c_flags) $< > $@ ;\ 15 19 sed -i '1,/<!-- end-c-headers -->/d;' $@ 16 20 17 - targets += constants.py 18 - $(obj)/constants.py: $(SRCTREE)/$(obj)/constants.py.in FORCE 21 + extra-y += constants.py 22 + $(obj)/constants.py: $(src)/constants.py.in FORCE 19 23 $(call if_changed_dep,gen_constants_py) 20 24 21 - build_constants_py: $(obj)/constants.py 22 - @: 23 - 24 - clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py) $(obj)/constants.py 25 + clean-files := *.pyc *.pyo
+5 -8
scripts/kallsyms.c
··· 62 62 static int absolute_percpu = 0; 63 63 static int base_relative = 0; 64 64 65 - int token_profit[0x10000]; 65 + static int token_profit[0x10000]; 66 66 67 67 /* the table that holds the result of the compression */ 68 - unsigned char best_table[256][2]; 69 - unsigned char best_table_len[256]; 68 + static unsigned char best_table[256][2]; 69 + static unsigned char best_table_len[256]; 70 70 71 71 72 72 static void usage(void) ··· 80 80 * This ignores the intensely annoying "mapping symbols" found 81 81 * in ARM ELF files: $a, $t and $d. 82 82 */ 83 - static inline int is_arm_mapping_symbol(const char *str) 83 + static int is_arm_mapping_symbol(const char *str) 84 84 { 85 85 return str[0] == '$' && strchr("axtd", str[1]) 86 86 && (str[2] == '\0' || str[2] == '.'); ··· 331 331 unsigned int *markers; 332 332 char buf[KSYM_NAME_LEN]; 333 333 334 - printf("#include <asm/types.h>\n"); 334 + printf("#include <asm/bitsperlong.h>\n"); 335 335 printf("#if BITS_PER_LONG == 64\n"); 336 336 printf("#define PTR .quad\n"); 337 337 printf("#define ALGN .balign 8\n"); ··· 595 595 static void insert_real_symbols_in_table(void) 596 596 { 597 597 unsigned int i, j, c; 598 - 599 - memset(best_table, 0, sizeof(best_table)); 600 - memset(best_table_len, 0, sizeof(best_table_len)); 601 598 602 599 for (i = 0; i < table_cnt; i++) { 603 600 for (j = 0; j < table[i].len; j++) {
-13
scripts/kconfig/conf.c
··· 488 488 const char *progname = av[0]; 489 489 int opt; 490 490 const char *name, *defconfig_file = NULL /* gcc uninit */; 491 - struct stat tmpstat; 492 491 int no_conf_write = 0; 493 492 494 493 tty_stdio = isatty(0) && isatty(1); ··· 559 560 name = av[optind]; 560 561 conf_parse(name); 561 562 //zconfdump(stdout); 562 - if (sync_kconfig) { 563 - name = conf_get_configname(); 564 - if (stat(name, &tmpstat)) { 565 - fprintf(stderr, "***\n" 566 - "*** Configuration file \"%s\" not found!\n" 567 - "***\n" 568 - "*** Please run some configurator (e.g. \"make oldconfig\" or\n" 569 - "*** \"make menuconfig\" or \"make xconfig\").\n" 570 - "***\n", name); 571 - exit(1); 572 - } 573 - } 574 563 575 564 switch (input_mode) { 576 565 case defconfig:
+2 -2
scripts/mkcompile_h
··· 62 62 63 63 # Generate a temporary compile.h 64 64 65 - ( echo /\* This file is auto generated, version $VERSION \*/ 65 + { echo /\* This file is auto generated, version $VERSION \*/ 66 66 if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi 67 67 68 68 echo \#define UTS_MACHINE \"$ARCH\" ··· 73 73 echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" 74 74 75 75 echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\" 76 - ) > .tmpcompile 76 + } > .tmpcompile 77 77 78 78 # Only replace the real compile.h if the new one is different, 79 79 # in order to preserve the timestamp and avoid unnecessary
+4 -4
scripts/package/Makefile
··· 59 59 # binrpm-pkg 60 60 # --------------------------------------------------------------------------- 61 61 binrpm-pkg: FORCE 62 - $(MAKE) KBUILD_SRC= 62 + $(MAKE) -f $(srctree)/Makefile 63 63 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec 64 64 +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ 65 65 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec ··· 72 72 $(call cmd,src_tar,$(KDEB_SOURCENAME)) 73 73 origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\ 74 74 mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz 75 - +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -i.git -us -uc 75 + +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc 76 76 77 77 bindeb-pkg: FORCE 78 78 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian 79 - +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -b -nc -uc 79 + +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc 80 80 81 81 intdeb-pkg: FORCE 82 82 +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb ··· 102 102 # tarball targets 103 103 # --------------------------------------------------------------------------- 104 104 tar%pkg: FORCE 105 - $(MAKE) KBUILD_SRC= 105 + $(MAKE) -f $(srctree)/Makefile 106 106 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ 107 107 108 108 clean-dirs += $(objtree)/tar-install/
+5 -5
scripts/package/builddeb
··· 86 86 if grep -q "^CONFIG_OF_EARLY_FLATTREE=y" $KCONFIG_CONFIG ; then 87 87 # Only some architectures with OF support have this target 88 88 if [ -d "${srctree}/arch/$SRCARCH/boot/dts" ]; then 89 - $MAKE KBUILD_SRC= INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install 89 + $MAKE -f $srctree/Makefile INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install 90 90 fi 91 91 fi 92 92 93 93 if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then 94 - INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install 94 + INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_install 95 95 rm -f "$tmpdir/lib/modules/$version/build" 96 96 rm -f "$tmpdir/lib/modules/$version/source" 97 97 if [ "$ARCH" = "um" ] ; then ··· 113 113 # resign stripped modules 114 114 MODULE_SIG_ALL="$(grep -s '^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true)" 115 115 if [ -n "$MODULE_SIG_ALL" ]; then 116 - INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_sign 116 + INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_sign 117 117 fi 118 118 fi 119 119 fi 120 120 121 121 if [ "$ARCH" != "um" ]; then 122 - $MAKE headers_check KBUILD_SRC= 123 - $MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr" 122 + $MAKE -f $srctree/Makefile headers_check 123 + $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH="$libc_headers_dir/usr" 124 124 fi 125 125 126 126 # Install the maintainer scripts
+1 -1
scripts/package/buildtar
··· 57 57 # Try to install modules 58 58 # 59 59 if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then 60 - make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install 60 + make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install 61 61 dirs="$dirs lib" 62 62 fi 63 63
+4 -2
scripts/package/mkdebian
··· 205 205 cat <<EOF > debian/rules 206 206 #!$(command -v $MAKE) -f 207 207 208 + srctree ?= . 209 + 208 210 build: 209 211 \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ 210 - KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= 212 + KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile 211 213 212 214 binary-arch: 213 215 \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ 214 - KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= intdeb-pkg 216 + KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg 215 217 216 218 clean: 217 219 rm -rf debian/*tmp debian/files