foss-for-synopsys-dwc-arc-processors / linux

Helpful resources for users & developers of Linux kernel for ARC
22 stars 13 forks source link

ARCv3: "uImage" target doesn't have proper dependency on "loader" and fail to build #142

Closed abrodkin closed 10 months ago

abrodkin commented 10 months ago

On attempt to create uImage for ARCv3 processors (be it ARC HS58 or ARC HS68) skipping make all or simple make leads to the following error:

$ make haps_arc64_defconfig
$ make uImage
...
  SORTTAB vmlinux
  SYSMAP  System.map
  OBJCOPY arch/arc/boot/vmlinux.bin
  GZIP    arch/arc/boot/vmlinux.bin.gz
arc64-linux-nm: 'arch/arc/boot/loader': No such file
arc64-linux-nm: 'arch/arc/boot/loader': No such file
arc64-linux-nm: 'arch/arc/boot/loader': No such file
  UIMAGE  arch/arc/boot/uImage.gz
/u/abrodkin/.local/bin/mkimage: invalid entry point 0x
make[2]: *** [arch/arc/boot/uImage.gz] Error 1
make[1]: *** [uImage.gz] Error 2
make: *** [__sub-make] Error 2

That happens because apparently loader is not a dependency for uImage target.

I guess the following will fix it:

diff --git a/arch/arc/boot/Makefile b/arch/arc/boot/Makefile
index 48633d8b182b..b60aae98e5e4 100644
--- a/arch/arc/boot/Makefile
+++ b/arch/arc/boot/Makefile
@@ -9,7 +9,6 @@ OBJCOPYFLAGS= -O binary -R .note -R .note.gnu.build-id -R .comment -S
 LINUX_ENTRY_VIRT = 0x$(shell $(NM) vmlinux | awk '$$NF == "res_service" {print $$1}')

 ifeq ($(CONFIG_ISA_ARCV3),y)
-$(obj)/uImage*: $(obj)/loader
 LINUX_ENTRY_PHY = 0x$(shell $(NM) $(obj)/loader | awk '$$NF == "_entry_point" {print $$1}')
 else
 LINUX_ENTRY_PHY = $(LINUX_ENTRY_VIRT)
@@ -25,6 +24,8 @@ targets += uImage.bin
 targets += uImage.gz
 targets += uImage.lzma
 targets += loader
+targets += loader.gz
+targets += loader.lzma

 $(obj)/vmlinux.bin: vmlinux FORCE
        $(call if_changed,objcopy)
@@ -35,13 +36,31 @@ $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
 $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
        $(call if_changed,lzma)

+$(obj)/loader.gz: $(obj)/loader FORCE
+       $(call if_changed,gzip)
+
+$(obj)/loader.lzma: $(obj)/loader FORCE
+       $(call if_changed,lzma)
+
+ifeq ($(CONFIG_ISA_ARCV3),y)
+$(obj)/uImage.bin: $(obj)/loader FORCE
+else
 $(obj)/uImage.bin: $(obj)/vmlinux.bin FORCE
+endif
        $(call if_changed,uimage,none)

+ifeq ($(CONFIG_ISA_ARCV3),y)
+$(obj)/uImage.gz: $(obj)/loader.gz FORCE
+else
 $(obj)/uImage.gz: $(obj)/vmlinux.bin.gz FORCE
+endif
        $(call if_changed,uimage,gzip)

+ifeq ($(CONFIG_ISA_ARCV3),y)
+$(obj)/uImage.lzma: $(obj)/loader.lzma FORCE
+else
 $(obj)/uImage.lzma: $(obj)/vmlinux.bin.lzma FORCE
+endif
        $(call if_changed,uimage,lzma)

 $(obj)/loader.o: $(src)/loader.S $(obj)/vmlinux.bin
abrodkin commented 10 months ago

Also, let's add a GitHub CI test builds to https://github.com/foss-for-synopsys-dwc-arc-processors/linux/blob/arc64/.github/workflows/ci.yml for automated testing of uImage building.

xxkent commented 10 months ago

Fixed here: https://github.com/foss-for-synopsys-dwc-arc-processors/linux/tree/bolsh-arc64-uImage-fix