All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kvm-unit-tests] build: don't reevaluate cc-option shell command
@ 2016-03-12  0:21 Peter Feiner
  2016-03-14 14:03 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Feiner @ 2016-03-12  0:21 UTC (permalink / raw)
  To: drjones, pbonzini, kvm; +Cc: pfeiner

Make was reevaluating the shell commands in CFLAGS for every recipe
because CFLAGS was defined as a recursively-expanded variable. Doing a
simple expansion before putting the command output in CFLAGS prevents
this reevaluation.

The difference this change makes for the x86 build is stark:

BEFORE:
	make -j  6.17s user 5.74s system 167% cpu 7.117 total
	make  6.52s user 5.70s system 89% cpu 13.664 total

AFTER:
	make -j  4.03s user 1.47s system 1036% cpu 0.530 total
	make  3.69s user 2.16s system 92% cpu 6.310 total

Signed-off-by: Peter Feiner <pfeiner@google.com>
---
 Makefile | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 09999c6..2a2d942 100644
--- a/Makefile
+++ b/Makefile
@@ -42,9 +42,13 @@ cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \
 
 CFLAGS += -g
 CFLAGS += $(autodepend-flags) -Wall -Werror
-CFLAGS += $(call cc-option, -fomit-frame-pointer, "")
-CFLAGS += $(call cc-option, -fno-stack-protector, "")
-CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
+
+fomit_frame_pointer := $(call cc-option, -fomit-frame-pointer, "")
+fnostack_protector := $(call cc-option, -fno-stack-protector, "")
+fnostack_protector_all := $(call cc-option, -fno-stack-protector-all, "")
+CFLAGS += $(fomit_frame_pointer)
+CFLAGS += $(fno_stack_protector)
+CFLAGS += $(fno_stack_protector_all)
 
 CXXFLAGS += $(CFLAGS)
 
-- 
2.7.0.rc3.207.g0ac5344


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

end of thread, other threads:[~2016-03-14 14:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-12  0:21 [PATCH kvm-unit-tests] build: don't reevaluate cc-option shell command Peter Feiner
2016-03-14 14:03 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.