From afba83ad89d5b17fc49f47df3a8c031a23815d1a Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:12 +0300 Subject: kbuild: de-duplicate fixdep usage Backported from the linux kernel commit e4aca4595005 ("kbuild: de-duplicate fixdep usage") A lot of the kernels kbuild depend on that patch. Backport it and pull in the 'rule_as_o_S'a rule as well. This might end up being unused but it doesn't break anything and makes diffing the files easier. Signed-off-by: Ilias Apalodimas --- scripts/Kbuild.include | 5 ++++- scripts/Makefile.build | 17 ++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 054dd157485..7468223d323 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -266,10 +266,13 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ # Execute the command and also postprocess generated .d dependencies file. if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ @set -e; \ + $(cmd_and_fixdep), @:) + +cmd_and_fixdep = \ $(echo-cmd) $(cmd_$(1)); \ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ rm -f $(depfile); \ - mv -f $(dot-target).tmp $(dot-target).cmd, @:) + mv -f $(dot-target).tmp $(dot-target).cmd; # Usage: $(call if_changed_rule,foo) # Will check if $(cmd_foo) or any of the prerequisites changed, diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 90aed148c44..10f31a57a0f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -241,14 +241,17 @@ endif define rule_cc_o_c $(call echo-cmd,checksrc) $(cmd_checksrc) \ - $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ + $(call cmd_and_fixdep,cc_o_c) \ $(cmd_modversions) \ - $(call echo-cmd,record_mcount) \ - $(cmd_record_mcount) \ - scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ - $(dot-target).tmp; \ - rm -f $(depfile); \ - mv -f $(dot-target).tmp $(dot-target).cmd + $(cmd_objtool) \ + $(call echo-cmd,record_mcount) $(cmd_record_mcount) +endef + +define rule_as_o_S + $(call cmd_and_fixdep,as_o_S) + $(call cmd,gen_ksymdeps) + $(call cmd,objtool) + $(call cmd,modversions_S) endef # Built-in and composite module parts -- cgit v1.2.3 From 31811fbb6b164ad7be63cb34146a63334b3689b8 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:13 +0300 Subject: kbuild: disable dtc simple_bus_reg warnings by default Backport changes from the kernel commit 70523a3ce5ff ("kbuild: disable dtc simple_bus_reg warnings by default") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.lib | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 83fd5ff6c31..2422ac980a4 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -302,6 +302,7 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \ -Wno-alias_paths \ -Wno-graph_child_address \ -Wno-graph_port \ + -Wno-simple_bus_reg \ -Wno-unique_unit_address \ -Wno-simple_bus_reg \ -Wno-pci_device_reg -- cgit v1.2.3 From 1ecfa813bb2d8793e80f55278fea293e2329353b Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:14 +0300 Subject: kbuild: Enable dtc graph_port warning by default Backport changes from the kernel commit a2237fec1e06 ("kbuild: Enable dtc graph_port warning by default") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.lib | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 2422ac980a4..c3c6c941bef 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -301,7 +301,6 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \ -Wno-avoid_unnecessary_addr_size \ -Wno-alias_paths \ -Wno-graph_child_address \ - -Wno-graph_port \ -Wno-simple_bus_reg \ -Wno-unique_unit_address \ -Wno-simple_bus_reg \ -- cgit v1.2.3 From 14795eba8bb3e138314d10313e95cc0862f98736 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:15 +0300 Subject: kbuild: remove redundant 'set -e' from filechk_offsets Backport changes from the kernel commit f3fd4a3f3a38 ("kbuild: remove redundant 'set -e' from filechk_offsets") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index c3c6c941bef..a2b3b2e6387 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -718,7 +718,7 @@ endef # Use filechk to avoid rebuilds when a header changes, but the resulting file # does not define filechk_offsets - (set -e; \ + ( \ echo "#ifndef $2"; \ echo "#define $2"; \ echo "/*"; \ -- cgit v1.2.3 From cfccf25100c26cb98d537106f0756363cb0647c6 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:16 +0300 Subject: kbuild: remove redundant target cleaning on failure Bacport from the kernel commit 172caf1993b7 ("kbuild: remove redundant target cleaning on failure") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.lib | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index a2b3b2e6387..7690cc61f9a 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -288,8 +288,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ # --------------------------------------------------------------------------- quiet_cmd_gzip = GZIP $@ -cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \ - (rm -f $@ ; false) +cmd_gzip = cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@ # DTC # --------------------------------------------------------------------------- @@ -562,26 +561,22 @@ printf "%08x\n" $$dec_size | \ quiet_cmd_bzip2 = BZIP2 $@ cmd_bzip2 = (cat $(filter-out FORCE,$^) | \ - bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ - (rm -f $@ ; false) + bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ # Lzma # --------------------------------------------------------------------------- quiet_cmd_lzma = LZMA $@ cmd_lzma = (cat $(filter-out FORCE,$^) | \ - lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ - (rm -f $@ ; false) + lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ quiet_cmd_lzo = LZO $@ cmd_lzo = (cat $(filter-out FORCE,$^) | \ - lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ - (rm -f $@ ; false) + lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ quiet_cmd_lz4 = LZ4 $@ cmd_lz4 = (cat $(filter-out FORCE,$^) | \ - lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ - (rm -f $@ ; false) + lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ # U-Boot mkimage # --------------------------------------------------------------------------- @@ -627,13 +622,11 @@ quiet_cmd_uimage = UIMAGE $(UIMAGE_OUT) quiet_cmd_xzkern = XZKERN $@ cmd_xzkern = (cat $(filter-out FORCE,$^) | \ sh $(srctree)/scripts/xz_wrap.sh && \ - $(call size_append, $(filter-out FORCE,$^))) > $@ || \ - (rm -f $@ ; false) + $(call size_append, $(filter-out FORCE,$^))) > $@ quiet_cmd_xzmisc = XZMISC $@ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ - xz --check=crc32 --lzma2=dict=1MiB) > $@ || \ - (rm -f $@ ; false) + xz --check=crc32 --lzma2=dict=1MiB) > $@ # Additional commands for U-Boot # -- cgit v1.2.3 From 3d21332c2f3e299836fc55d69887aa88168ac567 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:17 +0300 Subject: kbuild: skip 'addtree' and 'flags' magic for external module build Backport from kernel commit 58156ba4468f ("kbuild: skip 'addtree' and 'flags' magic for external module build") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.host | 6 ++++-- scripts/Makefile.lib | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 7624304e3e9..bd5ed4c63b7 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -72,13 +72,15 @@ _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ $(HOSTCXXFLAGS_$(basetarget).o) -ifeq ($(KBUILD_SRC),) __hostc_flags = $(_hostc_flags) __hostcxx_flags = $(_hostcxx_flags) -else + +ifeq ($(KBUILD_EXTMOD),) +ifneq ($(KBUILD_SRC),) __hostc_flags = -I$(obj) $(call flags,_hostc_flags) __hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) endif +endif hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 7690cc61f9a..f1a78886e84 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -143,15 +143,14 @@ _c_flags += $(if $(patsubst n%,, \ $(CFLAGS_KASAN)) endif -# If building the kernel in a separate objtree expand all occurrences -# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). - -ifeq ($(KBUILD_SRC),) __c_flags = $(_c_flags) __a_flags = $(_a_flags) __cpp_flags = $(_cpp_flags) -else +# If building the kernel in a separate objtree expand all occurrences +# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). +ifeq ($(KBUILD_EXTMOD),) +ifneq ($(KBUILD_SRC),) # -I$(obj) locates generated .h files # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files # and locates generated .h files @@ -161,6 +160,7 @@ __c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \ __a_flags = $(call flags,_a_flags) __cpp_flags = $(call flags,_cpp_flags) endif +endif # Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ -- cgit v1.2.3 From 39160c5fbf7b724b4113a8918b9fa3790d080a5c Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:18 +0300 Subject: kbuild: simplify rules of data compression with size appending Backport kernel changes commit ecbd10d90e94 ("kbuild: simplify rules of data compression with size appending") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.lib | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index f1a78886e84..6d0cb8e6513 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -546,7 +546,7 @@ $(obj)/dsdt_generated.c: $(src)/dsdt.asl # append the size as a 32-bit littleendian number as gzip does. size_append = printf $(shell \ dec_size=0; \ -for F in $1; do \ +for F in $(filter-out FORCE,$^); do fsize=$$(stat -c "%s" $$F); \ dec_size=$$(expr $$dec_size + $$fsize); \ done; \ @@ -560,23 +560,20 @@ printf "%08x\n" $$dec_size | \ ) quiet_cmd_bzip2 = BZIP2 $@ -cmd_bzip2 = (cat $(filter-out FORCE,$^) | \ - bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ +cmd_bzip2 = (cat $(filter-out FORCE,$^) | bzip2 -9 && $(size_append)) > $@ # Lzma # --------------------------------------------------------------------------- quiet_cmd_lzma = LZMA $@ -cmd_lzma = (cat $(filter-out FORCE,$^) | \ - lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ +cmd_lzma = (cat $(filter-out FORCE,$^) | lzma -9 && $(size_append)) > $@ quiet_cmd_lzo = LZO $@ -cmd_lzo = (cat $(filter-out FORCE,$^) | \ - lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ +cmd_lzo = (cat $(filter-out FORCE,$^) | lzop -9 && $(size_append)) > $@ quiet_cmd_lz4 = LZ4 $@ -cmd_lz4 = (cat $(filter-out FORCE,$^) | \ - lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ +cmd_lz4 = (cat $(filter-out FORCE,$^) | lz4c -l -c1 stdin stdout && \ + $(size_append)) > $@ # U-Boot mkimage # --------------------------------------------------------------------------- @@ -621,8 +618,7 @@ quiet_cmd_uimage = UIMAGE $(UIMAGE_OUT) # decompression mode. A BCJ filter isn't used either. quiet_cmd_xzkern = XZKERN $@ cmd_xzkern = (cat $(filter-out FORCE,$^) | \ - sh $(srctree)/scripts/xz_wrap.sh && \ - $(call size_append, $(filter-out FORCE,$^))) > $@ + sh $(srctree)/scripts/xz_wrap.sh && $(size_append)) > $@ quiet_cmd_xzmisc = XZMISC $@ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ -- cgit v1.2.3 From a73c41c398a1cbbe9aa7ffb644729e6cf7595845 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:19 +0300 Subject: kbuild: add real-prereqs shorthand for $(filter-out FORCE, $^) Backport from kernel commit afa974b77128 ("kbuild: add real-prereqs shorthand for $(filter-out FORCE,$^)") Signed-off-by: Ilias Apalodimas --- scripts/Kbuild.include | 4 ++++ scripts/Makefile.build | 2 +- scripts/Makefile.lib | 10 +++++----- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 7468223d323..2ef687ea895 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -27,6 +27,10 @@ basetarget = $(basename $(notdir $@)) # filename of first prerequisite with directory and extension stripped baseprereq = $(basename $(notdir $<)) +### +# real prerequisites without phony targets +real-prereqs = $(filter-out $(PHONY), $^) + ### # Escape single quote for use in echo statements escsq = $(subst $(squote),'\$(squote)',$1) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 10f31a57a0f..73e1d71e30d 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -356,7 +356,7 @@ $(modorder-target): $(subdir-ym) FORCE # ifdef lib-target quiet_cmd_link_l_target = AR $@ -cmd_link_l_target = rm -f $@; $(AR) cDPrsT$(KBUILD_ARFLAGS) $@ $(lib-y) +cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) $(lib-target): $(lib-y) FORCE $(call if_changed,link_l_target) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 6d0cb8e6513..4861b1332c3 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -546,7 +546,7 @@ $(obj)/dsdt_generated.c: $(src)/dsdt.asl # append the size as a 32-bit littleendian number as gzip does. size_append = printf $(shell \ dec_size=0; \ -for F in $(filter-out FORCE,$^); do +for F in $(real-prereqs); do fsize=$$(stat -c "%s" $$F); \ dec_size=$$(expr $$dec_size + $$fsize); \ done; \ @@ -560,19 +560,19 @@ printf "%08x\n" $$dec_size | \ ) quiet_cmd_bzip2 = BZIP2 $@ -cmd_bzip2 = (cat $(filter-out FORCE,$^) | bzip2 -9 && $(size_append)) > $@ +cmd_bzip2 = (cat $(real-prereqs) | bzip2 -9 && $(size_append)) > $@ # Lzma # --------------------------------------------------------------------------- quiet_cmd_lzma = LZMA $@ -cmd_lzma = (cat $(filter-out FORCE,$^) | lzma -9 && $(size_append)) > $@ +cmd_lzma = (cat $(real-prereqs) | lzma -9 && $(size_append)) > $@ quiet_cmd_lzo = LZO $@ -cmd_lzo = (cat $(filter-out FORCE,$^) | lzop -9 && $(size_append)) > $@ +cmd_lzo = (cat $(real-prereqs) | lzop -9 && $(size_append)) > $@ quiet_cmd_lz4 = LZ4 $@ -cmd_lz4 = (cat $(filter-out FORCE,$^) | lz4c -l -c1 stdin stdout && \ +cmd_lz4 = (cat $(real-prereqs) | lz4c -l -c1 stdin stdout && \ $(size_append)) > $@ # U-Boot mkimage -- cgit v1.2.3 From 603a4ade16069851b6005591426e36edd9c465cc Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:20 +0300 Subject: kbuild: remove unnecessary in-subshell execution Backport kernel changes commit b79c6aa6a1f1 ("kbuild: remove unnecessary in-subshell execution") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.lib | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 4861b1332c3..28295c7ff12 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -324,7 +324,7 @@ DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@) quiet_cmd_dt_S_dtb= DTBS $@ # Modified for U-Boot cmd_dt_S_dtb= \ -( \ +{ \ echo '.section .dtb.init.rodata,"a"'; \ echo '.balign 16'; \ echo '.global __dtb_$(subst -,_,$(*F))_begin'; \ @@ -333,7 +333,7 @@ cmd_dt_S_dtb= \ echo '__dtb_$(subst -,_,$(*F))_end:'; \ echo '.global __dtb_$(subst -,_,$(*F))_end'; \ echo '.balign 16'; \ -) > $@ +} > $@ $(obj)/%.dtb.S: $(obj)/%.dtb $(call cmd,dt_S_dtb) @@ -560,20 +560,20 @@ printf "%08x\n" $$dec_size | \ ) quiet_cmd_bzip2 = BZIP2 $@ -cmd_bzip2 = (cat $(real-prereqs) | bzip2 -9 && $(size_append)) > $@ +cmd_bzip2 = { cat $(real-prereqs) | bzip2 -9 && $(size_append); } > $@ # Lzma # --------------------------------------------------------------------------- quiet_cmd_lzma = LZMA $@ -cmd_lzma = (cat $(real-prereqs) | lzma -9 && $(size_append)) > $@ +cmd_lzma = { cat $(real-prereqs) | lzma -9 && $(size_append); } > $@ quiet_cmd_lzo = LZO $@ -cmd_lzo = (cat $(real-prereqs) | lzop -9 && $(size_append)) > $@ +cmd_lzo = { cat $(real-prereqs) | lzop -9 && $(size_append); } > $@ quiet_cmd_lz4 = LZ4 $@ -cmd_lz4 = (cat $(real-prereqs) | lz4c -l -c1 stdin stdout && \ - $(size_append)) > $@ +cmd_lz4 = { cat $(real-prereqs) | lz4c -l -c1 stdin stdout && \ + $(size_append); } > $@ # U-Boot mkimage # --------------------------------------------------------------------------- @@ -617,12 +617,11 @@ quiet_cmd_uimage = UIMAGE $(UIMAGE_OUT) # big dictionary would increase the memory usage too much in the multi-call # decompression mode. A BCJ filter isn't used either. quiet_cmd_xzkern = XZKERN $@ -cmd_xzkern = (cat $(filter-out FORCE,$^) | \ - sh $(srctree)/scripts/xz_wrap.sh && $(size_append)) > $@ +cmd_xzkern = { cat $(filter-out FORCE,$^) | \ + sh $(srctree)/scripts/xz_wrap.sh && $(size_append); } > $@ quiet_cmd_xzmisc = XZMISC $@ -cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ - xz --check=crc32 --lzma2=dict=1MiB) > $@ +cmd_xzmisc = cat $(real-prereqs) | xz --check=crc32 --lzma2=dict=1MiB > $@ # Additional commands for U-Boot # -- cgit v1.2.3 From 47a4770c7a2f6dab7ada9ba77b12bd41939db551 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:21 +0300 Subject: kbuild: move archive command to scripts/Makefile.lib Backport from kernel commit 898f5a009f22 ("kbuild: move archive command to scripts/Makefile.lib") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.build | 4 +--- scripts/Makefile.lib | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 73e1d71e30d..d90b0b7aa6a 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -355,11 +355,9 @@ $(modorder-target): $(subdir-ym) FORCE # Rule to compile a set of .o files into one .a file # ifdef lib-target -quiet_cmd_link_l_target = AR $@ -cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) $(lib-target): $(lib-y) FORCE - $(call if_changed,link_l_target) + $(call if_changed,ar) targets += $(lib-target) endif diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 28295c7ff12..c441be352da 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -278,6 +278,11 @@ $(obj)/%: $(src)/%_shipped quiet_cmd_ld = LD $@ cmd_ld = $(LD) $(ld_flags) $(filter-out FORCE,$^) -o $@ +# Archive +# --------------------------------------------------------------------------- +quiet_cmd_ar = AR $@ +cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) + # Objcopy # --------------------------------------------------------------------------- -- cgit v1.2.3 From cc571e29a8ecbba909cbb04ba062db026f70ae8b Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:22 +0300 Subject: kbuild: let fixdep directly write to .*.cmd files Backport from kernel commit 392885ee82d3 ("kbuild: let fixdep directly write to .*.cmd files") Signed-off-by: Ilias Apalodimas --- scripts/Kbuild.include | 5 ++--- scripts/Makefile.build | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 2ef687ea895..6ef66c451eb 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -274,9 +274,8 @@ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ cmd_and_fixdep = \ $(echo-cmd) $(cmd_$(1)); \ - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ - rm -f $(depfile); \ - mv -f $(dot-target).tmp $(dot-target).cmd; + scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ + rm -f $(depfile) # Usage: $(call if_changed_rule,foo) # Will check if $(cmd_foo) or any of the prerequisites changed, diff --git a/scripts/Makefile.build b/scripts/Makefile.build index d90b0b7aa6a..2f2d5d4afc2 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -410,14 +410,17 @@ FORCE: # optimization, we don't need to read them if the target does not # exist, we will rebuild anyway in that case. -cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) +existing-targets := $(wildcard $(sort $(targets))) -ifneq ($(cmd_files),) - include $(cmd_files) -endif +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) # Create directories for object files if they do not exist obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets)))) +# If targets exist, their directories apparently exist. Skip mkdir. +existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets)))) +obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs))) +ifneq ($(obj-dirs),) $(shell mkdir -p $(obj-dirs)) +endif .PHONY: $(PHONY) -- cgit v1.2.3 From 2c180949ec3e924020edbff00884f206e120b028 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:23 +0300 Subject: kbuild: remove redundant 'set -e' from sub_cmd_record_mcount Back from kernel commit 4317ee3b6a5e ("kbuild: remove redundant 'set -e' from sub_cmd_record_mcount") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 2f2d5d4afc2..b2bf5a2c000 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -223,7 +223,7 @@ sub_cmd_record_mcount = \ recordmcount_source := $(srctree)/scripts/recordmcount.c \ $(srctree)/scripts/recordmcount.h else -sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ +sub_cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ "$(if $(CONFIG_SYS_BIG_ENDIAN),big,little)" \ "$(if $(CONFIG_64BIT),64,32)" \ "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)" \ -- cgit v1.2.3 From 3679f24373d609b59e6434afb5253fd8c7af730a Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:24 +0300 Subject: kbuild: refactor modversions build rules Backport from kernel commit ee3e46b7efd2 ("kbuild: refactor modversions build rules") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.build | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index b2bf5a2c000..639091e7b29 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -171,34 +171,30 @@ $(obj)/%.symtypes : $(src)/%.c FORCE # (See cmd_cc_o_c + relevant part of rule_cc_o_c) quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ - -ifndef CONFIG_MODVERSIONS cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< -else +ifdef CONFIG_MODVERSIONS # When module versioning is enabled the following steps are executed: -# o compile a .tmp_.o from .c -# o if .tmp_.o doesn't contain a __ksymtab version, i.e. does -# not export symbols, we just rename .tmp_.o to .o and -# are done. +# o compile a .o from .c +# o if .o doesn't contain a __ksymtab version, i.e. does +# not export symbols, it's done # o otherwise, we calculate symbol versions using the good old # genksyms on the preprocessed source and postprocess them in a way # that they are usable as a linker script -# o generate .o from .tmp_.o using the linker to +# o generate .tmp_.o from .o using the linker to # replace the unresolved symbols __crc_exported_symbol with # the actual value of the checksum generated by genksyms -cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< +# o remove .tmp_.o to .o cmd_modversions = \ - if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ + if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \ $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ > $(@D)/.tmp_$(@F:.o=.ver); \ \ - $(LD) $(KBUILD_LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ + $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \ -T $(@D)/.tmp_$(@F:.o=.ver); \ - rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ - else \ mv -f $(@D)/.tmp_$(@F) $@; \ + rm -f $(@D)/.tmp_$(@F:.o=.ver); \ fi; endif -- cgit v1.2.3 From daf8f5af4c9e542ac75b2ddf7f2831b73833b49d Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:25 +0300 Subject: kbuild: change if_changed_rule for multi-line recipe Backport from kernel commit 3a2429e1faf4 ("kbuild: change if_changed_rule for multi-line recipe") Signed-off-by: Ilias Apalodimas --- scripts/Kbuild.include | 12 ++++-------- scripts/Makefile.build | 12 +++++++----- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 6ef66c451eb..c0d3440a4b3 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -226,7 +226,7 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\ echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';) # printing commands -cmd = @$(echo-cmd) $(cmd_$(1)) +cmd = @set -e; $(echo-cmd) $(cmd_$(1)) # Add $(obj)/ for paths that are not absolute objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) @@ -268,21 +268,17 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) # Execute the command and also postprocess generated .d dependencies file. -if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ - @set -e; \ - $(cmd_and_fixdep), @:) +if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)),$(cmd_and_fixdep),@:) cmd_and_fixdep = \ - $(echo-cmd) $(cmd_$(1)); \ + $(cmd); \ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ rm -f $(depfile) # Usage: $(call if_changed_rule,foo) # Will check if $(cmd_foo) or any of the prerequisites changed, # and if so will execute $(rule_foo). -if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ - @set -e; \ - $(rule_$(1)), @:) +if_changed_rule = $(if $(strip $(any-prereq) $(arg-check)),$(rule_$(1)),@:) ### # why - tell why a a target got build diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 639091e7b29..59ff37a5320 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -236,11 +236,13 @@ endif # -record-mcount endif define rule_cc_o_c - $(call echo-cmd,checksrc) $(cmd_checksrc) \ - $(call cmd_and_fixdep,cc_o_c) \ - $(cmd_modversions) \ - $(cmd_objtool) \ - $(call echo-cmd,record_mcount) $(cmd_record_mcount) + $(call cmd,checksrc) + $(call cmd_and_fixdep,cc_o_c) + $(call cmd,gen_ksymdeps) + $(call cmd,checkdoc) + $(call cmd,objtool) + $(call cmd,modversions_c) + $(call cmd,record_mcount) endef define rule_as_o_S -- cgit v1.2.3 From 82f75d890d7af1cecd30e6e9f675889b915e68ed Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:26 +0300 Subject: kbuild: remove trailing semicolon from cmd_* passed to if_changed_rule Backport from kernel commit e5d289100d3a ("kbuild: remove trailing semicolon from cmd_* passed to if_changed_rule") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 59ff37a5320..80caddde09a 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -94,10 +94,10 @@ __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ # Linus' kernel sanity checking tool ifeq ($(KBUILD_CHECKSRC),1) quiet_cmd_checksrc = CHECK $< - cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; + cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< else ifeq ($(KBUILD_CHECKSRC),2) quiet_cmd_force_checksrc = CHECK $< - cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; + cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< endif # Do section mismatch analysis for each module/built-in.o @@ -231,7 +231,7 @@ cmd_record_mcount = \ if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ "$(CC_FLAGS_FTRACE)" ]; then \ $(sub_cmd_record_mcount) \ - fi; + fi endif # -record-mcount endif -- cgit v1.2.3 From 919bd66ca8c966a30448d8befc7b59d58ba8d22d Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:27 +0300 Subject: kbuild: remove redundant 'set -e' from cmd_* defines Backported from kernel commit 5439f09f488f ("kbuild: remove redundant 'set -e' from cmd_* defines") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.build | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 80caddde09a..fa91445f132 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -159,7 +159,6 @@ cmd_gensymtypes = \ quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ cmd_cc_symtypes_c = \ - set -e; \ $(call cmd_gensymtypes,true,$@) >/dev/null; \ test -s $@ || rm -f $@ -- cgit v1.2.3 From 47b6ab973728bd99247c1bc31d9608304417dd9b Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:28 +0300 Subject: kbuild: remove redundant quiet_modtag for $(obj-m) Backported from kernel commit b39a691617e4 commit ("kbuild: remove redundant quiet_modtag for $(obj-m)") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.build | 2 -- 1 file changed, 2 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index fa91445f132..29446298041 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -125,8 +125,6 @@ $(real-objs-m:.o=.i) : quiet_modtag := [M] $(real-objs-m:.o=.s) : quiet_modtag := [M] $(real-objs-m:.o=.lst): quiet_modtag := [M] -$(obj-m) : quiet_modtag := [M] - # Default for not multi-part modules modname = $(basetarget) -- cgit v1.2.3 From 88067ffc0c6f8c4f5142a1f8d08a206f3ed49083 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:29 +0300 Subject: kbuild: refactor quiet_modtag Backport from kernel commit 45c4372d00 ("kbuild: refactor quiet_modtag") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.build | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 29446298041..ed58bcab291 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -113,18 +113,13 @@ modkern_cflags = \ $(if $(part-of-module), \ $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) -quiet_modtag := $(empty) $(empty) +quiet_modtag = $(if $(part-of-module),[M], ) $(real-objs-m) : part-of-module := y $(real-objs-m:.o=.i) : part-of-module := y $(real-objs-m:.o=.s) : part-of-module := y $(real-objs-m:.o=.lst): part-of-module := y -$(real-objs-m) : quiet_modtag := [M] -$(real-objs-m:.o=.i) : quiet_modtag := [M] -$(real-objs-m:.o=.s) : quiet_modtag := [M] -$(real-objs-m:.o=.lst): quiet_modtag := [M] - # Default for not multi-part modules modname = $(basetarget) -- cgit v1.2.3 From 1a59e6d3ba8a2f63a27a1e69286affd0bdc66dbf Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:30 +0300 Subject: kbuild: generate modules.order only when CONFIG_MODULES=y Backport from kernel although it is unused since it makes diffing easier. commit 1d8001ef358 ("kbuild: generate modules.order only when CONFIG_MODULES=y") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.build | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index ed58bcab291..2b2beb01bd3 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -82,7 +82,9 @@ ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) builtin-target := $(obj)/built-in.o endif +ifdef CONFIG_MODULES modorder-target := $(obj)/modules.order +endif # We keep a list of all modules in $(MODVERDIR) -- cgit v1.2.3 From bb08767f12795ba72a93948aa2b5477ad548c511 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:31 +0300 Subject: kbuild: hardcode genksyms path and remove GENKSYMS variable Back port from kernel although it's not used since it makes diffing easier. commit 88110713ca9dfb ("kbuild: hardcode genksyms path and remove GENKSYMS variable") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 2b2beb01bd3..b7611c03008 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -148,7 +148,7 @@ $(obj)/%.i: $(src)/%.c FORCE cmd_gensymtypes = \ $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ - $(GENKSYMS) $(if $(1), -T $(2)) \ + scripts/genksyms/genksyms $(if $(1), -T $(2)) \ $(if $(KBUILD_PRESERVE),-p) \ -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) -- cgit v1.2.3 From 25ab30f1c46efc8d2c11b01013449c09815a3f65 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:32 +0300 Subject: kbuild: strip whitespace in cmd_record_mcount findstring Backport from kernel commit 1a49b2fd8f58 ("kbuild: strip whitespace in cmd_record_mcount findstring") Signed-off-by: Ilias Apalodimas --- scripts/Makefile.build | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index b7611c03008..aa48d249433 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -221,11 +221,8 @@ sub_cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ "$(if $(part-of-module),1,0)" "$(@)"; recordmcount_source := $(srctree)/scripts/recordmcount.pl endif -cmd_record_mcount = \ - if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ - "$(CC_FLAGS_FTRACE)" ]; then \ - $(sub_cmd_record_mcount) \ - fi +cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), \ + $(sub_cmd_record_mcount)) endif # -record-mcount endif -- cgit v1.2.3 From ef0eec3fa91840ab8147dbb1c44b859879cb306b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Mon, 26 May 2025 07:35:10 -0600 Subject: scripts/setlocalversion: sync with linux v6.15 The changes upstream since the last sync at commit 5c02350fa03d ("scripts/setlocalversion: sync with linux v6.9") are e2ff1219a554 setlocalversion: add -e option 523f3dbc187a setlocalversion: work around "git describe" performance Signed-off-by: Tom Rini --- scripts/setlocalversion | 58 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 16 deletions(-) (limited to 'scripts') diff --git a/scripts/setlocalversion b/scripts/setlocalversion index dbe048210d6..9ed3f56bebf 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -10,6 +10,8 @@ # # +set -e + usage() { echo "Usage: $0 [--no-local] [srctree]" >&2 exit 1 @@ -30,6 +32,29 @@ if test $# -gt 0 -o ! -d "$srctree"; then usage fi +try_tag() { + tag="$1" + + # Is $tag an annotated tag? + if [ "$(git cat-file -t "$tag" 2> /dev/null)" != tag ]; then + return + fi + + # Is it an ancestor of HEAD, and if so, how many commits are in $tag..HEAD? + # shellcheck disable=SC2046 # word splitting is the point here + set -- $(git rev-list --count --left-right "$tag"...HEAD 2> /dev/null) + + # $1 is 0 if and only if $tag is an ancestor of HEAD. Use + # string comparison, because $1 is empty if the 'git rev-list' + # command somehow failed. + if [ "$1" != 0 ]; then + return + fi + + # $2 is the number of commits in the range $tag..HEAD, possibly 0. + count="$2" +} + scm_version() { local short=false @@ -61,33 +86,33 @@ scm_version() # stable kernel: 6.1.7 -> v6.1.7 version_tag=v$(echo "${KERNELVERSION}" | sed -E 's/^([0-9]+\.[0-9]+)\.0(.*)$/\1\2/') + # try_tag initializes count if the tag is usable. + count= + # If a localversion* file exists, and the corresponding # annotated tag exists and is an ancestor of HEAD, use # it. This is the case in linux-next. - tag=${file_localversion#-} - desc= - if [ -n "${tag}" ]; then - desc=$(git describe --match=$tag 2>/dev/null) + if [ -n "${file_localversion#-}" ] ; then + try_tag "${file_localversion#-}" fi # Otherwise, if a localversion* file exists, and the tag # obtained by appending it to the tag derived from # KERNELVERSION exists and is an ancestor of HEAD, use # it. This is e.g. the case in linux-rt. - if [ -z "${desc}" ] && [ -n "${file_localversion}" ]; then - tag="${version_tag}${file_localversion}" - desc=$(git describe --match=$tag 2>/dev/null) + if [ -z "${count}" ] && [ -n "${file_localversion}" ]; then + try_tag "${version_tag}${file_localversion}" fi # Otherwise, default to the annotated tag derived from KERNELVERSION. - if [ -z "${desc}" ]; then - tag="${version_tag}" - desc=$(git describe --match=$tag 2>/dev/null) + if [ -z "${count}" ]; then + try_tag "${version_tag}" fi - # If we are at the tagged commit, we ignore it because the version is - # well-defined. - if [ "${tag}" != "${desc}" ]; then + # If we are at the tagged commit, we ignore it because the + # version is well-defined. If none of the attempted tags exist + # or were usable, $count is still empty. + if [ -z "${count}" ] || [ "${count}" -gt 0 ]; then # If only the short version is requested, don't bother # running further git commands @@ -95,14 +120,15 @@ scm_version() echo "+" return fi + # If we are past the tagged commit, we pretty print it. # (like 6.1.0-14595-g292a089d78d3) - if [ -n "${desc}" ]; then - echo "${desc}" | awk -F- '{printf("-%05d", $(NF-1))}' + if [ -n "${count}" ]; then + printf "%s%05d" "-" "${count}" fi # Add -g and exactly 12 hex chars. - printf '%s%s' -g "$(echo $head | cut -c1-12)" + printf '%s%.12s' -g "$head" fi if ${no_dirty}; then -- cgit v1.2.3 From c9b452acd95312e3ca2a44c6b969399f191764bb Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Wed, 28 May 2025 17:27:04 -0600 Subject: scripts/Makefile.lib: Rework upstream_dtsi_include to get subdirectories A problem with the logic in upstream_dtsi_include currently is that it does not list directories such as dts/upstream/src/arm/nxp/imx and so will not findi "imx6ul-pinfunc.h" for example as it is normally and correctly included without vendor sub-paths. Expand the current wildcard glob to catch these directories too. Reviewed-by: Peter Robinson Signed-off-by: Tom Rini --- scripts/Makefile.lib | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index e89a4a51b74..ac14e4f9dfb 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -205,8 +205,10 @@ dtsi_include_list = $(strip $(u_boot_dtsi_options_debug) \ # Modified for U-Boot upstream_dtsi_include = $(addprefix -I, $(srctree)/dts/upstream/src/ \ $(sort $(dir $(wildcard $(srctree)/dts/upstream/src/$(ARCH)/*/*))) \ + $(sort $(dir $(wildcard $(srctree)/dts/upstream/src/$(ARCH)/*/*/*))) \ $(if (CONFIG_ARM64), \ - $(sort $(dir $(wildcard $(srctree)/dts/upstream/src/arm64/*/*))))) + $(sort $(dir $(wildcard $(srctree)/dts/upstream/src/arm64/*/*))) \ + $(sort $(dir $(wildcard $(srctree)/dts/upstream/src/arm64/*/*/*))))) dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ $(UBOOTINCLUDE) \ -I$(dir $<) \ -- cgit v1.2.3 From a76fb6981fb502717c7a5b7a601ef5c4c4dc17a0 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Wed, 11 Jun 2025 23:24:30 +0300 Subject: kbuild: use assignment instead of define ... endef for filechk_* rules Backported from kernel commit ba97df45581f ("kbuild: use assignment instead of define ... endef for filechk_* rules") Signed-off-by: Ilias Apalodimas --- scripts/Kbuild.include | 7 +++---- scripts/kconfig/Makefile | 4 +--- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index c0d3440a4b3..fd7a744478f 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -49,11 +49,10 @@ kecho := $($(quiet)kecho) ### # filechk is used to check if the content of a generated file is updated. # Sample usage: -# define filechk_sample -# echo $KERNELRELEASE -# endef -# version.h : Makefile +# filechk_sample = echo $(KERNELRELEASE) +# version.h: FORCE # $(call filechk,sample) +# # The rule defined shall write to stdout the content of the new file. # The existing file will be compared with the new one. # - If no file exist it is created diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index ba30652f01a..f0f93c56bdb 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -220,9 +220,7 @@ $(obj)/gconf.o: $(obj)/.gconf-cfg $(obj)/zconf.tab.o: $(obj)/zconf.lex.c # check if necessary packages are available, and configure build flags -define filechk_conf_cfg - $(CONFIG_SHELL) $< -endef +filechk_conf_cfg = $(CONFIG_SHELL) $< $(obj)/.%conf-cfg: $(src)/%conf-cfg.sh FORCE $(call filechk,conf_cfg) -- cgit v1.2.3 From 5ba5cbf5a29d54763f30b6685e6c06ffd51d29eb Mon Sep 17 00:00:00 2001 From: Eric Schikschneit Date: Tue, 3 Jun 2025 12:06:24 -0500 Subject: dtc: Add Kconfig option to pad device tree blob This will allow arch(s) that use device tree blobs to pad the end of the device tree so they can be modified by board files at run time. This will help prevent errors such as FDT_ERR_NOSPACE from occurring. Signed-off-by: Eric Schikschneit [trini: Change default order so that X86 && EFI_APP works correctly] --- scripts/Makefile.dts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts') diff --git a/scripts/Makefile.dts b/scripts/Makefile.dts index 685e3371bc6..3871a4ad412 100644 --- a/scripts/Makefile.dts +++ b/scripts/Makefile.dts @@ -16,6 +16,10 @@ dtb-y += $(subst $(dt_dir)/,,$(dtb-vendor_dts)) endif +ifneq ($(CONFIG_SYS_DTC_PAD_BYTES),0) +DTC_FLAGS += -p $(CONFIG_SYS_DTC_PAD_BYTES) +endif + targets += $(dtb-y) PHONY += dtbs -- cgit v1.2.3