Skip to contentSkip to conversation

sh: boot: add intermediate vmlinux.bin* to targets instead of extra-y

PATCH In review Masahiro Yamada 2 participants 7 messages Jan 17, 2021 – Jan 18, 2021 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 sh: boot: add intermediate vmlinux.bin* to targets instead of extra-y

You do not need to build all of vmlinux.bin*

They are built on demand as prerequsites of uImage.bin*, hence should be added to targets instead of extra-y.

---

 arch/sh/boot/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sh/boot/Makefile +2 -2
index 58592dfa5cb6..dded61296c9a 100644
@@ -27,8 +27,8 @@ suffix-$(CONFIG_KERNEL_XZ)	:= xz
 suffix-$(CONFIG_KERNEL_LZO)	:= lzo
 
 targets := zImage vmlinux.srec romImage uImage uImage.srec uImage.gz \
-	   uImage.bz2 uImage.lzma uImage.xz uImage.lzo uImage.bin
-extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
+	   uImage.bz2 uImage.lzma uImage.xz uImage.lzo uImage.bin \
+	   vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
 	   vmlinux.bin.xz vmlinux.bin.lzo
 subdir- := compressed romimage
 
Signature · 1 line
2.27.0
#1 lore raw

PATCH 2/2 sh: boot: avoid unneeded rebuilds under arch/sh/boot/compressed/

Even if none of source code is updated, the following are every time rebuilt:

CC arch/sh/boot/compressed/cache.o
SHIPPED arch/sh/boot/compressed/ashiftrt.S
AS arch/sh/boot/compressed/ashiftrt.o
SHIPPED arch/sh/boot/compressed/ashldi3.c
CC arch/sh/boot/compressed/ashldi3.o
SHIPPED arch/sh/boot/compressed/ashrsi3.S
AS arch/sh/boot/compressed/ashrsi3.o
SHIPPED arch/sh/boot/compressed/ashlsi3.S
AS arch/sh/boot/compressed/ashlsi3.o
SHIPPED arch/sh/boot/compressed/lshrsi3.S
AS arch/sh/boot/compressed/lshrsi3.o
LD arch/sh/boot/compressed/vmlinux
OBJCOPY arch/sh/boot/zImage

Add build artifacts to 'targets' as needed.

I turned the library files to check-in files. It is simpler than copying from arch/sh/lib/ at build-time.

---

 arch/sh/boot/compressed/.gitignore |  5 -----
 arch/sh/boot/compressed/Makefile   | 32 ++++++++++++------------------
 arch/sh/boot/compressed/ashiftrt.S |  2 ++
 arch/sh/boot/compressed/ashldi3.c  |  2 ++
 arch/sh/boot/compressed/ashlsi3.S  |  2 ++
 arch/sh/boot/compressed/ashrsi3.S  |  2 ++
 arch/sh/boot/compressed/lshrsi3.S  |  2 ++
 7 files changed, 23 insertions(+), 24 deletions(-)
 create mode 100644 arch/sh/boot/compressed/ashiftrt.S
 create mode 100644 arch/sh/boot/compressed/ashldi3.c
 create mode 100644 arch/sh/boot/compressed/ashlsi3.S
 create mode 100644 arch/sh/boot/compressed/ashrsi3.S
 create mode 100644 arch/sh/boot/compressed/lshrsi3.S
arch/sh/boot/compressed/.gitignore +0 -5
index 37aa53057369..cd16663bc7c8 100644
@@ -1,7 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-ashiftrt.S
-ashldi3.c
-ashlsi3.S
-ashrsi3.S
-lshrsi3.S
 vmlinux.bin.*
arch/sh/boot/compressed/Makefile +13 -19
index 589d2d8a573d..cf3174df7859 100644
@@ -5,12 +5,18 @@
 # create a compressed vmlinux image from the original vmlinux
 #
 
-targets		:= vmlinux vmlinux.bin vmlinux.bin.gz \
-		   vmlinux.bin.bz2 vmlinux.bin.lzma \
-		   vmlinux.bin.xz vmlinux.bin.lzo \
-		   head_32.o misc.o piggy.o
+OBJECTS := head_32.o misc.o cache.o piggy.o \
+           ashiftrt.o ashldi3.o ashrsi3.o ashlsi3.o lshrsi3.o
+
+# These were previously generated 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.
+ifdef building_out_of_srctree
+$(shell rm -f $(addprefix $(obj)/, ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S lshrsi3.S))
+endif
 
