[PATCH] Makefile: fix empty MK_ARCH when using ccache

Quentin Schulz quentin.schulz at cherry.de
Mon Nov 11 15:43:27 CET 2024


Hi Heinrich,

On 11/11/24 3:27 PM, Heinrich Schuchardt wrote:
> Am 11. November 2024 14:20:49 MEZ schrieb Quentin Schulz <foss+uboot at 0leil.net>:
>> From: Quentin Schulz <quentin.schulz at cherry.de>
>>
>> One can use ccache by prefixing the typical CROSS_COMPILE value with
>> "ccache " (e.g. "ccache aarch64-gnu-linux-" for Aarch64). This however
>> makes the MK_ARCH empty because sed won't find a match anymore since it
>> expects the CROSS_COMPILE value to start with the actual toolchain (with
>> an unlimited number of white spaces before).
>>
>> This is failing builds since commit 7506c1566998 ("sandbox: Report host
>> default-filename in native mode").
>>
>> Add "ccache" prefix to ignore but participate in the matching regex used
>> by sed to identify the target architecture.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz at cherry.de>
>> ---
>> One can use ccache by prefixing the typical CROSS_COMPILE value with
>> "ccache " (e.g. "ccache aarch64-gnu-linux-" for Aarch64). This however
>> makes the MK_ARCH empty because sed won't find a match anymore since it
>> expects the CROSS_COMPILE value to start with the actual toolchain (with
>> an unlimited number of white spaces before).
>>
>> This is failing builds since commit 7506c1566998 ("sandbox: Report host
>> default-filename in native mode").
>>
>> Add "ccache" prefix to ignore but participate in the matching regex used
>> by sed to identify the target architecture.
>> ---
>> Makefile | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 7275a02f24ca64ebd46c5dc6e769dcdee9917dca..71743db16fca930567edd67eb77f1c94e9b7b4e9 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -21,7 +21,7 @@ include include/host_arch.h
>> ifeq ("", "$(CROSS_COMPILE)")
>>    MK_ARCH="${shell uname -m}"
>> else
>> -  MK_ARCH="${shell echo $(CROSS_COMPILE) | sed -n 's/^[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\2/p'}"
>> +  MK_ARCH="${shell echo $(CROSS_COMPILE) | sed -n 's/^\(ccache\)\?[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\3/p'}"
> 
> The target architecture cannot be determined in this way.
> 
> You could use the riscv64 compiler to compile riscv32 when providing a gcc flag.
> 
> You should not make any assumptions about the naming scheme of vendor toolchains.
> 

I am assuming nothing more than what we are already assuming for the 
last three and half years, c.f. f7691a6d736bec7915c227ac14076f9993a27367.

Cheers,
Quentin


More information about the U-Boot mailing list