Skip to contentSkip to conversation

loongarch: add dependency between vmlinuz.efi and vmlinux.efi

PATCH In review Masahiro Yamada 2 participants 6 messages Nov 19, 2023 – Nov 20, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 loongarch: add dependency between vmlinuz.efi and vmlinux.efi

A common issue in Makefile is a race in parallel building.

You need to be careful to prevent multiple threads from writing to the same file simultaneously.

Commit 3939f3345050 ("ARM: 8418/1: add boot image dependencies to not generate invalid images") addressed such a bad scenario.

A similar symptom occurs with the following command:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
    GZIP    arch/loongarch/boot/vmlinuz
    OBJCOPY arch/loongarch/boot/vmlinuz.o
    LD      arch/loongarch/boot/vmlinuz.efi.elf
    OBJCOPY arch/loongarch/boot/vmlinuz.efi

The log "OBJCOPY arch/loongarch/boot/vmlinux.efi" is displayed twice.

It indicates that two threads simultaneously enter arch/loongarch/boot/ and write to arch/loongarch/boot/vmlinux.efi.

It occasionally leads to a build failure:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
  truncate: Invalid number: ‘arch/loongarch/boot/vmlinux.bin’
  make[2]: *** [drivers/firmware/efi/libstub/Makefile.zboot:13:
  arch/loongarch/boot/vmlinux.bin] Error 1
  make[2]: *** Deleting file 'arch/loongarch/boot/vmlinux.bin'
  make[1]: *** [arch/loongarch/Makefile:146: vmlinuz.efi] Error 2
  make[1]: *** Waiting for unfinished jobs....
  make: *** [Makefile:234: __sub-make] Error 2

vmlinuz.efi depends on vmlinux.efi, but such a dependency is not specified in arch/loongarch/Makefile.

---

 arch/loongarch/Makefile | 1 +
 1 file changed, 1 insertion(+)
arch/loongarch/Makefile +1 -0
index 9eeb0c05f3f4..6022bf3d30c9 100644
@@ -142,6 +142,7 @@ vdso-install-y += arch/loongarch/vdso/vdso.so.dbg
 
 all:	$(notdir $(KBUILD_IMAGE))
 
+vmlinuz.efi: vmlinux.efi
 vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@
 
Signature · 1 line
2.40.1
maintainer
#1 lore raw

Hi, Masahiro,

Quoted 56 lines · Masahiro Yamada

A common issue in Makefile is a race in parallel building.

You need to be careful to prevent multiple threads from writing to the same file simultaneously.

Commit 3939f3345050 ("ARM: 8418/1: add boot image dependencies to not generate invalid images") addressed such a bad scenario.

A similar symptom occurs with the following command:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
    GZIP    arch/loongarch/boot/vmlinuz
    OBJCOPY arch/loongarch/boot/vmlinuz.o
    LD      arch/loongarch/boot/vmlinuz.efi.elf
    OBJCOPY arch/loongarch/boot/vmlinuz.efi

The log "OBJCOPY arch/loongarch/boot/vmlinux.efi" is displayed twice.

It indicates that two threads simultaneously enter arch/loongarch/boot/ and write to arch/loongarch/boot/vmlinux.efi.

It occasionally leads to a build failure:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
  truncate: Invalid number: ‘arch/loongarch/boot/vmlinux.bin’
  make[2]: *** [drivers/firmware/efi/libstub/Makefile.zboot:13:
  arch/loongarch/boot/vmlinux.bin] Error 1
  make[2]: *** Deleting file 'arch/loongarch/boot/vmlinux.bin'
  make[1]: *** [arch/loongarch/Makefile:146: vmlinuz.efi] Error 2
  make[1]: *** Waiting for unfinished jobs....
  make: *** [Makefile:234: __sub-make] Error 2

vmlinuz.efi depends on vmlinux.efi, but such a dependency is not specified in arch/loongarch/Makefile.

