[PATCH v4] Makefile: add dependency from lib to arch/$(ARCH)/lib

Fabio Estevam festevam at gmail.com
Thu Jul 31 21:19:10 CEST 2025


Hi Mikko,

On Thu, Jul 31, 2025 at 8:53 AM Mikko Rapeli <mikko.rapeli at linaro.org> wrote:
>
> Top level Makefile starts separate "make" processes for each each
> subdirectory. lib/efi_loader apps now depend on lib.a from
> arch/$(ARCH)/lib if CONFIG_USE_PRIVATE_LIBGCC is enabled which creates
> a race conditions since dependency from lib/efi_loader EFI apps to
> arch/$(ARCH)/lib/lib.a is not explicit:
>
> arm-poky-linux-gnueabi-ld.bfd: cannot find arch/arm/lib/lib.a: No such file or directory
> make[3]: *** [scripts/Makefile.lib:512: lib/efi_loader/testapp_efi.so] Error 1
>
> This error was seen on yocto/OE-core CI builds after u-boot 2025.07 update:
>
> https://lists.openembedded.org/g/openembedded-core/message/220004
>
> https://autobuilder.yoctoproject.org/valkyrie/api/v2/logs/2914600/raw_inline
>
>     |    rm -f lib/efi_loader/built-in.o; arm-poky-linux-gnueabi-ar cDPrsT lib/efi_loader/built-in.o lib/efi_loader/efi_bootmgr.o lib/efi_loader/efi_bootbin.o lib/efi_loader
> /efi_boottime.o lib/efi_loader/efi_helper.o lib/efi_loader/efi_console.o lib/efi_loader/efi_device_path.o lib/efi_loader/efi_device_path_to_text.o lib/efi_loader/efi_device_
> path_utilities.o lib/efi_loader/efi_dt_fixup.o lib/efi_loader/efi_fdt.o lib/efi_loader/efi_file.o lib/efi_loader/efi_hii.o lib/efi_loader/efi_hii_config.o lib/efi_loader/efi
> _image_loader.o lib/efi_loader/efi_load_options.o lib/efi_loader/efi_memory.o lib/efi_loader/efi_root_node.o lib/efi_loader/efi_runtime.o lib/efi_loader/efi_setup.o lib/efi_
> loader/efi_string.o lib/efi_loader/efi_unicode_collation.o lib/efi_loader/efi_var_common.o lib/efi_loader/efi_var_mem.o lib/efi_loader/efi_variable.o lib/efi_loader/efi_var_
> file.o lib/efi_loader/efi_watchdog.o lib/efi_loader/efi_disk.o lib/efi_loader/efi_net.o lib/efi_loader/efi_smbios.o lib/efi_loader/efi_load_initrd.o lib/efi_loader/efi_confo
> rmance.o
>     |   arm-poky-linux-gnueabi-ld.bfd -nostdlib -zexecstack -znocombreloc -znorelro --no-warn-rwx-segments -L /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-
> 3119200/tmp/work/beaglebone_yocto-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07 -T arch/arm/lib/elf_arm_efi.lds -shared -Bsymbolic -s lib/efi_loader/helloworld.o
> lib/efi_loader/efi_crt0.o lib/efi_loader/efi_reloc.o lib/efi_loader/efi_freestanding.o arch/arm/lib/lib.a -o lib/efi_loader/helloworld_efi.so
>     | arm-poky-linux-gnueabi-ld.bfd: cannot find arch/arm/lib/lib.a: No such file or directory
>     | make[3]: *** [scripts/Makefile.lib:512: lib/efi_loader/helloworld_efi.so] Error 1
>
> The different "make" processes share common scripts/Makefile.build
> and scripts/Makefile.libs but since they are separate processes
> the Makefile rules can't add a dependency from lib/uefi_loader targets
> to arch/$(ARCH)/lib/lib.a. Or the file level dependency can be added but
> then "make" produces a too sparse error message which does not mention
> that one of the dependencies like arch/$(ARCH)/lib/lib.a was not found:
>
> make[3]: *** No rule to make target 'lib/efi_loader/helloworld.efi', needed by '__build'.  Stop.
>
> Fix this dependency problem by building arch/$(ARCH)/lib before lib
> if CONFIG_USE_PRIVATE_LIBGCC was enabled.
>
> To reproduce the race condition more reliably, add a "sleep 10" delay
> before linker command cmd_link_l_target with 2025.07
> or to $(lib-target): target in scripts/Makefile.build with master branch
> after Kbuild update.
>
> Fixes: 43d43241d1c9 ("scripts/Makefile.lib: add PLATFORM_LIBGCC to efi linking")
>
> Cc: Adriano Cordova <adrianox at gmail.com>
> Cc: Fabio Estevam <festevam at gmail.com>
> Signed-off-by: Mikko Rapeli <mikko.rapeli at linaro.org>

Thanks for the fix:

Reviewed-by: Fabio Estevam <festevam at gmail.com>


More information about the U-Boot mailing list