[PATCH] kbuild: use which $(DTC) as a dependency

sorki srk at 48.io
Tue Oct 17 14:04:07 CEST 2023


On 10/17/23 13:27, Rasmus Villemoes wrote:
> On 17/10/2023 12.44, Richard Marko wrote:
>> If we try to build using external dtc using
>>
>>> make DTC=dtc
>> we get a confusing error like
>>
>>> make[2]: *** No rule to make target 'arch/x86/dts/bayleybay.dtb',
>>> needed by 'dtbs'.  Stop.
>> Workaround is to use
>>
>>> make DTC=$( which dtc )
>> which gives make a full path, so the dependency
>> is satisfied.
>>
>> This was introduced by commit
>> d50af66 kbuild: add dtc as dependency on .dtb files
>>
>> and we extend it so it calls which automatically
>> (similar to scripts/dtc-version.sh)
>
> Let's please not deviate from linux Kbuild unless we absolutely have to.
> In this case, passing an absolute path works just fine, and is AFAICT
> the only documented way to pass DTC. E.g. doc/build/gcc.rst has
>
>      DTC=/usr/bin/dtc make
>
> as example.
>
> [And if we do this, then at the very least this should also be done for
> the .dtbo rule and wherever else $(DTC) is used. But I'm really not a
> fan of calling out to $(shell which ...) in the rule itself. Perhaps if
> it was done just once, near DTC/DTC_IN_TREE, something like (not real
> make syntax I think)
>
> ifneq ($(DTC), $(DTC_IN_TREE))
> DTC := $(shell which $(DTC))
> endif
>
> But I don't think we should be doing this at all.]
>
> Rasmus
>
I'm fine with passing a full path and not adding this.

The DTC=dtc thingie was done in NixOS and it stopped working for recent 
versions. It took me a while to figure out what is going on because the 
failure message seems very unrelated and no dtc is called except for 
dtc-version.sh check which passes just fine. Alternatively we could fail 
earlier if $(DTC) is not an absolute path and get rid of `which` call in 
dtc-version.sh but I'm not sure how to formulate that into make either.

Richard



More information about the U-Boot mailing list