-OBJECTS = $(obj)/head_32.o $(obj)/misc.o $(obj)/cache.o
+targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
+           vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo $(OBJECTS)
 
 GCOV_PROFILE := n
 
@@ -33,21 +39,9 @@ ccflags-remove-$(CONFIG_MCOUNT) += -pg
 LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \
 		   -T $(obj)/../../kernel/vmlinux.lds
 
-#
-# Pull in the necessary libgcc bits from the in-kernel implementation.
-#
-lib1funcs-y	:= ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S lshrsi3.S
-lib1funcs-obj   := \
-	$(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y))))
-
-lib1funcs-dir		:= $(srctree)/arch/$(SRCARCH)/lib
-
-KBUILD_CFLAGS += -I$(lib1funcs-dir) -DDISABLE_BRANCH_PROFILING
-
-$(addprefix $(obj)/,$(lib1funcs-y)): $(obj)/%: $(lib1funcs-dir)/% FORCE
-	$(call cmd,shipped)
+KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
 
-$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(lib1funcs-obj) FORCE
+$(obj)/vmlinux: $(addprefix $(obj)/, $(OBJECTS)) FORCE
 	$(call if_changed,ld)
 
 $(obj)/vmlinux.bin: vmlinux FORCE
arch/sh/boot/compressed/ashiftrt.S new file +2 -0
new file mode 100644
index 000000000000..0f3b291a3f4b
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashiftrt.S"
arch/sh/boot/compressed/ashldi3.c new file +2 -0
new file mode 100644
index 000000000000..7cebd646df83
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include "../../lib/ashldi3.c"
arch/sh/boot/compressed/ashlsi3.S new file +2 -0
new file mode 100644
index 000000000000..e354262b275f
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashlsi3.S"
arch/sh/boot/compressed/ashrsi3.S new file +2 -0
new file mode 100644
index 000000000000..e564be9a4dcd
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashrsi3.S"
arch/sh/boot/compressed/lshrsi3.S new file +2 -0
new file mode 100644
index 000000000000..5a8281b7e516
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/lshrsi3.S"
Signature · 1 line
2.27.0
#2 lore raw

Re: [PATCH 2/2] sh: boot: avoid unneeded rebuilds under arch/sh/boot/compressed/

Hi Masahiro!

Quoted 141 lines · Masahiro Yamada

Even if none of source code is updated, the following are every time rebuilt:

CC arch/sh/boot/compressed/cache.o
SHIPPED arch/sh/boot/compressed/ashiftrt.S
AS arch/sh/boot/compressed/ashiftrt.o
SHIPPED arch/sh/boot/compressed/ashldi3.c
CC arch/sh/boot/compressed/ashldi3.o
SHIPPED arch/sh/boot/compressed/ashrsi3.S
AS arch/sh/boot/compressed/ashrsi3.o
SHIPPED arch/sh/boot/compressed/ashlsi3.S
AS arch/sh/boot/compressed/ashlsi3.o
SHIPPED arch/sh/boot/compressed/lshrsi3.S
AS arch/sh/boot/compressed/lshrsi3.o
LD arch/sh/boot/compressed/vmlinux
OBJCOPY arch/sh/boot/zImage

Add build artifacts to 'targets' as needed.

I turned the library files to check-in files. It is simpler than copying from arch/sh/lib/ at build-time.

---

 arch/sh/boot/compressed/.gitignore |  5 -----
 arch/sh/boot/compressed/Makefile   | 32 ++++++++++++------------------
 arch/sh/boot/compressed/ashiftrt.S |  2 ++
 arch/sh/boot/compressed/ashldi3.c  |  2 ++
 arch/sh/boot/compressed/ashlsi3.S  |  2 ++
 arch/sh/boot/compressed/ashrsi3.S  |  2 ++
 arch/sh/boot/compressed/lshrsi3.S  |  2 ++
 7 files changed, 23 insertions(+), 24 deletions(-)
 create mode 100644 arch/sh/boot/compressed/ashiftrt.S
 create mode 100644 arch/sh/boot/compressed/ashldi3.c
 create mode 100644 arch/sh/boot/compressed/ashlsi3.S
 create mode 100644 arch/sh/boot/compressed/ashrsi3.S
 create mode 100644 arch/sh/boot/compressed/lshrsi3.S
