summaryrefslogtreecommitdiff
path: root/config.mk
diff options
context:
space:
mode:
authorDaniel Schwierzeck <daniel.schwierzeck@googlemail.com>2011-11-02 19:46:31 +0100
committerGerrit <chrome-bot@google.com>2011-11-22 14:20:51 -0800
commit0f46e7520c53d2ee3d5bc87b4f597a07137c2137 (patch)
tree95956438f278b8981e4249a1c6ed1ff1a02ef1eb /config.mk
parent20af9dcaed30c7f5f42a0cbdf9eb5370a06d0a78 (diff)
UPSTREAM: config.mk: use memoization in cc-option macro to speed up compilation
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> (cherry picked from commit f5fd7cd17552daf41677f6aa1c9eef48055c98a8) Change-Id: I76d9d6ccab7ba2aefc1e63a5f5e16c8a7aeadef7 Reviewed-on: https://gerrit.chromium.org/gerrit/11807 Reviewed-by: Doug Anderson <dianders@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Commit-Ready: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'config.mk')
-rw-r--r--config.mk14
1 files changed, 14 insertions, 0 deletions
diff --git a/config.mk b/config.mk
index 9d36d4754e..aeafbd4c98 100644
--- a/config.mk
+++ b/config.mk
@@ -95,8 +95,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...)