diff options
author | Marek Vasut <marek.vasut+renesas@mailbox.org> | 2025-01-12 23:32:38 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-01-18 08:28:16 -0600 |
commit | 37a777e1286e5c43a8d5b9babeec9436733224d7 (patch) | |
tree | 8b473987e6baa213ec0b2457f7fa092ca3f856e0 /scripts | |
parent | 24c76a1f437b75157cca8072b4ec124e5827565a (diff) | |
download | u-boot-37a777e1286e5c43a8d5b9babeec9436733224d7.tar.gz |
Makefile: Make sure all linker input objects exist
In case the build system builds a directory with empty Makefile,
one which does not contain any obj-y entries, the build fails to
link due to missing built-in.o .
This happens because of this part of scripts/Makefile.build
81 ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
82 builtin-target := $(obj)/built-in.o
83 endif
which does not assign builtin-target in case obj-y is empty. The
built-in target is then not built at all, and built-in.o is not
generated by this part of scripts/Makefile.build
325 ifdef builtin-target
326 quiet_cmd_link_o_target = AR $@
327 # If the list of objects to link is empty, just create an empty built-in.o
...
335 targets += $(builtin-target)
336 endif # builtin-target
This is the correct behavior.
The final link however expects the built-in.o to exist in every directory
included in the build, even in those where the aforementioned code skipped
generation of built-in.o . Make sure the built-in.o does exist for every
directory used in final link simply by doing touch on every built-in.o used
for the link, which will create empty built-in.o in case any built-in.o is
missing.
A possible alternative fix is the always define the builtin-target
and always generate built-in.o .
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Tested-by: Quentin Schulz <quentin.schulz@cherry.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.xpl | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/scripts/Makefile.xpl b/scripts/Makefile.xpl index dca5f4539d0..abc49fbe6c9 100644 --- a/scripts/Makefile.xpl +++ b/scripts/Makefile.xpl @@ -510,6 +510,7 @@ quiet_cmd_u-boot-spl ?= LTO $@ cmd_u-boot-spl ?= \ ( \ cd $(obj) && \ + touch $(patsubst $(obj)/%,%,$(u-boot-spl-main)) && \ $(CC) -nostdlib -nostartfiles $(LTO_FINAL_LDFLAGS) $(c_flags) \ $(KBUILD_LDFLAGS:%=-Wl,%) $(LDFLAGS_$(@F):%=-Wl,%) \ $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \ @@ -526,6 +527,7 @@ quiet_cmd_u-boot-spl ?= LD $@ cmd_u-boot-spl ?= \ ( \ cd $(obj) && \ + touch $(patsubst $(obj)/%,%,$(u-boot-spl-main)) && \ $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_$(@F)) \ $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \ --whole-archive \ |