arch/sh/boot/compressed/.gitignore +0 -5
index 37aa53057369..cd16663bc7c8 100644
@@ -1,7 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-ashiftrt.S
-ashldi3.c
-ashlsi3.S
-ashrsi3.S
-lshrsi3.S
 vmlinux.bin.*
arch/sh/boot/compressed/Makefile +13 -19
index 589d2d8a573d..cf3174df7859 100644
@@ -5,12 +5,18 @@
 # create a compressed vmlinux image from the original vmlinux
 #
 
-targets		:= vmlinux vmlinux.bin vmlinux.bin.gz \
-		   vmlinux.bin.bz2 vmlinux.bin.lzma \
-		   vmlinux.bin.xz vmlinux.bin.lzo \
-		   head_32.o misc.o piggy.o
+OBJECTS := head_32.o misc.o cache.o piggy.o \
+           ashiftrt.o ashldi3.o ashrsi3.o ashlsi3.o lshrsi3.o
+
+# These were previously generated 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.
+ifdef building_out_of_srctree
+$(shell rm -f $(addprefix $(obj)/, ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S lshrsi3.S))
+endif
 
-OBJECTS = $(obj)/head_32.o $(obj)/misc.o $(obj)/cache.o
+targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
+           vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo $(OBJECTS)
 
 GCOV_PROFILE := n
 
@@ -33,21 +39,9 @@ ccflags-remove-$(CONFIG_MCOUNT) += -pg
 LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \
 		   -T $(obj)/../../kernel/vmlinux.lds
 
-#
-# Pull in the necessary libgcc bits from the in-kernel implementation.
-#
-lib1funcs-y	:= ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S lshrsi3.S
-lib1funcs-obj   := \
-	$(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y))))
-
-lib1funcs-dir		:= $(srctree)/arch/$(SRCARCH)/lib
-
-KBUILD_CFLAGS += -I$(lib1funcs-dir) -DDISABLE_BRANCH_PROFILING
-
-$(addprefix $(obj)/,$(lib1funcs-y)): $(obj)/%: $(lib1funcs-dir)/% FORCE
-	$(call cmd,shipped)
+KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
 
-$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(lib1funcs-obj) FORCE
+$(obj)/vmlinux: $(addprefix $(obj)/, $(OBJECTS)) FORCE
 	$(call if_changed,ld)
 
 $(obj)/vmlinux.bin: vmlinux FORCE
arch/sh/boot/compressed/ashiftrt.S new file +2 -0
new file mode 100644
index 000000000000..0f3b291a3f4b
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashiftrt.S"
arch/sh/boot/compressed/ashldi3.c new file +2 -0
new file mode 100644
index 000000000000..7cebd646df83
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include "../../lib/ashldi3.c"
arch/sh/boot/compressed/ashlsi3.S new file +2 -0
new file mode 100644
index 000000000000..e354262b275f
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashlsi3.S"
arch/sh/boot/compressed/ashrsi3.S new file +2 -0
new file mode 100644
index 000000000000..e564be9a4dcd
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashrsi3.S"
arch/sh/boot/compressed/lshrsi3.S new file +0 -0
new file mode 100644
index 000000000000..5a8281b7e516

arch/sh/boot/compressed/lshrsi3.S line 2

Quoted 2 lines
arch/sh/boot/compressed/lshrsi3.S new file +2 -0
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/lshrsi3.S"

This patch doesn't apply for me while the first one applies without problems:

