History

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

Linus Torvalds committed 5 years ago

Commit 0f979d82 parents ab159ac 0ab143861 files · +183 −342Browse files

Showing the changes to scripts (15 of 61 files). Show all

Unified · Split

15 files
  1. scripts/.gitignore +9 −9
  2. scripts/Makefile.build +1 −1
  3. scripts/Makefile.lib +30 −27
  4. scripts/basic/.gitignore +1 −1
  5. scripts/dtc/.gitignore +2 −2
  6. scripts/gcc-plugins/.gitignore +1 −1
  7. scripts/genksyms/.gitignore +1 −1
  8. scripts/genksyms/Makefile +1 −1
  9. scripts/link-vmlinux.sh +0 −14
  10. scripts/mod/.gitignore +4 −4
  11. scripts/nsdeps +1 −1
  12. scripts/recordmcount.pl +1 −1
  13. scripts/remove-stale-files +31 −0
  14. scripts/setlocalversion +1 −1
  15. scripts/tags.sh +1 −1
scripts/.gitignore+9−9
@@ -1,11 +1,11 @@
11 # SPDX-License-Identifier: GPL-2.0-only
2−bin2c
3−kallsyms
4−unifdef
5−recordmcount
6−sorttable
7−asn1_compiler
8−extract-cert
9−sign-file
10−insert-sys-cert
2+/asn1_compiler
3+/bin2c
4+/extract-cert
5+/insert-sys-cert
6+/kallsyms
117 /module.lds
8+/recordmcount
9+/sign-file
10+/sorttable
11+/unifdef
scripts/Makefile.build+1−1
@@ -354,7 +354,7 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE · 353 unmodified lines
354354
355355 targets += $(filter-out $(subdir-builtin), $(real-obj-y))
356356 targets += $(filter-out $(subdir-modorder), $(real-obj-m))
357−targets += $(lib-y) $(always-y) $(MAKECMDGOALS)
357+targets += $(real-dtb-y) $(lib-y) $(always-y) $(MAKECMDGOALS)
358358
359359 # Linker scripts preprocessor (.lds.S -> .lds)
360360 # ---------------------------------------------------------------------------
scripts/Makefile.lib+30−27
@@ -44,19 +44,22 @@ else · 43 unmodified lines
4444 obj-y := $(filter-out %/, $(obj-y))
4545 endif
4646
47−# Expand $(foo-objs) $(foo-y) by calling $(call suffix-search,foo.o,-objs -y)
48−suffix-search = $(strip $(foreach s, $2, $($(1:.o=$s))))
47+# Expand $(foo-objs) $(foo-y) etc. by replacing their individuals
48+suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s))))
49+# List composite targets that are constructed by combining other targets
50+multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $m)))
51+# List primitive targets that are compiled from source files
52+real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2, $3 -), $(call suffix-search, $m, $2, $3), $m))
53+
4954 # If $(foo-objs), $(foo-y), $(foo-m), or $(foo-) exists, foo.o is a composite object
50−multi-search = $(sort $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $m)))
51−multi-obj-y := $(call multi-search,$(obj-y),-objs -y)
52−multi-obj-m := $(call multi-search,$(obj-m),-objs -y -m)
55+multi-obj-y := $(call multi-search, $(obj-y), .o, -objs -y)
56+multi-obj-m := $(call multi-search, $(obj-m), .o, -objs -y -m)
5357 multi-obj-ym := $(multi-obj-y) $(multi-obj-m)
5458
5559 # Replace multi-part objects by their individual parts,
5660 # including built-in.a from subdirectories
57−real-search = $(foreach m, $1, $(if $(call suffix-search, $m, $2 -), $(call suffix-search, $m, $2), $m))
58−real-obj-y := $(call real-search, $(obj-y),-objs -y)
59−real-obj-m := $(call real-search, $(obj-m),-objs -y -m)
61+real-obj-y := $(call real-search, $(obj-y), .o, -objs -y)
62+real-obj-m := $(call real-search, $(obj-m), .o, -objs -y -m)
6063
6164 always-y += $(always-m)
6265
@@ -75,24 +78,18 @@ always-y += $(userprogs-always-y) $(userprogs-always-m) · 12 unmodified lines
7578 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
7679 dtb-$(CONFIG_OF_ALL_DTBS) += $(dtb-)
7780
78−# List all dtbs to be generated by fdtoverlay
79−overlay-y := $(foreach m,$(dtb-y), $(if $(strip $($(m:.dtb=-dtbs))),$(m),))
80−
81−# Generate symbols for the base files so overlays can be applied to them.
82−$(foreach m,$(overlay-y), $(eval DTC_FLAGS_$(basename $(firstword $($(m:.dtb=-dtbs)))) += -@))
83−
84−# Add base dtb and overlay dtbo
85−dtb-y += $(foreach m,$(overlay-y), $($(m:.dtb=-dtbs)))
81+# Composite DTB (i.e. DTB constructed by overlay)
82+multi-dtb-y := $(call multi-search, $(dtb-y), .dtb, -dtbs)
83+# Primitive DTB compiled from *.dts
84+real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs)
85+# Base DTB that overlay is applied onto (each first word of $(*-dtbs) expansion)
86+base-dtb-y := $(foreach m, $(multi-dtb-y), $(firstword $(call suffix-search, $m, .dtb, -dtbs)))
8687
8788 always-y += $(dtb-y)
8889
8990 ifneq ($(CHECK_DTBS),)
90−# Don't run schema checks for dtbs created by fdtoverlay as they don't
91−# have corresponding dts files.
92−dt-yaml-y := $(filter-out $(overlay-y),$(dtb-y))
93−
94−always-y += $(patsubst %.dtb,%.dt.yaml, $(dt-yaml-y))
95−always-y += $(patsubst %.dtbo,%.dt.yaml, $(dt-yaml-y))
91+always-y += $(patsubst %.dtb,%.dt.yaml, $(real-dtb-y))
92+always-y += $(patsubst %.dtbo,%.dt.yaml, $(real-dtb-y))
9693 endif
9794
9895 # Add subdir path
@@ -105,12 +102,14 @@ lib-y := $(addprefix $(obj)/,$(lib-y)) · 6 unmodified lines
105102 real-obj-y := $(addprefix $(obj)/,$(real-obj-y))
106103 real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
107104 multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m))
105+multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y))
106+real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y))
108107 subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
109108
110109 # Finds the multi-part object the current object will be linked into.
111110 # If the object belongs to two or more multi-part objects, list them all.
112111 modname-multi = $(sort $(foreach m,$(multi-obj-ym),\
113− $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))
112+ $(if $(filter $*.o, $(call suffix-search, $m, .o, -objs -y -m)),$(m:.o=))))
114113
115114 __modname = $(if $(modname-multi),$(modname-multi),$(basetarget))
116115
@@ -252,6 +251,9 @@ quiet_cmd_copy = COPY $@ · 135 unmodified lines
252251
253252 # Shipped files
254253 # ===========================================================================
254+# 'cp' preserves permissions. If you use it to copy a file in read-only srctree,
255+# the copy would be read-only as well, leading to an error when executing the
256+# rule next time. Use 'cat' instead in order to generate a writable file.
255257
256258 quiet_cmd_shipped = SHIPPED $@
257259 cmd_shipped = cat $< > $@
@@ -319,6 +321,9 @@ endif · 61 unmodified lines
319321
320322 DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
321323
324+# Set -@ if the target is a base DTB that overlay is applied onto
325+DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@)
326+
322327 # Generate an assembly file to wrap the output of the device tree compiler
323328 quiet_cmd_dt_S_dtb= DTB $@
324329 cmd_dt_S_dtb= \
@@ -350,14 +355,12 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE · 25 unmodified lines
350355 $(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
351356 $(call if_changed_dep,dtc)
352357
353−overlay-y := $(addprefix $(obj)/, $(overlay-y))
354−
355358 quiet_cmd_fdtoverlay = DTOVL $@
356359 cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real-prereqs)
357360
358−$(overlay-y): FORCE
361+$(multi-dtb-y): FORCE
359362 $(call if_changed,fdtoverlay)
360−$(call multi_depend, $(overlay-y), .dtb, -dtbs)
363+$(call multi_depend, $(multi-dtb-y), .dtb, -dtbs)
361364
362365 DT_CHECKER ?= dt-validate
363366 DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),,-m)
scripts/basic/.gitignore+1−1
@@ -1,2 +1,2 @@
11 # SPDX-License-Identifier: GPL-2.0-only
2−fixdep
2+/fixdep
scripts/dtc/.gitignore+2−2
@@ -1,3 +1,3 @@
11 # SPDX-License-Identifier: GPL-2.0-only
2−dtc
3−fdtoverlay
2+/dtc
3+/fdtoverlay
scripts/gcc-plugins/.gitignore+1−1
@@ -1,2 +1,2 @@
11 # SPDX-License-Identifier: GPL-2.0-only
2−randomize_layout_seed.h
2+/randomize_layout_seed.h
scripts/genksyms/.gitignore+1−1
@@ -1,2 +1,2 @@
11 # SPDX-License-Identifier: GPL-2.0-only
2−genksyms
2+/genksyms
scripts/genksyms/Makefile+1−1
@@ -22,7 +22,7 @@ $(obj)/pars%.tab.c $(obj)/pars%.tab.h: $(src)/pars%.y FORCE · 21 unmodified lines
2222
2323 endif
2424
25−# -I needed for generated C source (shipped source)
25+# -I needed for generated C source to include headers in source tree
2626 HOSTCFLAGS_parse.tab.o := -I $(srctree)/$(src)
2727 HOSTCFLAGS_lex.lex.o := -I $(srctree)/$(src)
2828
scripts/link-vmlinux.sh+0−14
@@ -320,20 +320,6 @@ cleanup() · 319 unmodified lines
320320 rm -f .vmlinux.d
321321 }
322322
323−on_exit()
324−{
325− if [ $? -ne 0 ]; then
326− cleanup
327− fi
328−}
329−trap on_exit EXIT
330−
331−on_signals()
332−{
333− exit 1
334−}
335−trap on_signals HUP INT QUIT TERM
336−
337323 # Use "make V=1" to debug this script
338324 case "${KBUILD_VERBOSE}" in
339325 *1*)
scripts/mod/.gitignore+4−4
@@ -1,5 +1,5 @@
11 # SPDX-License-Identifier: GPL-2.0-only
2−elfconfig.h
3−mk_elfconfig
4−modpost
5−devicetable-offsets.h
2+/devicetable-offsets.h
3+/elfconfig.h
4+/mk_elfconfig
5+/modpost
scripts/nsdeps+1−1
@@ -44,7 +44,7 @@ generate_deps() { · 43 unmodified lines
4444 for source_file in $mod_source_files; do
4545 sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp
4646 offset=$(wc -l ${source_file}.tmp | awk '{print $1;}')
47− cat $source_file | grep MODULE_IMPORT_NS | LANG=C sort -u >> ${source_file}.tmp
47+ cat $source_file | grep MODULE_IMPORT_NS | LC_ALL=C sort -u >> ${source_file}.tmp
4848 tail -n +$((offset +1)) ${source_file} | grep -v MODULE_IMPORT_NS >> ${source_file}.tmp
4949 if ! diff -q ${source_file} ${source_file}.tmp; then
5050 mv ${source_file}.tmp ${source_file}
scripts/recordmcount.pl+1−1
@@ -497,7 +497,7 @@ sub update_funcs · 496 unmodified lines
497497 #
498498 # Step 2: find the sections and mcount call sites
499499 #
500−open(IN, "LANG=C $objdump -hdr $inputfile|") || die "error running $objdump";
500+open(IN, "LC_ALL=C $objdump -hdr $inputfile|") || die "error running $objdump";
501501
502502 my $text;
503503
scripts/remove-stale-files+31−0
@@ -0,0 +1,31 @@
1+#!/bin/sh
2+
3+set -e
4+
5+# When you move, remove or rename generated files, you probably also update
6+# .gitignore and cleaning rules in the Makefile. This is the right thing
7+# to do. However, people usually do 'git pull', 'git bisect', etc. without
8+# running 'make clean'. Then, the stale generated files are left over, often
9+# causing build issues.
10+#
11+# Also, 'git status' shows such stale build artifacts as untracked files.
12+# What is worse, some people send a wrong patch to get them back to .gitignore
13+# without checking the commit history.
14+#
15+# So, when you (re)move generated files, please move the cleaning rules from
16+# the Makefile to this script. This is run before Kbuild starts building
17+# anything, so people will not be annoyed by such garbage files.
18+#
19+# This script is not intended to grow endlessly. Rather, it is a temporary scrap
20+# yard. Stale files stay in this file for a while (for some release cycles?),
21+# then will be really dead and removed from the code base entirely.
22+
23+# These were previously generated source files. When you are building the kernel
24+# with O=, make sure to remove the stale files in the output tree. Otherwise,
25+# the build system wrongly compiles the stale ones.
26+if [ -n "${building_out_of_srctree}" ]; then
27+ for f in fdt_rw.c fdt_ro.c fdt_wip.c fdt.c
28+ do
29+ rm -f arch/arm/boot/compressed/${f}
30+ done
31+fi
scripts/setlocalversion+1−1
@@ -126,7 +126,7 @@ scm_version() · 125 unmodified lines
126126 fi
127127
128128 # Check for svn and a svn repo.
129− if rev=$(LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'); then
129+ if rev=$(LC_ALL=C svn info 2>/dev/null | grep '^Last Changed Rev'); then
130130 rev=$(echo $rev | awk '{print $NF}')
131131 printf -- '-svn%s' "$rev"
132132
scripts/tags.sh+1−1
@@ -326,5 +326,5 @@ esac · 325 unmodified lines
326326
327327 # Remove structure forward declarations.
328328 if [ -n "$remove_structs" ]; then
329− LANG=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1
329+ LC_ALL=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1
330330 fi