[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H6Y4vqc45eaMs+wCN7Quf4e9ogp8aDA8V0sA=TUnMWd-Q@mail.gmail.com>
Date: Sun, 19 Nov 2023 19:59:11 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Masahiro Yamada <masahiroy@...nel.org>
Cc: WANG Xuerui <kernel@...0n.name>, loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org, linux-kbuild@...r.kernel.org,
Ard Biesheuvel <ardb@...nel.org>,
Simon Glass <sjg@...omium.org>
Subject: Re: [PATCH] loongarch: add dependency between vmlinuz.efi and vmlinux.efi
Hi, Masahiro,
On Sun, Nov 19, 2023 at 1:35 PM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> 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.
>
> Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
> ---
>
> arch/loongarch/Makefile | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
> index 9eeb0c05f3f4..6022bf3d30c9 100644
> --- a/arch/loongarch/Makefile
> +++ b/arch/loongarch/Makefile
> @@ -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
>
> --
> 2.40.1
>
>
Powered by blists - more mailing lists