public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] config.mk: use memoization in cc-option macro to speed up compilation
@ 2011-11-02 18:46 Daniel Schwierzeck
  2011-11-02 20:39 ` Simon Glass
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Daniel Schwierzeck @ 2011-11-02 18:46 UTC (permalink / raw)
  To: u-boot

Apply memoization to cc-option macro by caching the results of the
gcc calls. This macro is called very often so using cached results
leads to faster compilation times.

This feature can be enabled by setting CACHE_CC_OPTIONS=y in the
environment.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
---

Some MAKEALL runs for ARM and MIPS (on Core 2 Duo E6600 at 2.4GHz):

time CROSS_COMPILE=/opt/codesourcery/arm-2011.03/bin/arm-none-linux-gnueabi-
MAKEALL_LOGDIR=../logs/ BUILD_DIR=../test/ ./MAKEALL -s omap3 -v ti

real	3m0.380s
user	9m30.570s
sys	1m34.550s


time CACHE_CC_OPTIONS=y CROSS_COMPILE=/opt/codesourcery/arm-2011.03/bin/arm-none-linux-gnueabi-
MAKEALL_LOGDIR=../logs/ BUILD_DIR=../test/ ./MAKEALL -s omap3 -v ti

real	1m15.661s
user	4m21.510s
sys	0m33.190s


time CROSS_COMPILE=/opt/codesourcery/mips-2011.03/bin/mips-linux-gnu-
MAKEALL_LOGDIR=../logs/ BUILD_DIR=../test/ ./MAKEALL mips4kc

real	2m49.883s
user	6m25.840s
sys	0m58.200s


time CACHE_CC_OPTIONS=y CROSS_COMPILE=/opt/codesourcery/mips-2011.03/bin/mips-linux-gnu-
MAKEALL_LOGDIR=../logs/ BUILD_DIR=../test/ ./MAKEALL mips4kc

real	2m18.205s
user	4m59.740s
sys	0m39.530s

 config.mk |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

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
+
+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
 
 #
 # Include the make variables (CC, etc...)
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-11-07 21:07 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-02 18:46 [U-Boot] [PATCH] config.mk: use memoization in cc-option macro to speed up compilation Daniel Schwierzeck
2011-11-02 20:39 ` Simon Glass
2011-11-02 21:36   ` Daniel Schwierzeck
2011-11-03 19:47     ` Wolfgang Denk
2011-11-04 12:53 ` [U-Boot] [PATCH v2] " Daniel Schwierzeck
2011-11-04 16:32   ` Simon Glass
2011-11-04 17:15     ` Daniel Schwierzeck
2011-11-04 17:31   ` Daniel Schwierzeck
2011-11-04 17:56     ` Wolfgang Denk
2011-11-05  9:16       ` Albert ARIBAUD
2011-11-05 13:30         ` Wolfgang Denk
2011-11-05 13:43         ` Daniel Schwierzeck
2011-11-05 15:02           ` Albert ARIBAUD
2011-11-07 15:26   ` [U-Boot] [PATCH v3] " Daniel Schwierzeck
2011-11-07 21:07     ` Wolfgang Denk
     [not found] ` <1320410756-30391-1-git-send-email-daniel.schwierzeck@googlemail.com>
2011-11-05  7:17   ` [U-Boot] [PATCH v2] " Aneesh V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox