diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2021-05-08 20:00:11 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-05-08 20:00:11 +0300 |
commit | 0f979d815cd52084b99e9f6b367e79488850df2e (patch) | |
tree | b8dd62b6f40d8ad2e0b42cfd73ff2adc7399b7fe /scripts | |
parent | ab159ac569fddf812c0a217d6dbffaa5d93ef88f (diff) | |
parent | 0ab1438bad43d95877f848b7df551bd431680270 (diff) | |
download | linux-0f979d815cd52084b99e9f6b367e79488850df2e.tar.xz |
Merge tag 'kbuild-v5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull more Kbuild updates from Masahiro Yamada:
- Convert sh and sparc to use generic shell scripts to generate the
syscall headers
- refactor .gitignore files
- Update kernel/config_data.gz only when the content of the .config
is really changed, which avoids the unneeded re-link of vmlinux
- move "remove stale files" workarounds to scripts/remove-stale-files
- suppress unused-but-set-variable warnings by default for Clang
as well
- fix locale setting LANG=C to LC_ALL=C
- improve 'make distclean'
- always keep intermediate objects from scripts/link-vmlinux.sh
- move IF_ENABLED out of <linux/kconfig.h> to make it self-contained
- misc cleanups
* tag 'kbuild-v5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (25 commits)
linux/kconfig.h: replace IF_ENABLED() with PTR_IF() in <linux/kernel.h>
kbuild: Don't remove link-vmlinux temporary files on exit/signal
kbuild: remove the unneeded comments for external module builds
kbuild: make distclean remove tag files in sub-directories
kbuild: make distclean work against $(objtree) instead of $(srctree)
kbuild: refactor modname-multi by using suffix-search
kbuild: refactor fdtoverlay rule
kbuild: parameterize the .o part of suffix-search
arch: use cross_compiling to check whether it is a cross build or not
kbuild: remove ARCH=sh64 support from top Makefile
.gitignore: prefix local generated files with a slash
kbuild: replace LANG=C with LC_ALL=C
Makefile: Move -Wno-unused-but-set-variable out of GCC only block
kbuild: add a script to remove stale generated files
kbuild: update config_data.gz only when the content of .config is changed
.gitignore: ignore only top-level modules.builtin
.gitignore: move tags and TAGS close to other tag files
kernel/.gitgnore: remove stale timeconst.h and hz.bc
usr/include: refactor .gitignore
genksyms: fix stale comment
...
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/.gitignore | 18 | ||||
-rw-r--r-- | scripts/Makefile.build | 2 | ||||
-rw-r--r-- | scripts/Makefile.lib | 57 | ||||
-rw-r--r-- | scripts/basic/.gitignore | 2 | ||||
-rw-r--r-- | scripts/dtc/.gitignore | 4 | ||||
-rw-r--r-- | scripts/gcc-plugins/.gitignore | 2 | ||||
-rw-r--r-- | scripts/genksyms/.gitignore | 2 | ||||
-rw-r--r-- | scripts/genksyms/Makefile | 2 | ||||
-rwxr-xr-x | scripts/link-vmlinux.sh | 14 | ||||
-rw-r--r-- | scripts/mod/.gitignore | 8 | ||||
-rw-r--r-- | scripts/nsdeps | 2 | ||||
-rwxr-xr-x | scripts/recordmcount.pl | 2 | ||||
-rwxr-xr-x | scripts/remove-stale-files | 31 | ||||
-rwxr-xr-x | scripts/setlocalversion | 2 | ||||
-rwxr-xr-x | scripts/tags.sh | 2 |
15 files changed, 85 insertions, 65 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore index a6c11316c969..e83c620ef52c 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -1,11 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only -bin2c -kallsyms -unifdef -recordmcount -sorttable -asn1_compiler -extract-cert -sign-file -insert-sys-cert +/asn1_compiler +/bin2c +/extract-cert +/insert-sys-cert +/kallsyms /module.lds +/recordmcount +/sign-file +/sorttable +/unifdef diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 5e39b0517186..949f723efe53 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -354,7 +354,7 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE targets += $(filter-out $(subdir-builtin), $(real-obj-y)) targets += $(filter-out $(subdir-modorder), $(real-obj-m)) -targets += $(lib-y) $(always-y) $(MAKECMDGOALS) +targets += $(real-dtb-y) $(lib-y) $(always-y) $(MAKECMDGOALS) # Linker scripts preprocessor (.lds.S -> .lds) # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 64daf37e874b..10950559b223 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -44,19 +44,22 @@ else obj-y := $(filter-out %/, $(obj-y)) endif -# Expand $(foo-objs) $(foo-y) by calling $(call suffix-search,foo.o,-objs -y) -suffix-search = $(strip $(foreach s, $2, $($(1:.o=$s)))) +# Expand $(foo-objs) $(foo-y) etc. by replacing their individuals +suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s)))) +# List composite targets that are constructed by combining other targets +multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $m))) +# List primitive targets that are compiled from source files +real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $(call suffix-search, $m, $2, $3), $m)) + # If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object -multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $m))) -multi-obj-y := $(call multi-search,$(obj-y),-objs -y) -multi-obj-m := $(call multi-search,$(obj-m),-objs -y -m) +multi-obj-y := $(call multi-search, $(obj-y), .o, -objs -y) +multi-obj-m := $(call multi-search, $(obj-m), .o, -objs -y -m) multi-obj-ym := $(multi-obj-y) $(multi-obj-m) # Replace multi-part objects by their individual parts, # including built-in.a from subdirectories -real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $(call suffix-search, $m, $2), $m)) -real-obj-y := $(call real-search, $(obj-y),-objs -y) -real-obj-m := $(call real-search, $(obj-m),-objs -y -m) +real-obj-y := $(call real-search, $(obj-y), .o, -objs -y) +real-obj-m := $(call real-search, $(obj-m), .o, -objs -y -m) always-y += $(always-m) @@ -75,24 +78,18 @@ always-y += $(userprogs-always-y) $(userprogs-always-m) # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built dtb-$(CONFIG_OF_ALL_DTBS) += $(dtb-) -# List all dtbs to be generated by fdtoverlay -overlay-y := $(foreach m,$(dtb-y), $(if $(strip $($(m:.dtb=-dtbs))),$(m),)) - -# Generate symbols for the base files so overlays can be applied to them. -$(foreach m,$(overlay-y), $(eval DTC_FLAGS_$(basename $(firstword $($(m:.dtb=-dtbs)))) += -@)) - -# Add base dtb and overlay dtbo -dtb-y += $(foreach m,$(overlay-y), $($(m:.dtb=-dtbs))) +# Composite DTB (i.e. DTB constructed by overlay) +multi-dtb-y := $(call multi-search, $(dtb-y), .dtb, -dtbs) +# Primitive DTB compiled from *.dts +real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs) +# Base DTB that overlay is applied onto (each first word of $(*-dtbs) expansion) +base-dtb-y := $(foreach m, $(multi-dtb-y), $(firstword $(call suffix-search, $m, .dtb, -dtbs))) always-y += $(dtb-y) ifneq ($(CHECK_DTBS),) -# Don't run schema checks for dtbs created by fdtoverlay as they don't -# have corresponding dts files. -dt-yaml-y := $(filter-out $(overlay-y),$(dtb-y)) - -always-y += $(patsubst %.dtb,%.dt.yaml, $(dt-yaml-y)) -always-y += $(patsubst %.dtbo,%.dt.yaml, $(dt-yaml-y)) +always-y += $(patsubst %.dtb,%.dt.yaml, $(real-dtb-y)) +always-y += $(patsubst %.dtbo,%.dt.yaml, $(real-dtb-y)) endif # Add subdir path @@ -105,12 +102,14 @@ lib-y := $(addprefix $(obj)/,$(lib-y)) real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m)) +multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y)) +real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) # Finds the multi-part object the current object will be linked into. # If the object belongs to two or more multi-part objects, list them all. modname-multi = $(sort $(foreach m,$(multi-obj-ym),\ - $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=)))) + $(if $(filter $*.o, $(call suffix-search, $m, .o, -objs -y -m)),$(m:.o=)))) __modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) @@ -252,6 +251,9 @@ quiet_cmd_copy = COPY $@ # Shipped files # =========================================================================== +# 'cp' preserves permissions. If you use it to copy a file in read-only srctree, +# the copy would be read-only as well, leading to an error when executing the +# rule next time. Use 'cat' instead in order to generate a writable file. quiet_cmd_shipped = SHIPPED $@ cmd_shipped = cat $< > $@ @@ -319,6 +321,9 @@ endif DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) +# Set -@ if the target is a base DTB that overlay is applied onto +DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@) + # Generate an assembly file to wrap the output of the device tree compiler quiet_cmd_dt_S_dtb= DTB $@ cmd_dt_S_dtb= \ @@ -350,14 +355,12 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE $(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE $(call if_changed_dep,dtc) -overlay-y := $(addprefix $(obj)/, $(overlay-y)) - quiet_cmd_fdtoverlay = DTOVL $@ cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real-prereqs) -$(overlay-y): FORCE +$(multi-dtb-y): FORCE $(call if_changed,fdtoverlay) -$(call multi_depend, $(overlay-y), .dtb, -dtbs) +$(call multi_depend, $(multi-dtb-y), .dtb, -dtbs) DT_CHECKER ?= dt-validate DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),,-m) diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore index 98ae1f509592..961c91c8a884 100644 --- a/scripts/basic/.gitignore +++ b/scripts/basic/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -fixdep +/fixdep diff --git a/scripts/dtc/.gitignore b/scripts/dtc/.gitignore index 8a8b62bf3d3c..e0b5c1d2464a 100644 --- a/scripts/dtc/.gitignore +++ b/scripts/dtc/.gitignore @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -dtc -fdtoverlay +/dtc +/fdtoverlay diff --git a/scripts/gcc-plugins/.gitignore b/scripts/gcc-plugins/.gitignore index b04e0f0f033e..5cc385b9eb97 100644 --- a/scripts/gcc-plugins/.gitignore +++ b/scripts/gcc-plugins/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -randomize_layout_seed.h +/randomize_layout_seed.h diff --git a/scripts/genksyms/.gitignore b/scripts/genksyms/.gitignore index 999af710f83d..0b275abf9405 100644 --- a/scripts/genksyms/.gitignore +++ b/scripts/genksyms/.gitignore @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -genksyms +/genksyms diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile index ce4f99935de5..d6a422a63b6a 100644 --- a/scripts/genksyms/Makefile +++ b/scripts/genksyms/Makefile @@ -22,7 +22,7 @@ $(obj)/pars%.tab.c $(obj)/pars%.tab.h: $(src)/pars%.y FORCE endif -# -I needed for generated C source (shipped source) +# -I needed for generated C source to include headers in source tree HOSTCFLAGS_parse.tab.o := -I $(srctree)/$(src) HOSTCFLAGS_lex.lex.o := -I $(srctree)/$(src) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 7d112681f332..f4de4c97015b 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -320,20 +320,6 @@ cleanup() rm -f .vmlinux.d } -on_exit() -{ - if [ $? -ne 0 ]; then - cleanup - fi -} -trap on_exit EXIT - -on_signals() -{ - exit 1 -} -trap on_signals HUP INT QUIT TERM - # Use "make V=1" to debug this script case "${KBUILD_VERBOSE}" in *1*) diff --git a/scripts/mod/.gitignore b/scripts/mod/.gitignore index 07e4a39f90a6..0465ec33c9bf 100644 --- a/scripts/mod/.gitignore +++ b/scripts/mod/.gitignore @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -elfconfig.h -mk_elfconfig -modpost -devicetable-offsets.h +/devicetable-offsets.h +/elfconfig.h +/mk_elfconfig +/modpost diff --git a/scripts/nsdeps b/scripts/nsdeps index e8ce2a4d704a..04c4b96e95ec 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -44,7 +44,7 @@ generate_deps() { for source_file in $mod_source_files; do sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp offset=$(wc -l ${source_file}.tmp | awk '{print $1;}') - cat $source_file | grep MODULE_IMPORT_NS | LANG=C sort -u >> ${source_file}.tmp + cat $source_file | grep MODULE_IMPORT_NS | LC_ALL=C sort -u >> ${source_file}.tmp tail -n +$((offset +1)) ${source_file} | grep -v MODULE_IMPORT_NS >> ${source_file}.tmp if ! diff -q ${source_file} ${source_file}.tmp; then mv ${source_file}.tmp ${source_file} diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index 5053b78da19e..c17e48020ec3 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl @@ -497,7 +497,7 @@ sub update_funcs # # Step 2: find the sections and mcount call sites # -open(IN, "LANG=C $objdump -hdr $inputfile|") || die "error running $objdump"; +open(IN, "LC_ALL=C $objdump -hdr $inputfile|") || die "error running $objdump"; my $text; diff --git a/scripts/remove-stale-files b/scripts/remove-stale-files new file mode 100755 index 000000000000..c3eb81c3f7de --- /dev/null +++ b/scripts/remove-stale-files @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e + +# When you move, remove or rename generated files, you probably also update +# .gitignore and cleaning rules in the Makefile. This is the right thing +# to do. However, people usually do 'git pull', 'git bisect', etc. without +# running 'make clean'. Then, the stale generated files are left over, often +# causing build issues. +# +# Also, 'git status' shows such stale build artifacts as untracked files. +# What is worse, some people send a wrong patch to get them back to .gitignore +# without checking the commit history. +# +# So, when you (re)move generated files, please move the cleaning rules from +# the Makefile to this script. This is run before Kbuild starts building +# anything, so people will not be annoyed by such garbage files. +# +# This script is not intended to grow endlessly. Rather, it is a temporary scrap +# yard. Stale files stay in this file for a while (for some release cycles?), +# then will be really dead and removed from the code base entirely. + +# These were previously generated source files. When you are building the kernel +# with O=, make sure to remove the stale files in the output tree. Otherwise, +# the build system wrongly compiles the stale ones. +if [ -n "${building_out_of_srctree}" ]; then + for f in fdt_rw.c fdt_ro.c fdt_wip.c fdt.c + do + rm -f arch/arm/boot/compressed/${f} + done +fi diff --git a/scripts/setlocalversion b/scripts/setlocalversion index bb709eda96cd..db941f6d9591 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -126,7 +126,7 @@ scm_version() fi # Check for svn and a svn repo. - if rev=$(LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'); then + if rev=$(LC_ALL=C svn info 2>/dev/null | grep '^Last Changed Rev'); then rev=$(echo $rev | awk '{print $NF}') printf -- '-svn%s' "$rev" diff --git a/scripts/tags.sh b/scripts/tags.sh index fd96734deff1..db8ba411860a 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -326,5 +326,5 @@ esac # Remove structure forward declarations. if [ -n "$remove_structs" ]; then - LANG=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1 + LC_ALL=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1 fi |