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 ...
Showing the changes to scripts (15 of 61 files). Show all
Unified · Split
| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | # 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 | |
| 11 | 7 | /module.lds |
| 8 | +/recordmcount | |
| 9 | +/sign-file | |
| 10 | +/sorttable | |
| 11 | +/unifdef | |
| @@ -354,7 +354,7 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE · 353 unmodified lines | ||
| 354 | 354 | |
| 355 | 355 | targets += $(filter-out $(subdir-builtin), $(real-obj-y)) |
| 356 | 356 | 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) | |
| 358 | 358 | |
| 359 | 359 | # Linker scripts preprocessor (.lds.S -> .lds) |
| 360 | 360 | # --------------------------------------------------------------------------- |
| @@ -44,19 +44,22 @@ else · 43 unmodified lines | ||
| 44 | 44 | obj-y := $(filter-out %/, $(obj-y)) |
| 45 | 45 | endif |
| 46 | 46 | |
| 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 | + | |
| 49 | 54 | # 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) | |
| 53 | 57 | multi-obj-ym := $(multi-obj-y) $(multi-obj-m) |
| 54 | 58 | |
| 55 | 59 | # Replace multi-part objects by their individual parts, |
| 56 | 60 | # 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) | |
| 60 | 63 | |
| 61 | 64 | always-y += $(always-m) |
| 62 | 65 | |
| @@ -75,24 +78,18 @@ always-y += $(userprogs-always-y) $(userprogs-always-m) · 12 unmodified lines | ||
| 75 | 78 | # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built |
| 76 | 79 | dtb-$(CONFIG_OF_ALL_DTBS) += $(dtb-) |
| 77 | 80 | |
| 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))) | |
| 86 | 87 | |
| 87 | 88 | always-y += $(dtb-y) |
| 88 | 89 | |
| 89 | 90 | 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)) | |
| 96 | 93 | endif |
| 97 | 94 | |
| 98 | 95 | # Add subdir path |
| @@ -105,12 +102,14 @@ lib-y := $(addprefix $(obj)/,$(lib-y)) · 6 unmodified lines | ||
| 105 | 102 | real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) |
| 106 | 103 | real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) |
| 107 | 104 | 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)) | |
| 108 | 107 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) |
| 109 | 108 | |
| 110 | 109 | # Finds the multi-part object the current object will be linked into. |
| 111 | 110 | # If the object belongs to two or more multi-part objects, list them all. |
| 112 | 111 | 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=)))) | |
| 114 | 113 | |
| 115 | 114 | __modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) |
| 116 | 115 | |
| @@ -252,6 +251,9 @@ quiet_cmd_copy = COPY $@ · 135 unmodified lines | ||
| 252 | 251 | |
| 253 | 252 | # Shipped files |
| 254 | 253 | # =========================================================================== |
| 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. | |
| 255 | 257 | |
| 256 | 258 | quiet_cmd_shipped = SHIPPED $@ |
| 257 | 259 | cmd_shipped = cat $< > $@ |
| @@ -319,6 +321,9 @@ endif · 61 unmodified lines | ||
| 319 | 321 | |
| 320 | 322 | DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) |
| 321 | 323 | |
| 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 | + | |
| 322 | 327 | # Generate an assembly file to wrap the output of the device tree compiler |
| 323 | 328 | quiet_cmd_dt_S_dtb= DTB $@ |
| 324 | 329 | cmd_dt_S_dtb= \ |
| @@ -350,14 +355,12 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE · 25 unmodified lines | ||
| 350 | 355 | $(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE |
| 351 | 356 | $(call if_changed_dep,dtc) |
| 352 | 357 | |
| 353 | −overlay-y := $(addprefix $(obj)/, $(overlay-y)) | |
| 354 | − | |
| 355 | 358 | quiet_cmd_fdtoverlay = DTOVL $@ |
| 356 | 359 | cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real-prereqs) |
| 357 | 360 | |
| 358 | −$(overlay-y): FORCE | |
| 361 | +$(multi-dtb-y): FORCE | |
| 359 | 362 | $(call if_changed,fdtoverlay) |
| 360 | −$(call multi_depend, $(overlay-y), .dtb, -dtbs) | |
| 363 | +$(call multi_depend, $(multi-dtb-y), .dtb, -dtbs) | |
| 361 | 364 | |
| 362 | 365 | DT_CHECKER ?= dt-validate |
| 363 | 366 | DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),,-m) |
| @@ -1,2 +1,2 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0-only |
| 2 | −fixdep | |
| 2 | +/fixdep | |
| @@ -1,3 +1,3 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0-only |
| 2 | −dtc | |
| 3 | −fdtoverlay | |
| 2 | +/dtc | |
| 3 | +/fdtoverlay | |
| @@ -1,2 +1,2 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0-only |
| 2 | −randomize_layout_seed.h | |
| 2 | +/randomize_layout_seed.h | |
| @@ -1,2 +1,2 @@ | ||
| 1 | 1 | # SPDX-License-Identifier: GPL-2.0-only |
| 2 | −genksyms | |
| 2 | +/genksyms | |
| @@ -22,7 +22,7 @@ $(obj)/pars%.tab.c $(obj)/pars%.tab.h: $(src)/pars%.y FORCE · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | endif |
| 24 | 24 | |
| 25 | −# -I needed for generated C source (shipped source) | |
| 25 | +# -I needed for generated C source to include headers in source tree | |
| 26 | 26 | HOSTCFLAGS_parse.tab.o := -I $(srctree)/$(src) |
| 27 | 27 | HOSTCFLAGS_lex.lex.o := -I $(srctree)/$(src) |
| 28 | 28 | |
| @@ -320,20 +320,6 @@ cleanup() · 319 unmodified lines | ||
| 320 | 320 | rm -f .vmlinux.d |
| 321 | 321 | } |
| 322 | 322 | |
| 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 | − | |
| 337 | 323 | # Use "make V=1" to debug this script |
| 338 | 324 | case "${KBUILD_VERBOSE}" in |
| 339 | 325 | *1*) |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | # 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 | |
| @@ -44,7 +44,7 @@ generate_deps() { · 43 unmodified lines | ||
| 44 | 44 | for source_file in $mod_source_files; do |
| 45 | 45 | sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp |
| 46 | 46 | 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 | |
| 48 | 48 | tail -n +$((offset +1)) ${source_file} | grep -v MODULE_IMPORT_NS >> ${source_file}.tmp |
| 49 | 49 | if ! diff -q ${source_file} ${source_file}.tmp; then |
| 50 | 50 | mv ${source_file}.tmp ${source_file} |
| @@ -497,7 +497,7 @@ sub update_funcs · 496 unmodified lines | ||
| 497 | 497 | # |
| 498 | 498 | # Step 2: find the sections and mcount call sites |
| 499 | 499 | # |
| 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"; | |
| 501 | 501 | |
| 502 | 502 | my $text; |
| 503 | 503 | |
| @@ -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 | |
| @@ -126,7 +126,7 @@ scm_version() · 125 unmodified lines | ||
| 126 | 126 | fi |
| 127 | 127 | |
| 128 | 128 | # 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 | |
| 130 | 130 | rev=$(echo $rev | awk '{print $NF}') |
| 131 | 131 | printf -- '-svn%s' "$rev" |
| 132 | 132 | |
| @@ -326,5 +326,5 @@ esac · 325 unmodified lines | ||
| 326 | 326 | |
| 327 | 327 | # Remove structure forward declarations. |
| 328 | 328 | 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 | |
| 330 | 330 | fi |