Skip to contentSkip to conversation

xen/Rules.mk: Do not dance about pointlessly with CFLAGS_tmp

PATCH In review Ian Jackson 2 participants 3 messages Jan 12, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/Rules.mk: Do not dance about pointlessly with CFLAGS_tmp

It is usually better to use =' in Makefiles than :='. The expansion rules for `:=' are simpler - so simple in fact that they don't work if any part of the expansion depends on the source or target filenames.

In this patch we remove the shuffling of the value of CFLAGS between := and = flavour variables. This was previously `necessary' because otherwise it would run the seddery for removing -fomit-frame-pointer once for each rule.

However this seddery is not actually necessary because there is plenty of other machinery for (a) only setting -fomit-frame-frame-pointer when applicable AND (b) passing -fno-omit-frame-pointer later on the command line if it's not applicable. So we already have belt and braces and can remove the safety pins.

xen/Rules.mk +2 -8
diff -r 95d8788bf4be xen/Rules.mk
@@ -22,9 +22,6 @@ endif
 endif
 ifeq ($(perfc_arrays),y)
 perfc := y
-endif
-ifeq ($(frame_pointer),y)
-CFLAGS := $(shell echo $(CFLAGS) | sed -e 's/-f[^ ]*omit-frame-pointer//g')
 endif
 
 # Set ARCH/SUBARCH appropriately.
@@ -64,14 +61,11 @@ AFLAGS-y                += -D__ASSEMBLY_
 
 ALL_OBJS := $(ALL_OBJS-y)
 
-CFLAGS_tmp := $(strip $(CFLAGS) $(CFLAGS-y))
-CFLAGS = $(CFLAGS_tmp) -MMD -MF .$(@F).d
+CFLAGS += $(CFLAGS-y) -MMD -MF .$(@F).d
 
 # Most CFLAGS are safe for assembly files:
 #  -std=gnu{89,99} gets confused by #-prefixed end-of-line comments
-AFLAGS_tmp := $(strip $(AFLAGS) $(AFLAGS-y))
-AFLAGS_tmp += $(patsubst -std=gnu%,,$(CFLAGS_tmp))
-AFLAGS = $(AFLAGS_tmp) -MMD -MF .$(@F).d
+AFLAGS += $(AFLAGS-y) $(filter-out -std=gnu%,$(CFLAGS))
 
 # LDFLAGS are only passed directly to $(LD)
 LDFLAGS  := $(strip $(LDFLAGS) $(LDFLAGS_DIRECT))

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 9 lines · Ian Jackson

It is usually better to use =' in Makefiles than :='. The expansion rules for `:=' are simpler - so simple in fact that they don't work if any part of the expansion depends on the source or target filenames.

In this patch we remove the shuffling of the value of CFLAGS between := and = flavour variables. This was previously `necessary' because otherwise it would run the seddery for removing -fomit-frame-pointer once for each rule.

Quoted 5 lines

However this seddery is not actually necessary because there is plenty of other machinery for (a) only setting -fomit-frame-frame-pointer when applicable AND (b) passing -fno-omit-frame-pointer later on the command line if it's not applicable. So we already have belt and braces and can remove the safety pins.

You missed a := in arch/x86/Rules.mk. Can that one be avoided so easily?

-- Keir

#2 lore raw
Quoted 7 lines · Keir Fraser
Quoted 5 lines

However this seddery is not actually necessary because there is plenty of other machinery for (a) only setting -fomit-frame-frame-pointer when applicable AND (b) passing -fno-omit-frame-pointer later on the command line if it's not applicable. So we already have belt and braces and can remove the safety pins.

You missed a := in arch/x86/Rules.mk. Can that one be avoided so easily?

Ah, well the answer is rather obviously yes. I'll fix this one up myself and check it in.

I'll also adjust cc-option to run $(CC) immediately and add the resulting appropriate option correctly even to a recursively-expanded variable. So $(CC) execution is not delayed and does not occur multiple times even if CFLAGS is expanded multiple times.

-- Keir