From nobody Sun Dec 14 20:41:07 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AACAAC5AD4C for ; Sun, 19 Nov 2023 05:35:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230292AbjKSFfF (ORCPT ); Sun, 19 Nov 2023 00:35:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjKSFfC (ORCPT ); Sun, 19 Nov 2023 00:35:02 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98F4FE0 for ; Sat, 18 Nov 2023 21:34:59 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4417EC433C8; Sun, 19 Nov 2023 05:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700372099; bh=08ranJTDZ/V2FeaQz06DOfRs9FrKM8GbfKs8aPV/pJ0=; h=From:To:Cc:Subject:Date:From; b=T7mlj5GUg5Ir2bPEcJD672ID2zy1JFi6zQqSV/b06D0APxoOpxxRwLqkZJo9U/gho 4E91B5jnTQfg0EBCqq1aoHQ0G6MupKhi48gJ9n8a+NUPdQMXzBG4GYyUfsymrpMiTe QsasBKKCtXNl8rpQMWS7/R0Q4OzHmkr0g0hmPJpXeWu7ENeLji/9yYUc91/hGQo7jh OpGS3IipJk87W9vaifTYcSBrnn0q5dvfpkAPg/c4+xqrCHCEWOdJX5jmaDL4eXunKR aGDZVSLbP/6TnwyngJZ80Gl7jXmPNAi4g2GwixD6/udG90dSATaW7GkozapYOMzo8O dzFGWJ6aDxc1w== From: Masahiro Yamada To: Huacai Chen , WANG Xuerui , loongarch@lists.linux.dev Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Ard Biesheuvel , Simon Glass , Masahiro Yamada Subject: [PATCH] loongarch: add dependency between vmlinuz.efi and vmlinux.efi Date: Sun, 19 Nov 2023 14:34:48 +0900 Message-Id: <20231119053448.2367725-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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=3Dloongarch 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=3Dloongarch vmlinux.efi vmlinuz.efi [ snip ] SORTTAB vmlinux OBJCOPY arch/loongarch/boot/vmlinux.efi PAD arch/loongarch/boot/vmlinux.bin truncate: Invalid number: =E2=80=98arch/loongarch/boot/vmlinux.bin=E2=80= =99 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 --- 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 +=3D arch/loongarch/vdso/vdso.so.dbg =20 all: $(notdir $(KBUILD_IMAGE)) =20 +vmlinuz.efi: vmlinux.efi vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux $(Q)$(MAKE) $(build)=3D$(boot) $(bootvars-y) $(boot)/$@ =20 --=20 2.40.1