---

 arch/loongarch/Makefile | 1 +
 1 file changed, 1 insertion(+)
arch/loongarch/Makefile +0 -0
index 9eeb0c05f3f4..6022bf3d30c9 100644

arch/loongarch/Makefile vdso-install-y += arch/loongarch/vdso/vdso.so.dbg · line 147

Quoted 6 lines
arch/loongarch/Makefile +1 -0
@@ -142,6 +142,7 @@ vdso-install-y += arch/loongarch/vdso/vdso.so.dbg
 
 all:   $(notdir $(KBUILD_IMAGE))
 
+vmlinuz.efi: vmlinux.efi
 vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

It is a little strange, because

in drivers/firmware/efi/libstub/Makefile.zboot:
vmlinuz.efi depends on vmlinuz.efi.elf, vmlinuz.efi.elf depends on vmlinuz.o, vmlinuz.o depends on vmlinuz, vmlinuz depends on vmlinux.bin, vmlinux.bin depends on $(EFI_ZBOOT_PAYLOAD).

in arch/loongarch/boot/Makefile,
EFI_ZBOOT_PAYLOAD := vmlinux.efi

So I think vmlinuz.efi has already depend on vmlinux.efi.

Huacai

Quoted 5 lines
arch/loongarch/Makefile +0 -1
--

2.40.1

#2 lore raw
Quoted 73 lines · Huacai Chen

Hi, Masahiro,

Quoted 56 lines · Masahiro Yamada

A common issue in Makefile is a race in parallel building.

You need to be careful to prevent multiple threads from writing to the same file simultaneously.

Commit 3939f3345050 ("ARM: 8418/1: add boot image dependencies to not generate invalid images") addressed such a bad scenario.

A similar symptom occurs with the following command:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
    GZIP    arch/loongarch/boot/vmlinuz
    OBJCOPY arch/loongarch/boot/vmlinuz.o
    LD      arch/loongarch/boot/vmlinuz.efi.elf
    OBJCOPY arch/loongarch/boot/vmlinuz.efi

The log "OBJCOPY arch/loongarch/boot/vmlinux.efi" is displayed twice.

It indicates that two threads simultaneously enter arch/loongarch/boot/ and write to arch/loongarch/boot/vmlinux.efi.

It occasionally leads to a build failure:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
  truncate: Invalid number: ‘arch/loongarch/boot/vmlinux.bin’
  make[2]: *** [drivers/firmware/efi/libstub/Makefile.zboot:13:
  arch/loongarch/boot/vmlinux.bin] Error 1
  make[2]: *** Deleting file 'arch/loongarch/boot/vmlinux.bin'
  make[1]: *** [arch/loongarch/Makefile:146: vmlinuz.efi] Error 2
  make[1]: *** Waiting for unfinished jobs....
  make: *** [Makefile:234: __sub-make] Error 2

vmlinuz.efi depends on vmlinux.efi, but such a dependency is not specified in arch/loongarch/Makefile.

---

 arch/loongarch/Makefile | 1 +
 1 file changed, 1 insertion(+)
arch/loongarch/Makefile +0 -0
index 9eeb0c05f3f4..6022bf3d30c9 100644

arch/loongarch/Makefile vdso-install-y += arch/loongarch/vdso/vdso.so.dbg · line 147

Quoted 6 lines
arch/loongarch/Makefile +1 -0
@@ -142,6 +142,7 @@ vdso-install-y += arch/loongarch/vdso/vdso.so.dbg
 
 all:   $(notdir $(KBUILD_IMAGE))
 
+vmlinuz.efi: vmlinux.efi
 vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

It is a little strange, because

in drivers/firmware/efi/libstub/Makefile.zboot:
vmlinuz.efi depends on vmlinuz.efi.elf, vmlinuz.efi.elf depends on vmlinuz.o, vmlinuz.o depends on vmlinuz, vmlinuz depends on vmlinux.bin, vmlinux.bin depends on $(EFI_ZBOOT_PAYLOAD).

