Makefile scripts/Makefile.lib: fix *_efi.so dependency to PLATFORM_LIBGCC
PATCH v2 1/1 Makefile scripts/Makefile.lib: fix *_efi.so dependency to PLATFORM_LIBGCC
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.
--- Makefile | 3 ++- examples/standalone/Makefile | 2 +- scripts/Makefile.lib | 2 +- scripts/Makefile.xpl | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-)
v2: introduced PLATFORM_LIBGCC_LIBA variable with just lib.a filename,
PLATFORM_LIBGCC can have other flags too
v1: https://lists.denx.de/pipermail/u-boot/2025-July/593982.html
Makefile +2 -1
@@ -1072,7 +1072,8 @@ u-boot-main := $(libs-y) # Add GCC lib ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y) -PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a +PLATFORM_LIBGCC_LIBA = arch/$(ARCH)/lib/lib.a +PLATFORM_LIBGCC = $(PLATFORM_LIBGCC_LIBA) else ifndef CONFIG_CC_IS_CLANG PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
examples/standalone/Makefile +1 -1
@@ -64,7 +64,7 @@ quiet_cmd_link_elf = LD $@ cmd_link_elf = $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_STANDALONE) -g \ -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) $(PLATFORM_LIBGCC) -$(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE +$(ELF): $(obj)/%: $(obj)/%.o $(LIB) $(PLATFORM_LIBGCC_LIBA) FORCE $(call if_changed,link_elf) $(obj)/%.srec: OBJCOPYFLAGS += -O srec
scripts/Makefile.lib +1 -1
@@ -533,7 +533,7 @@ $(obj)/efi_reloc.o: $(srctree)/arch/$(ARCH)/lib/$(EFI_RELOC:.o=.c) $(recordmcoun $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) -$(obj)/%_efi.so: $(obj)/%.o $(obj)/efi_crt0.o $(obj)/efi_reloc.o $(obj)/efi_freestanding.o +$(obj)/%_efi.so: $(PLATFORM_LIBGCC_LIBA) $(obj)/%.o $(obj)/efi_crt0.o $(obj)/efi_reloc.o $(obj)/efi_freestanding.o $(call cmd,efi_ld) targets += $(obj)/efi_crt0.o $(obj)/efi_reloc.o $(obj)/efi_freestanding.o
scripts/Makefile.xpl +2 -1
@@ -139,7 +139,8 @@ libs-y := $(patsubst %/, %/built-in.a, $(libs-y)) # Add GCC lib ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y) -PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a +PLATFORM_LIBGCC_LIBA = arch/$(ARCH)/lib/lib.a +PLATFORM_LIBGCC = $(PLATFORM_LIBGCC_LIBA) PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC) endif
Signature · 1 line
2.43.0
Hi,
Yocto side testing shows that this patch does not fix the race and missing lib.a:
https://lists.openembedded.org/g/openembedded-core/message/220519
Builds failure logs:
https://autobuilder.yoctoproject.org/valkyrie/api/v2/logs/2984138/raw_inline
| arm-poky-linux-gnueabi-gcc --sysroot=/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/recipe-sysroot -ffile-prefix-map=/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07=/usr/src/debug/u-boot/2025.07 -ffile-prefix-map=/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/build=/usr/src/debug/u-boot/2025.07 -ffile-prefix-map=/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/recipe-sysroot= -ffile-prefix-map=/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/recipe-sysroot-native= -Wp,-MD,lib/efi_loader/.testapp.o.d -nostdinc -isystem /srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/15.1.0/include -Iinclude -I/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/include -I/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/arch/arm/include -include /srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/include/linux/kconfig.h -I/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/dts/upstream/include -I/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/lib/efi_loader -Ilib/efi_loader -D__KERNEL__ -D__UBOOT__ -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -Os -fno-stack-protector -fno-delete-null-pointer-checks -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-maybe-uninitialized -fmacro-prefix-map=/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/= -gdwarf-4 -fstack-usage -Wno-format-nonliteral -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=date-time -Wno-packed-not-aligned -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mword-relocations -mno-unaligned-access -fno-common -msoft-float -mgeneral-regs-only -pipe -march=armv7-a -D__LINUX_ARM_ARCH__=7 -mtune=generic-armv7-a -I/srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/arch/arm/mach-omap2/include -fpic -fshort-wchar -Os -ffreestanding -DKBUILD_BASENAME='"testapp"' -DKBUILD_MODNAME='"testapp"' -c -o lib/efi_loader/testapp.o /srv/pokybuild/yocto-worker/oe-selftest-fedora/build/build-st-3774036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/lib/efi_loader/testapp.c | 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-fedora/build/build-st-3774036/tmp/work/qemuarm-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
https://autobuilder.yoctoproject.org/valkyrie/api/v2/logs/2984135/raw_inline
| make -f /srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3683036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/scripts/Makefile.build obj=lib/efi_loader | arm-poky-linux-gnueabi-ld.bfd -nostdlib -zexecstack -znocombreloc -znorelro --no-warn-rwx-segments -L /srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3683036/tmp/work/qemuarm-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 | make[2]: *** [/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3683036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/scripts/Makefile.build:398: lib/efi_loader] Error 2 | make[1]: *** [/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3683036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/Makefile:1920: lib] Error 2 | make[1]: Leaving directory '/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3683036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/build' | make: Leaving directory '/srv/pokybuild/yocto-worker/oe-selftest-debian/build/build-st-3683036/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07' | make: *** [Makefile:177: sub-make] Error 2
https://autobuilder.yoctoproject.org/valkyrie/api/v2/logs/2984171/raw_inline
| arm-poky-linux-gnueabi-gcc --sysroot=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/recipe-sysroot -ffile-prefix-map=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07=/usr/src/debug/u-boot/2025.07 -ffile-prefix-map=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/build=/usr/src/debug/u-boot/2025.07 -ffile-prefix-map=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/recipe-sysroot= -ffile-prefix-map=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/recipe-sysroot-native= -Wp,-MD,lib/efi_loader/.testapp.o.d -nostdinc -isystem /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/15.1.0/include -Iinclude -I/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/include -I/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/arch/arm/include -include /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/include/linux/kconfig.h -I/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/dts/upstream/include -I/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/lib/efi_loader -Ilib/efi_loader -D__KERNEL__ -D__UBOOT__ -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -std=gnu11 -fshort-wchar -fno-strict-aliasing -fno-PIE -Os -fno-stack-protector -fno-delete-null-pointer-checks -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-maybe-uninitialized -fmacro-prefix-map=/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/= -gdwarf-4 -fstack-usage -Wno-format-nonliteral -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=date-time -Wno-packed-not-aligned -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mword-relocations -mno-unaligned-access -fno-common -msoft-float -mgeneral-regs-only -pipe -march=armv7-a -D__LINUX_ARM_ARCH__=7 -mtune=generic-armv7-a -I/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/arch/arm/mach-omap2/include -fpic -fshort-wchar -Os -ffreestanding -DKBUILD_BASENAME='"testapp"' -DKBUILD_MODNAME='"testapp"' -c -o lib/efi_loader/testapp.o /srv/pokybuild/yocto-worker/oe-selftest-armhost/build/build-st-1802970/tmp/work/qemuarm-poky-linux-gnueabi/u-boot/2025.07/sources/u-boot-2025.07/lib/efi_loader/testapp.c | 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-1802970/tmp/work/qemuarm-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
In all cases, lib/efi_loader/helloworld_efi.so is getting linked but lib.a was not built before it. u-boot config is "am57xx_evm_defconfig".
Some other dependencies are not correct then.
Cheers,
-Mikko
Quoted 116 lines · Mikko Rapeli
When
PLATFORM_LIBGCCwas 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 fromPLATFORM_LIBGCCis available. This was seen in yocto autobuilder builds with u-boot 2025.07 update, see https://lists.openembedded.org/g/openembedded-core/message/220004https://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 1The issue is hard to reproduce but this change can artificially trigger it:
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build(quoted diff) +1
-1@@ -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 1Fix by introducing
PLATFORM_LIBGCC_LIBAvariable with only lib.a filename which is then used to add the dependency in rules which usePLATFORM_LIBGCC. This should not impact builds which don't setPLATFORM_LIBGCC_LIBAandPLATFORM_LIBGCCusage stays as is.Fixes 43d43241d1c9 ("scripts/Makefile.lib: add PLATFORM_LIBGCC to efi linking")Cc Adriano Cordova <[email protected]>Cc Fabio Estevam <[email protected]>Signed-off-by Mikko Rapeli <[email protected]>--- Makefile | 3 ++- examples/standalone/Makefile | 2 +- scripts/Makefile.lib | 2 +- scripts/Makefile.xpl | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-)v2: introduced
PLATFORM_LIBGCC_LIBAvariable with just lib.a filename,
PLATFORM_LIBGCCcan have other flags toov1: https://lists.denx.de/pipermail/u-boot/2025-July/593982.html
Makefile +2
-1@@ -1072,7 +1072,8 @@ u-boot-main := $(libs-y) # Add GCC lib ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y) -PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a +PLATFORM_LIBGCC_LIBA = arch/$(ARCH)/lib/lib.a +PLATFORM_LIBGCC = $(PLATFORM_LIBGCC_LIBA) else ifndef CONFIG_CC_IS_CLANG PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgccexamples/standalone/Makefile +1
-1@@ -64,7 +64,7 @@ quiet_cmd_link_elf = LD $@ cmd_link_elf = $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_STANDALONE) -g \ -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) $(PLATFORM_LIBGCC) -$(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE +$(ELF): $(obj)/%: $(obj)/%.o $(LIB) $(PLATFORM_LIBGCC_LIBA) FORCE $(call if_changed,link_elf) $(obj)/%.srec: OBJCOPYFLAGS += -O srecscripts/Makefile.lib +1
-1@@ -533,7 +533,7 @@ $(obj)/efi_reloc.o: $(srctree)/arch/$(ARCH)/lib/$(EFI_RELOC:.o=.c) $(recordmcoun $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) -$(obj)/%_efi.so: $(obj)/%.o $(obj)/efi_crt0.o $(obj)/efi_reloc.o $(obj)/efi_freestanding.o +$(obj)/%_efi.so: $(PLATFORM_LIBGCC_LIBA) $(obj)/%.o $(obj)/efi_crt0.o $(obj)/efi_reloc.o $(obj)/efi_freestanding.o $(call cmd,efi_ld) targets += $(obj)/efi_crt0.o $(obj)/efi_reloc.o $(obj)/efi_freestanding.oscripts/Makefile.xpl +2
-1@@ -139,7 +139,8 @@ libs-y := $(patsubst %/, %/built-in.a, $(libs-y)) # Add GCC lib ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y) -PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a +PLATFORM_LIBGCC_LIBA = arch/$(ARCH)/lib/lib.a +PLATFORM_LIBGCC = $(PLATFORM_LIBGCC_LIBA) PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC) endifSignature · 1 line
2.43.0