glaubitz@epyc:..glaubitz/linux-git> git am ../sh-patches-2021/\[PATCH\ 1_2\]\ sh\:\ boot\:\ add\ intermediate\ vmlinux.bin\*\ to\ targets\ instead\ of\ extra-y.eml
Applying: sh: boot: add intermediate vmlinux.bin* to targets instead of extra-y
glaubitz@epyc:..glaubitz/linux-git> git am ../sh-patches-2021/\[PATCH\ 2_2\]\ sh\:\ boot\:\ avoid\ unneeded\ rebuilds\ under\ arch_sh_boot_compressed_.eml
Applying: sh: boot: avoid unneeded rebuilds under arch/sh/boot/compressed/
error: arch/sh/boot/compressed/ashiftrt.S: already exists in working directory
error: arch/sh/boot/compressed/ashldi3.c: already exists in working directory
error: arch/sh/boot/compressed/ashlsi3.S: already exists in working directory
error: arch/sh/boot/compressed/ashrsi3.S: already exists in working directory
error: arch/sh/boot/compressed/lshrsi3.S: already exists in working directory
Patch failed at 0001 sh: boot: avoid unneeded rebuilds under arch/sh/boot/compressed/
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
glaubitz@epyc:..glaubitz/linux-git>

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#3 lore raw

Re: [PATCH 2/2] sh: boot: avoid unneeded rebuilds under arch/sh/boot/compressed/

Quoted 150 lines · John Paul Adrian Glaubitz

Hi Masahiro!

Quoted 141 lines · Masahiro Yamada

Even if none of source code is updated, the following are every time rebuilt:

CC arch/sh/boot/compressed/cache.o
SHIPPED arch/sh/boot/compressed/ashiftrt.S
AS arch/sh/boot/compressed/ashiftrt.o
SHIPPED arch/sh/boot/compressed/ashldi3.c
CC arch/sh/boot/compressed/ashldi3.o
SHIPPED arch/sh/boot/compressed/ashrsi3.S
AS arch/sh/boot/compressed/ashrsi3.o
SHIPPED arch/sh/boot/compressed/ashlsi3.S
AS arch/sh/boot/compressed/ashlsi3.o
SHIPPED arch/sh/boot/compressed/lshrsi3.S
AS arch/sh/boot/compressed/lshrsi3.o
LD arch/sh/boot/compressed/vmlinux
OBJCOPY arch/sh/boot/zImage

Add build artifacts to 'targets' as needed.

I turned the library files to check-in files. It is simpler than copying from arch/sh/lib/ at build-time.

---

 arch/sh/boot/compressed/.gitignore |  5 -----
 arch/sh/boot/compressed/Makefile   | 32 ++++++++++++------------------
 arch/sh/boot/compressed/ashiftrt.S |  2 ++
 arch/sh/boot/compressed/ashldi3.c  |  2 ++
 arch/sh/boot/compressed/ashlsi3.S  |  2 ++
 arch/sh/boot/compressed/ashrsi3.S  |  2 ++
 arch/sh/boot/compressed/lshrsi3.S  |  2 ++
 7 files changed, 23 insertions(+), 24 deletions(-)
 create mode 100644 arch/sh/boot/compressed/ashiftrt.S
 create mode 100644 arch/sh/boot/compressed/ashldi3.c
 create mode 100644 arch/sh/boot/compressed/ashlsi3.S
 create mode 100644 arch/sh/boot/compressed/ashrsi3.S
 create mode 100644 arch/sh/boot/compressed/lshrsi3.S
arch/sh/boot/compressed/.gitignore +0 -5
index 37aa53057369..cd16663bc7c8 100644
@@ -1,7 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-ashiftrt.S
-ashldi3.c
-ashlsi3.S
-ashrsi3.S
-lshrsi3.S
 vmlinux.bin.*
arch/sh/boot/compressed/Makefile +13 -19
index 589d2d8a573d..cf3174df7859 100644
@@ -5,12 +5,18 @@
 # create a compressed vmlinux image from the original vmlinux
 #
 
-targets              := vmlinux vmlinux.bin vmlinux.bin.gz \
-                vmlinux.bin.bz2 vmlinux.bin.lzma \
-                vmlinux.bin.xz vmlinux.bin.lzo \
-                head_32.o misc.o piggy.o
+OBJECTS := head_32.o misc.o cache.o piggy.o \
+           ashiftrt.o ashldi3.o ashrsi3.o ashlsi3.o lshrsi3.o
+
+# These were previously generated 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.
+ifdef building_out_of_srctree
+$(shell rm -f $(addprefix $(obj)/, ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S lshrsi3.S))
+endif
 
