[U-Boot] [PATCH] config.mk: use memoization in cc-option macro to speed up compilation

Daniel Schwierzeck daniel.schwierzeck at googlemail.com
Wed Nov 2 22:36:29 CET 2011


Hi Simon,

On 02.11.2011 21:39, Simon Glass wrote:
...
>>
>> diff --git a/config.mk b/config.mk
>> index 11b67e5..27c366f 100644
>> --- a/config.mk
>> +++ b/config.mk
>> @@ -107,8 +107,22 @@ HOSTCFLAGS += -pedantic
>>   # Option checker (courtesy linux kernel) to ensure
>>   # only supported compiler options are used
>>   #
>> +ifeq ($(CACHE_CC_OPTIONS),y)
>> +sinclude $(OBJTREE)/include/cc-options.mk
>
> It would be better to put this into include/generated - it will also
> make git ignore it and it will be also be removed on clobber which I
> think you need.

The patch is still experimental. But I will move that file to 
include/generated in the final version.

>
>> +
>> +cc-option-cached = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
>> +>  /dev/null 2>&1; then \
>> +               echo 'CC_OPTIONS += $(strip $1)' \
>> +>>  $(OBJTREE)/include/cc-options.mk; \
>> +               echo "$(1)"; else echo "$(2)"; fi ;)
>> +
>> +cc-option = $(if $(filter $1,$(CC_OPTIONS)),\
>> +               $(filter $1,$(CC_OPTIONS)),\
>> +               $(call cc-option-cached,$1,$2))
>> +else
>>   cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
>>                 >  /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
>> +endif
>>
>
> Tested-by: Simon Glass<sjg at chromium.org>
>
> With this patch and Wolfgang's I get 1.122s for an incremental build
> now. Now I just need faster SPI flash and a faster car to get to work
> sooner.
>
> Is there any reason not to enable this option by default?

To see the difference between compilation times with and without this 
optimization and to do not break existing code. In the final version I 
would remove the config switch and enable the optimization by default ;)

Best regards,
Daniel



More information about the U-Boot mailing list