Quoted 4 lines

in arch/loongarch/boot/Makefile,
EFI_ZBOOT_PAYLOAD := vmlinux.efi

So I think vmlinuz.efi has already depend on vmlinux.efi.

That is a story in arch/loongarch/boot/Makefile.

I am talking about arch/loongarch/Makefile,
which is included from the top Makefile.

See this code.

vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux

        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

Only the required dependency is

- vmlinux.elf depends on vmlinux
- vmlinuz.elf depends on vmlinux

vmlinux.elf and vmlinuz.elf are independent of each other.

In parallel building, GNU Make considers that vmlinux.elf and vmlinuz.elf can be built simultaneously.

GNU Make spawns two processes to execute these simultaneously:

$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/vmlinux.elf $(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/vmlinuz.elf

The former enters arch/loongarch/boot/Makefile to build vmlinux.elf. (A)

The latter also enters arch/loongarch/boot/Makefile to build vmlinuz.elf, which depends on vmlinux.elf (B)

(A) and (B) are independent processes, hence none of them know the other.

I hope it is clearer.

Quoted 8 lines

Huacai

Quoted 5 lines
arch/loongarch/Makefile +0 -1
--

2.40.1

Signature · 2 lines
Best Regards
Masahiro Yamada
maintainer
#3 lore raw

Hi, Masahiro,

Quoted 128 lines · Masahiro Yamada
Quoted 73 lines · Huacai Chen

Hi, Masahiro,

Quoted 56 lines · Masahiro Yamada

A common issue in Makefile is a race in parallel building.

You need to be careful to prevent multiple threads from writing to the same file simultaneously.

Commit 3939f3345050 ("ARM: 8418/1: add boot image dependencies to not generate invalid images") addressed such a bad scenario.

A similar symptom occurs with the following command:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
    GZIP    arch/loongarch/boot/vmlinuz
    OBJCOPY arch/loongarch/boot/vmlinuz.o
    LD      arch/loongarch/boot/vmlinuz.efi.elf
    OBJCOPY arch/loongarch/boot/vmlinuz.efi

The log "OBJCOPY arch/loongarch/boot/vmlinux.efi" is displayed twice.

It indicates that two threads simultaneously enter arch/loongarch/boot/ and write to arch/loongarch/boot/vmlinux.efi.

It occasionally leads to a build failure:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
  truncate: Invalid number: ‘arch/loongarch/boot/vmlinux.bin’
  make[2]: *** [drivers/firmware/efi/libstub/Makefile.zboot:13:
  arch/loongarch/boot/vmlinux.bin] Error 1
  make[2]: *** Deleting file 'arch/loongarch/boot/vmlinux.bin'
  make[1]: *** [arch/loongarch/Makefile:146: vmlinuz.efi] Error 2
  make[1]: *** Waiting for unfinished jobs....
  make: *** [Makefile:234: __sub-make] Error 2

vmlinuz.efi depends on vmlinux.efi, but such a dependency is not specified in arch/loongarch/Makefile.

---

 arch/loongarch/Makefile | 1 +
 1 file changed, 1 insertion(+)
arch/loongarch/Makefile +0 -0
index 9eeb0c05f3f4..6022bf3d30c9 100644

arch/loongarch/Makefile vdso-install-y += arch/loongarch/vdso/vdso.so.dbg · line 147

Quoted 6 lines
arch/loongarch/Makefile +1 -0
@@ -142,6 +142,7 @@ vdso-install-y += arch/loongarch/vdso/vdso.so.dbg
 
 all:   $(notdir $(KBUILD_IMAGE))
 
+vmlinuz.efi: vmlinux.efi
 vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

It is a little strange, because

in drivers/firmware/efi/libstub/Makefile.zboot:
vmlinuz.efi depends on vmlinuz.efi.elf, vmlinuz.efi.elf depends on vmlinuz.o, vmlinuz.o depends on vmlinuz, vmlinuz depends on vmlinux.bin, vmlinux.bin depends on $(EFI_ZBOOT_PAYLOAD).

Quoted 4 lines

in arch/loongarch/boot/Makefile,
EFI_ZBOOT_PAYLOAD := vmlinux.efi

So I think vmlinuz.efi has already depend on vmlinux.efi.

That is a story in arch/loongarch/boot/Makefile.

I am talking about arch/loongarch/Makefile,
which is included from the top Makefile.

See this code.

vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux

        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

Only the required dependency is

- vmlinux.elf depends on vmlinux
- vmlinuz.elf depends on vmlinux

vmlinux.elf and vmlinuz.elf are independent of each other.

In parallel building, GNU Make considers that vmlinux.elf and vmlinuz.elf can be built simultaneously.

GNU Make spawns two processes to execute these simultaneously:

$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/vmlinux.elf $(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/vmlinuz.elf

The former enters arch/loongarch/boot/Makefile to build vmlinux.elf. (A)

The latter also enters arch/loongarch/boot/Makefile to build vmlinuz.elf, which depends on vmlinux.elf (B)

Quoted 5 lines

(A) and (B) are independent processes, hence none of them know the other.

I hope it is clearer.

Sorry, I'm not familiar with Makefile rules, so you are probably right, but should we do it like this (remove the direct dependency from vmlinuz.efi to vmlinux)?

vmlinuz.efi: vmlinux.efi
vmlinux.elf vmlinux.efi: vmlinux

        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

Huacai

Quoted 19 lines
Quoted 6 lines
Quoted 8 lines

Huacai

Quoted 5 lines
arch/loongarch/Makefile +0 -1
--

2.40.1

--
Best Regards
Masahiro Yamada

#4 lore raw
Quoted 136 lines · Huacai Chen

Hi, Masahiro,

Quoted 132 lines · Masahiro Yamada
Quoted 73 lines · Huacai Chen

Hi, Masahiro,

Quoted 56 lines · Masahiro Yamada

A common issue in Makefile is a race in parallel building.

You need to be careful to prevent multiple threads from writing to the same file simultaneously.

Commit 3939f3345050 ("ARM: 8418/1: add boot image dependencies to not generate invalid images") addressed such a bad scenario.

A similar symptom occurs with the following command:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
    GZIP    arch/loongarch/boot/vmlinuz
    OBJCOPY arch/loongarch/boot/vmlinuz.o
    LD      arch/loongarch/boot/vmlinuz.efi.elf
    OBJCOPY arch/loongarch/boot/vmlinuz.efi

The log "OBJCOPY arch/loongarch/boot/vmlinux.efi" is displayed twice.

It indicates that two threads simultaneously enter arch/loongarch/boot/ and write to arch/loongarch/boot/vmlinux.efi.

It occasionally leads to a build failure:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
  truncate: Invalid number: ‘arch/loongarch/boot/vmlinux.bin’
  make[2]: *** [drivers/firmware/efi/libstub/Makefile.zboot:13:
  arch/loongarch/boot/vmlinux.bin] Error 1
  make[2]: *** Deleting file 'arch/loongarch/boot/vmlinux.bin'
  make[1]: *** [arch/loongarch/Makefile:146: vmlinuz.efi] Error 2
  make[1]: *** Waiting for unfinished jobs....
  make: *** [Makefile:234: __sub-make] Error 2

vmlinuz.efi depends on vmlinux.efi, but such a dependency is not specified in arch/loongarch/Makefile.

---

 arch/loongarch/Makefile | 1 +
 1 file changed, 1 insertion(+)
arch/loongarch/Makefile +0 -0
index 9eeb0c05f3f4..6022bf3d30c9 100644

arch/loongarch/Makefile vdso-install-y += arch/loongarch/vdso/vdso.so.dbg · line 147

Quoted 6 lines
arch/loongarch/Makefile +1 -0
@@ -142,6 +142,7 @@ vdso-install-y += arch/loongarch/vdso/vdso.so.dbg
 
 all:   $(notdir $(KBUILD_IMAGE))
 
+vmlinuz.efi: vmlinux.efi
 vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

It is a little strange, because

in drivers/firmware/efi/libstub/Makefile.zboot:
vmlinuz.efi depends on vmlinuz.efi.elf, vmlinuz.efi.elf depends on vmlinuz.o, vmlinuz.o depends on vmlinuz, vmlinuz depends on vmlinux.bin, vmlinux.bin depends on $(EFI_ZBOOT_PAYLOAD).

Quoted 4 lines

in arch/loongarch/boot/Makefile,
EFI_ZBOOT_PAYLOAD := vmlinux.efi

So I think vmlinuz.efi has already depend on vmlinux.efi.

That is a story in arch/loongarch/boot/Makefile.

I am talking about arch/loongarch/Makefile,
which is included from the top Makefile.

See this code.

vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux

        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

Only the required dependency is

- vmlinux.elf depends on vmlinux
- vmlinuz.elf depends on vmlinux

vmlinux.elf and vmlinuz.elf are independent of each other.

In parallel building, GNU Make considers that vmlinux.elf and vmlinuz.elf can be built simultaneously.

GNU Make spawns two processes to execute these simultaneously:

$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/vmlinux.elf $(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/vmlinuz.elf

The former enters arch/loongarch/boot/Makefile to build vmlinux.elf. (A)

The latter also enters arch/loongarch/boot/Makefile to build vmlinuz.elf, which depends on vmlinux.elf (B)

(A) and (B) are independent processes, hence none of them know the other.

Quoted 8 lines
Quoted 1 line

I hope it is clearer.

Sorry, I'm not familiar with Makefile rules, so you are probably right, but should we do it like this (remove the direct dependency from vmlinuz.efi to vmlinux)?

vmlinuz.efi: vmlinux.efi
vmlinux.elf vmlinux.efi: vmlinux

        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

No.

It would create only vmlinux.efi because there is
no recipe line for vmlinuz.efi

vmlinuz.efi: vmlinux.efi

        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@
vmlinux.elf vmlinux.efi: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

will work, but I do not want to repeat the same recipe line.

Quoted 21 lines

Huacai

Quoted 19 lines
Quoted 6 lines
Quoted 8 lines

Huacai

Quoted 5 lines
arch/loongarch/Makefile +0 -1
--

2.40.1

--
Best Regards
Masahiro Yamada

Signature · 2 lines
Best Regards
Masahiro Yamada
maintainer
#5 lore raw
Quoted 157 lines · Masahiro Yamada
Quoted 136 lines · Huacai Chen

Hi, Masahiro,

Quoted 132 lines · Masahiro Yamada
Quoted 73 lines · Huacai Chen

Hi, Masahiro,

Quoted 56 lines · Masahiro Yamada

A common issue in Makefile is a race in parallel building.

You need to be careful to prevent multiple threads from writing to the same file simultaneously.

Commit 3939f3345050 ("ARM: 8418/1: add boot image dependencies to not generate invalid images") addressed such a bad scenario.

A similar symptom occurs with the following command:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
    GZIP    arch/loongarch/boot/vmlinuz
    OBJCOPY arch/loongarch/boot/vmlinuz.o
    LD      arch/loongarch/boot/vmlinuz.efi.elf
    OBJCOPY arch/loongarch/boot/vmlinuz.efi

The log "OBJCOPY arch/loongarch/boot/vmlinux.efi" is displayed twice.

It indicates that two threads simultaneously enter arch/loongarch/boot/ and write to arch/loongarch/boot/vmlinux.efi.

It occasionally leads to a build failure:

  $ make -j$(nproc) ARCH=loongarch vmlinux.efi vmlinuz.efi
    [ snip ]
    SORTTAB vmlinux
    OBJCOPY arch/loongarch/boot/vmlinux.efi
    PAD     arch/loongarch/boot/vmlinux.bin
  truncate: Invalid number: ‘arch/loongarch/boot/vmlinux.bin’
  make[2]: *** [drivers/firmware/efi/libstub/Makefile.zboot:13:
  arch/loongarch/boot/vmlinux.bin] Error 1
  make[2]: *** Deleting file 'arch/loongarch/boot/vmlinux.bin'
  make[1]: *** [arch/loongarch/Makefile:146: vmlinuz.efi] Error 2
  make[1]: *** Waiting for unfinished jobs....
  make: *** [Makefile:234: __sub-make] Error 2

vmlinuz.efi depends on vmlinux.efi, but such a dependency is not specified in arch/loongarch/Makefile.

---

 arch/loongarch/Makefile | 1 +
 1 file changed, 1 insertion(+)
arch/loongarch/Makefile +0 -0
index 9eeb0c05f3f4..6022bf3d30c9 100644

arch/loongarch/Makefile vdso-install-y += arch/loongarch/vdso/vdso.so.dbg · line 147

Quoted 6 lines
arch/loongarch/Makefile +1 -0
@@ -142,6 +142,7 @@ vdso-install-y += arch/loongarch/vdso/vdso.so.dbg
 
 all:   $(notdir $(KBUILD_IMAGE))
 
+vmlinuz.efi: vmlinux.efi
 vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

It is a little strange, because

in drivers/firmware/efi/libstub/Makefile.zboot:
vmlinuz.efi depends on vmlinuz.efi.elf, vmlinuz.efi.elf depends on vmlinuz.o, vmlinuz.o depends on vmlinuz, vmlinuz depends on vmlinux.bin, vmlinux.bin depends on $(EFI_ZBOOT_PAYLOAD).

Quoted 4 lines

in arch/loongarch/boot/Makefile,
EFI_ZBOOT_PAYLOAD := vmlinux.efi

So I think vmlinuz.efi has already depend on vmlinux.efi.

That is a story in arch/loongarch/boot/Makefile.

I am talking about arch/loongarch/Makefile,
which is included from the top Makefile.

See this code.

vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux

        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

Only the required dependency is

- vmlinux.elf depends on vmlinux
- vmlinuz.elf depends on vmlinux

vmlinux.elf and vmlinuz.elf are independent of each other.

In parallel building, GNU Make considers that vmlinux.elf and vmlinuz.elf can be built simultaneously.

GNU Make spawns two processes to execute these simultaneously:

$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/vmlinux.elf $(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/vmlinuz.elf

The former enters arch/loongarch/boot/Makefile to build vmlinux.elf. (A)

The latter also enters arch/loongarch/boot/Makefile to build vmlinuz.elf, which depends on vmlinux.elf (B)

(A) and (B) are independent processes, hence none of them know the other.

Quoted 8 lines
Quoted 1 line

I hope it is clearer.

Sorry, I'm not familiar with Makefile rules, so you are probably right, but should we do it like this (remove the direct dependency from vmlinuz.efi to vmlinux)?

vmlinuz.efi: vmlinux.efi
vmlinux.elf vmlinux.efi: vmlinux

        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

No.

It would create only vmlinux.efi because there is
no recipe line for vmlinuz.efi

Quoted 8 lines

vmlinuz.efi: vmlinux.efi

        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@
vmlinux.elf vmlinux.efi: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@

will work, but I do not want to repeat the same recipe line.

OK, I know, thank you very much. This patch will be applied to loongarch-fixes.

Huacai

Quoted 42 lines
Quoted 15 lines
Quoted 21 lines

Huacai

Quoted 19 lines
Quoted 6 lines
Quoted 8 lines

Huacai

Quoted 5 lines
arch/loongarch/Makefile +0 -1
--

2.40.1

--
Best Regards
Masahiro Yamada

--
Best Regards
Masahiro Yamada