-OBJECTS = $(obj)/head_32.o $(obj)/misc.o $(obj)/cache.o
+targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
+           vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo $(OBJECTS)
 
 GCOV_PROFILE := n
 
@@ -33,21 +39,9 @@ ccflags-remove-$(CONFIG_MCOUNT) += -pg
 LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \
                 -T $(obj)/../../kernel/vmlinux.lds
 
-#
-# Pull in the necessary libgcc bits from the in-kernel implementation.
-#
-lib1funcs-y  := ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S lshrsi3.S
-lib1funcs-obj   := \
-     $(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y))))
-
-lib1funcs-dir                := $(srctree)/arch/$(SRCARCH)/lib
-
-KBUILD_CFLAGS += -I$(lib1funcs-dir) -DDISABLE_BRANCH_PROFILING
-
-$(addprefix $(obj)/,$(lib1funcs-y)): $(obj)/%: $(lib1funcs-dir)/% FORCE
-     $(call cmd,shipped)
+KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
 
-$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(lib1funcs-obj) FORCE
+$(obj)/vmlinux: $(addprefix $(obj)/, $(OBJECTS)) FORCE
      $(call if_changed,ld)
 
 $(obj)/vmlinux.bin: vmlinux FORCE
arch/sh/boot/compressed/ashiftrt.S new file +2 -0
new file mode 100644
index 000000000000..0f3b291a3f4b
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashiftrt.S"
arch/sh/boot/compressed/ashldi3.c new file +2 -0
new file mode 100644
index 000000000000..7cebd646df83
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include "../../lib/ashldi3.c"
arch/sh/boot/compressed/ashlsi3.S new file +2 -0
new file mode 100644
index 000000000000..e354262b275f
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashlsi3.S"
arch/sh/boot/compressed/ashrsi3.S new file +2 -0
new file mode 100644
index 000000000000..e564be9a4dcd
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashrsi3.S"
arch/sh/boot/compressed/lshrsi3.S new file +0 -0
new file mode 100644
index 000000000000..5a8281b7e516

arch/sh/boot/compressed/lshrsi3.S line 2

Quoted 2 lines
arch/sh/boot/compressed/lshrsi3.S new file +2 -0
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/lshrsi3.S"

This patch doesn't apply for me while the first one applies without problems:

Quoted 9 lines

glaubitz@epyc:..glaubitz/linux-git> git am ../sh-patches-2021/\[PATCH\ 1_2\]\ sh\:\ boot\:\ add\ intermediate\ vmlinux.bin\*\ to\ targets\ instead\ of\ extra-y.eml
Applying: sh: boot: add intermediate vmlinux.bin* to targets instead of extra-y
glaubitz@epyc:..glaubitz/linux-git> git am ../sh-patches-2021/\[PATCH\ 2_2\]\ sh\:\ boot\:\ avoid\ unneeded\ rebuilds\ under\ arch_sh_boot_compressed_.eml
Applying: sh: boot: avoid unneeded rebuilds under arch/sh/boot/compressed/
error: arch/sh/boot/compressed/ashiftrt.S: already exists in working directory
error: arch/sh/boot/compressed/ashldi3.c: already exists in working directory
error: arch/sh/boot/compressed/ashlsi3.S: already exists in working directory
error: arch/sh/boot/compressed/ashrsi3.S: already exists in working directory
error: arch/sh/boot/compressed/lshrsi3.S: already exists in working directory

Adrian, these 5 files are currently generated files.

That is why git-am failed.

They are not cleaned up by 'make ARCH=sh clean'
(this is a bug too).

Please remove them manually, then try git am again.

Quoted 7 lines

Patch failed at 0001 sh: boot: avoid unneeded rebuilds under arch/sh/boot/compressed/
hint: Use 'git am --show-current-patch=diff' to see the failed patch When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort". glaubitz@epyc:..glaubitz/linux-git>

Quoted 8 lines

Adrian

--

 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

--
Best Regards
Masahiro Yamada

#4 lore raw

Re: [PATCH 2/2] sh: boot: avoid unneeded rebuilds under arch/sh/boot/compressed/

Hi Masahiro!

Quoted 12 lines · Masahiro Yamada
Quoted 11 lines

This patch doesn't apply for me while the first one applies without problems:

