[PATCH] Makefile: Make sure all linker input objects exist
Marek Vasut
marek.vasut at mailbox.org
Sat Jan 18 08:08:05 CET 2025
On 1/15/25 11:38 AM, Quentin Schulz wrote:
> Hi Marek,
Hi,
> On 1/12/25 11:32 PM, Marek Vasut wrote:
>> 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 at mailbox.org>
>
> I tested this with the following diff:
[..]
> which allows me to use HAVE_VENDOR_COMMON_LIB mechanism with an empty
> Makefile for TPL/SPL build stage, so:
>
> Tested-by: Quentin Schulz <quentin.schulz at cherry.de>
Thank you
> Looking forward to being able to use HAVE_VENDOR_COMMON_LIB!
>
> Though I could actually always include the file and just ifdef
> CONFIG_XPL_BUILD in common.o, but let's see where this patch goes first :)
If the intent is to use an empty Makefile (with or without ifdeferry) in
any directory pulled into the build, to mitigate the missing built-in.o
problem, that also won't work without this patch, because empty Makefile
itself won't lead to generation of the built-in.o .
More information about the U-Boot
mailing list