[PATCH v3 1/2] Makefile scripts/Makefile.lib: fix *_efi.so dependency to PLATFORM_LIBGCC
Fabio Estevam
festevam at gmail.com
Thu Jul 24 01:11:11 CEST 2025
Hi Mikko,
On Fri, Jul 18, 2025 at 5:30 AM Mikko Rapeli <mikko.rapeli at linaro.org> wrote:
>
> When PLATFORM_LIBGCC was added to linker command it was not
> added to the dependency of the .so and other rules. Thus a build can
> try to link *_efi.so files before lib.a from PLATFORM_LIBGCC is available.
> This was seen in yocto autobuilder builds with u-boot 2025.07
> update, see 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_conformance.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 issue is hard to reproduce but this change can artificially trigger it:
>
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -353,7 +353,7 @@ $(modorder-target): $(subdir-ym) FORCE
> #
> ifdef lib-target
> quiet_cmd_link_l_target = AR $@
> -cmd_link_l_target = rm -f $@; $(AR) cDPrsT$(KBUILD_ARFLAGS) $@ $(lib-y)
> +cmd_link_l_target = rm -f $@ && echo "HACK, delaying build!" && sleep 60 && $(AR) cDPrsT$(KBUILD_ARFLAGS) $@ $(lib-y)
>
> $(lib-target): $(lib-y) FORCE
> $(call if_changed,link_l_target)
>
> Then run a rebuild with:
>
> $ rm -f $( find build/ -name lib.a -or -name helloworld_efi.so ) && \
> make
> ...
> arm-poky-linux-gnueabi-ld.bfd -nostdlib -zexecstack -znocombreloc -znorelro --no-warn-rwx-segments -L /home/mcfrisk/src/base/repo/poky/build_bea
> glebone/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
>
> Fix by introducing PLATFORM_LIBGCC_LIBA variable with only lib.a
> filename which is then used to add the dependency in rules which use
> PLATFORM_LIBGCC. This should not impact builds which don't set
> PLATFORM_LIBGCC_LIBA and PLATFORM_LIBGCC usage stays as is.
>
> 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>
> ---
> Makefile | 4 +++-
> examples/standalone/Makefile | 2 +-
> scripts/Makefile.lib | 2 +-
> scripts/Makefile.xpl | 3 ++-
> 4 files changed, 7 insertions(+), 4 deletions(-)
>
> v3: added "export PLATFORM_LIBGCC_LIBA" like PLATFORM_LIBGCC, not sure
> how testing worked without this before
Thanks for your hard work on this series. I appreciated it.
This series fixed the build failures observed on the OE-core autobuilders.
For the series:
Reviewed-by: Fabio Estevam <festevam at gmail.com>
More information about the U-Boot
mailing list