glaubitz@epyc:..glaubitz/linux-git> git am ../sh-patches-2021/\[PATCH\ 1_2\]\ sh\:\ boot\:\ add\ intermediate\ vmlinux.bin\*\ to\ targets\ instead\ of\ extra-y.eml
Applying: sh: boot: add intermediate vmlinux.bin* to targets instead of extra-y
glaubitz@epyc:..glaubitz/linux-git> git am ../sh-patches-2021/\[PATCH\ 2_2\]\ sh\:\ boot\:\ avoid\ unneeded\ rebuilds\ under\ arch_sh_boot_compressed_.eml
Applying: sh: boot: avoid unneeded rebuilds under arch/sh/boot/compressed/
error: arch/sh/boot/compressed/ashiftrt.S: already exists in working directory
error: arch/sh/boot/compressed/ashldi3.c: already exists in working directory
error: arch/sh/boot/compressed/ashlsi3.S: already exists in working directory
error: arch/sh/boot/compressed/ashrsi3.S: already exists in working directory
error: arch/sh/boot/compressed/lshrsi3.S: already exists in working directory

Quoted 3 lines

Adrian, these 5 files are currently generated files.

That is why git-am failed.

I already guessed that. I removed them now and the patch applies cleanly.

Will test-boot on my SH-7785LCR in a minute.

Quoted 2 lines

They are not cleaned up by 'make ARCH=sh clean'
(this is a bug too).

That should be easy to fix I guess :-).

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
maintainer Tested-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] sh: boot: avoid unneeded rebuilds under arch/sh/boot/compressed/

In reply to Masahiro Yamada
Quoted 141 lines · Masahiro Yamada

Even if none of source code is updated, the following are every time rebuilt:

CC arch/sh/boot/compressed/cache.o
SHIPPED arch/sh/boot/compressed/ashiftrt.S
AS arch/sh/boot/compressed/ashiftrt.o
SHIPPED arch/sh/boot/compressed/ashldi3.c
CC arch/sh/boot/compressed/ashldi3.o
SHIPPED arch/sh/boot/compressed/ashrsi3.S
AS arch/sh/boot/compressed/ashrsi3.o
SHIPPED arch/sh/boot/compressed/ashlsi3.S
AS arch/sh/boot/compressed/ashlsi3.o
SHIPPED arch/sh/boot/compressed/lshrsi3.S
AS arch/sh/boot/compressed/lshrsi3.o
LD arch/sh/boot/compressed/vmlinux
OBJCOPY arch/sh/boot/zImage

Add build artifacts to 'targets' as needed.

I turned the library files to check-in files. It is simpler than copying from arch/sh/lib/ at build-time.

---

 arch/sh/boot/compressed/.gitignore |  5 -----
 arch/sh/boot/compressed/Makefile   | 32 ++++++++++++------------------
 arch/sh/boot/compressed/ashiftrt.S |  2 ++
 arch/sh/boot/compressed/ashldi3.c  |  2 ++
 arch/sh/boot/compressed/ashlsi3.S  |  2 ++
 arch/sh/boot/compressed/ashrsi3.S  |  2 ++
 arch/sh/boot/compressed/lshrsi3.S  |  2 ++
 7 files changed, 23 insertions(+), 24 deletions(-)
 create mode 100644 arch/sh/boot/compressed/ashiftrt.S
 create mode 100644 arch/sh/boot/compressed/ashldi3.c
 create mode 100644 arch/sh/boot/compressed/ashlsi3.S
 create mode 100644 arch/sh/boot/compressed/ashrsi3.S
 create mode 100644 arch/sh/boot/compressed/lshrsi3.S
arch/sh/boot/compressed/.gitignore +0 -5
index 37aa53057369..cd16663bc7c8 100644
@@ -1,7 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-ashiftrt.S
-ashldi3.c
-ashlsi3.S
-ashrsi3.S
-lshrsi3.S
 vmlinux.bin.*
arch/sh/boot/compressed/Makefile +13 -19
index 589d2d8a573d..cf3174df7859 100644
@@ -5,12 +5,18 @@
 # create a compressed vmlinux image from the original vmlinux
 #
 
