Makefile scripts/Makefile.lib: fix *_efi.so dependency to PLATFORM_LIBGCC
PATCH v3 1/2 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 | 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
v2: introduced PLATFORM_LIBGCC_LIBA variable with just lib.a filename,
PLATFORM_LIBGCC can have other flags too
https://lists.denx.de/pipermail/u-boot/2025-July/594034.html
v1: https://lists.denx.de/pipermail/u-boot/2025-July/593982.html
Makefile +3 -1
@@ -911,7 +911,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
@@ -926,6 +927,7 @@ endif export PLATFORM_LIBS export PLATFORM_LIBGCC +export PLATFORM_LIBGCC_LIBA # Special flags for CPP when processing the linker script. # Pass the version down so we can handle backwards compatibility
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
@@ -508,7 +508,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.o, $(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
PATCH v3 2/2 efi_loader Makefile: change apps from "always" to "targets"
Adding delay to link commands in 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 lib-target"; sleep 10; $(AR) cDPrsT$(KBUILD_ARFLAGS) $@ $(lib-y)
$(lib-target): $(lib-y) FORCE
$(call if_changed,link_l_target)
(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? n
@@ -362,7 +362,7 @@ targets += $(lib-target)
endif
quiet_cmd_link_multi-y = AR $@
-cmd_link_multi-y = rm -f $@; $(AR) cDPrsT$(KBUILD_ARFLAGS) $@ $(filter %.o,$^)
+cmd_link_multi-y = rm -f $@; echo "HACK delaying cmd_link_multi-y"; sleep 10; $(AR) cDPrsT$(KBUILD_ARFLAGS) $@ $(filter %.o,$^)
quiet_cmd_link_multi-m = AR [M] $@
cmd_link_multi-m = $(cmd_link_multi-y)
exposes a build failure:
make[3]: *** No rule to make target 'lib/efi_loader/helloworld.efi', needed by '__build'. Stop. make[3]: *** Waiting for unfinished jobs....
This if fixed by using normal targets for .efi apps. The rules in scripts/Makefile.lib handle the dependencies correctly.
--- lib/efi_loader/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/efi_loader/Makefile +1 -1
@@ -96,5 +96,5 @@ $(foreach f,$(apps-y),\ $(eval CFLAGS_$(f).o := $(CFLAGS_EFI) -Os -ffreestanding)\ $(eval CFLAGS_REMOVE_$(f).o := $(CFLAGS_NON_EFI))) -always += $(foreach f,$(apps-y),$(f).efi) +targets += $(foreach f,$(apps-y),$(f).efi) targets += $(foreach f,$(apps-y),$(f).o)
Signature · 1 line
2.43.0
Hi Mikko,
Quoted 55 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 | 4 +++- examples/standalone/Makefile | 2 +- scripts/Makefile.lib | 2 +- scripts/Makefile.xpl | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-)
Quoted 2 lines
v3: added "export
PLATFORM_LIBGCC_LIBA" likePLATFORM_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:
Quoted 42 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.
Quoted 5 lines
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]>
So, this series needs a cover letter. And to reword the commit messages, so that the diff to make things fail shows up below the "---". But the fatal problem for right now is this needs to be put through CI next time. This seems to cause some of the EFI apps to not be built now:
https://source.denx.de/u-boot/u-boot/-/jobs/1209924
I assume Azure would have failed too if I let it get that far. Thanks.
Signature · 1 line
Tom
Hi,
Quoted 46 lines · Tom Rini
Quoted 44 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")
Quoted 9 lines
Quoted 3 lines
Cc Adriano Cordova <[email protected]>Cc Fabio Estevam <[email protected]>Signed-off-by Mikko Rapeli <[email protected]>So, this series needs a cover letter. And to reword the commit messages, so that the diff to make things fail shows up below the "---". But the fatal problem for right now is this needs to be put through CI next time. This seems to cause some of the EFI apps to not be built now:
https://source.denx.de/u-boot/u-boot/-/jobs/1209924
Ok, I can add a cover letter but details need to be in commit message too. I'm surprised how many things have failed when commit message has a diff but I will describe the test in some way there.
The issues seen in yocto autobuilder are fixed by the first patch. Second patch is for the failure I saw when building with the hack which delays linking. This breaks the EFI app builds and I can reproduce that. The patch is somehow wrong, but without it the artificially delayed linking step fails in my test builds. I'll investigate this more.
Cheers,
-Mikko
Hi,
Quoted 56 lines · Tom Rini
Quoted 42 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.Quoted 5 lines
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]>So, this series needs a cover letter. And to reword the commit messages, so that the diff to make things fail shows up below the "---". But the fatal problem for right now is this needs to be put through CI next time. This seems to cause some of the EFI apps to not be built now:
https://source.denx.de/u-boot/u-boot/-/jobs/1209924
Quoted 1 line
I assume Azure would have failed too if I let it get that far. Thanks.
I think I finally figured this out and will send a patch to Makefile in v4. arch/$(ARCH)/lib and lib are compiled by separate "make" processes started by top level Makefile, and both use the same scripts/Makefile.build etc. This threw me off quite a bit. And "make" does not tell which dependencies of a target are missing if the file level dependency to lib.a is explicit when linking the EFI apps.
I think the single change to build "arch/$(ARCH)/lib" directory before "lib" in top level Makefile is simple enough to explain in commit message without a coverletter, similar to how "examples" directory is compiled after all other directories for u-boot binaries.
Cheers,
-Mikko
Quoted 68 lines · Mikko Rapeli
Hi,
Quoted 56 lines · Tom Rini
Quoted 42 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.Quoted 5 lines
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]>So, this series needs a cover letter. And to reword the commit messages, so that the diff to make things fail shows up below the "---". But the fatal problem for right now is this needs to be put through CI next time. This seems to cause some of the EFI apps to not be built now:
https://source.denx.de/u-boot/u-boot/-/jobs/1209924Quoted 1 line
I assume Azure would have failed too if I let it get that far. Thanks.
I think I finally figured this out and will send a patch to
Makefilein v4. arch/$(ARCH)/lib and lib are compiled by separate "make" processes started by top levelMakefile, and both use the samescripts/Makefile.buildetc. This threw me off quite a bit. And "make" does not tell which dependencies of a target are missing if the file level dependency to lib.a is explicit when linking the EFI apps.
Quoted 4 lines
I think the single change to build "arch/$(ARCH)/lib" directory before "lib" in top level
Makefileis simple enough to explain in commit message without a coverletter, similar to how "examples" directory is compiled after all other directories for u-boot binaries.
Ah, good job figuring this out!
Signature · 1 line
Tom