-targets		:= vmlinux vmlinux.bin vmlinux.bin.gz \
-		   vmlinux.bin.bz2 vmlinux.bin.lzma \
-		   vmlinux.bin.xz vmlinux.bin.lzo \
-		   head_32.o misc.o piggy.o
+OBJECTS := head_32.o misc.o cache.o piggy.o \
+           ashiftrt.o ashldi3.o ashrsi3.o ashlsi3.o lshrsi3.o
+
+# These were previously generated 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.
+ifdef building_out_of_srctree
+$(shell rm -f $(addprefix $(obj)/, ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S lshrsi3.S))
+endif
 
-OBJECTS = $(obj)/head_32.o $(obj)/misc.o $(obj)/cache.o
+targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \
+           vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo $(OBJECTS)
 
 GCOV_PROFILE := n
 
@@ -33,21 +39,9 @@ ccflags-remove-$(CONFIG_MCOUNT) += -pg
 LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \
 		   -T $(obj)/../../kernel/vmlinux.lds
 
-#
-# Pull in the necessary libgcc bits from the in-kernel implementation.
-#
-lib1funcs-y	:= ashiftrt.S ashldi3.c ashrsi3.S ashlsi3.S lshrsi3.S
-lib1funcs-obj   := \
-	$(addsuffix .o, $(basename $(addprefix $(obj)/, $(lib1funcs-y))))
-
-lib1funcs-dir		:= $(srctree)/arch/$(SRCARCH)/lib
-
-KBUILD_CFLAGS += -I$(lib1funcs-dir) -DDISABLE_BRANCH_PROFILING
-
-$(addprefix $(obj)/,$(lib1funcs-y)): $(obj)/%: $(lib1funcs-dir)/% FORCE
-	$(call cmd,shipped)
+KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
 
-$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(lib1funcs-obj) FORCE
+$(obj)/vmlinux: $(addprefix $(obj)/, $(OBJECTS)) FORCE
 	$(call if_changed,ld)
 
 $(obj)/vmlinux.bin: vmlinux FORCE
arch/sh/boot/compressed/ashiftrt.S new file +2 -0
new file mode 100644
index 000000000000..0f3b291a3f4b
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashiftrt.S"
arch/sh/boot/compressed/ashldi3.c new file +2 -0
new file mode 100644
index 000000000000..7cebd646df83
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include "../../lib/ashldi3.c"
arch/sh/boot/compressed/ashlsi3.S new file +2 -0
new file mode 100644
index 000000000000..e354262b275f
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashlsi3.S"
arch/sh/boot/compressed/ashrsi3.S new file +2 -0
new file mode 100644
index 000000000000..e564be9a4dcd
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/ashrsi3.S"
arch/sh/boot/compressed/lshrsi3.S new file +0 -0
new file mode 100644
index 000000000000..5a8281b7e516

arch/sh/boot/compressed/lshrsi3.S line 2

Quoted 2 lines
arch/sh/boot/compressed/lshrsi3.S new file +2 -0
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include "../../lib/lshrsi3.S"

Successfully boot-tested on my SH-7785LCR. No regressions.

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
maintainer Tested-by on v1 1/2
#6 lore raw
In reply to Masahiro Yamada
Quoted 16 lines · Masahiro Yamada

You do not need to build all of vmlinux.bin*

They are built on demand as prerequsites of uImage.bin*, hence should be added to targets instead of extra-y.

---

 arch/sh/boot/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sh/boot/Makefile +0 -0
index 58592dfa5cb6..dded61296c9a 100644

arch/sh/boot/Makefile suffix-$(CONFIG_KERNEL_XZ) := xz · line 33

Quoted 9 lines
arch/sh/boot/Makefile +2 -2
@@ -27,8 +27,8 @@ suffix-$(CONFIG_KERNEL_XZ)	:= xz
 suffix-$(CONFIG_KERNEL_LZO)	:= lzo
 
 targets := zImage vmlinux.srec romImage uImage uImage.srec uImage.gz \
-	   uImage.bz2 uImage.lzma uImage.xz uImage.lzo uImage.bin
-extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
+	   uImage.bz2 uImage.lzma uImage.xz uImage.lzo uImage.bin \
+	   vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
 	   vmlinux.bin.xz vmlinux.bin.lzo
 subdir- := compressed romimage

Successfully boot-tested on my SH-7785LCR. No regressions.

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913