Skip to contentSkip to conversation

x86: fold linker script pre-processing rules

PATCH In review Jan Beulich 3 participants 4 messages Jan 30, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: fold linker script pre-processing rules

There's no need to have twice almost the same rule. Simply add the extra -DEFI to AFLAGS for the EFI variant, and specify both targets for the then single rule.

xen/arch/x86/Makefile +2 -5
@@ -241,15 +241,12 @@ $(BASEDIR)/include/generated/config.h: F
 	echo '#endif' >>[email protected]
 	$(call move-if-changed,[email protected],$@)
 
-xen.lds: xen.lds.S
+xen.lds efi.lds: xen.lds.S
 	$(CC) -P -E -Ui386 $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $<
 	sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new
 	mv -f .$(@F).d.new .$(@F).d
 
-efi.lds: xen.lds.S
-	$(CC) -P -E -Ui386 -DEFI $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $<
-	sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new
-	mv -f .$(@F).d.new .$(@F).d
+efi.lds: AFLAGS += -DEFI
 
 boot/mkelf32: boot/mkelf32.c
 	$(HOSTCC) $(HOSTCFLAGS) -o $@ $<

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#1 lore raw
Quoted 13 lines · Jan Beulich

There's no need to have twice almost the same rule. Simply add the extra -DEFI to AFLAGS for the EFI variant, and specify both targets for the then single rule.

xen/arch/x86/Makefile +0 -1
@@ -241,15 +241,12 @@ $(BASEDIR)/include/generated/config.h: F
 	echo '#endif' >>[email protected]
 	$(call move-if-changed,[email protected],$@)
 
-xen.lds: xen.lds.S

xen/arch/x86/Makefile $(BASEDIR)/include/generated/config.h: F · line 249

Quoted 10 lines
xen/arch/x86/Makefile +2 -4
+xen.lds efi.lds: xen.lds.S
 	$(CC) -P -E -Ui386 $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $<
 	sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new
 	mv -f .$(@F).d.new .$(@F).d
 
-efi.lds: xen.lds.S
-	$(CC) -P -E -Ui386 -DEFI $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $<
-	sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new
-	mv -f .$(@F).d.new .$(@F).d
+efi.lds: AFLAGS += -DEFI

I think it would be more natural to read with this line at the top, ahead of the rule:

efi.lds: AFLAGS += -DEFI
xen.lds efi.lds: xen.lds.S
        ...

Either way, Acked-by: Andrew Cooper <[email protected]>

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 28 lines · Andrew Cooper
Quoted 13 lines · Jan Beulich

There's no need to have twice almost the same rule. Simply add the extra -DEFI to AFLAGS for the EFI variant, and specify both targets for the then single rule.

xen/arch/x86/Makefile +0 -1
@@ -241,15 +241,12 @@ $(BASEDIR)/include/generated/config.h: F
 	echo '#endif' >>[email protected]
 	$(call move-if-changed,[email protected],$@)
 
-xen.lds: xen.lds.S

xen/arch/x86/Makefile $(BASEDIR)/include/generated/config.h: F · line 249

Quoted 10 lines
xen/arch/x86/Makefile +2 -4
+xen.lds efi.lds: xen.lds.S
 	$(CC) -P -E -Ui386 $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $<
 	sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new
 	mv -f .$(@F).d.new .$(@F).d
 
-efi.lds: xen.lds.S
-	$(CC) -P -E -Ui386 -DEFI $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $<
-	sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new
-	mv -f .$(@F).d.new .$(@F).d
+efi.lds: AFLAGS += -DEFI

I think it would be more natural to read with this line at the top, ahead of the rule:

Quoted 3 lines

efi.lds: AFLAGS += -DEFI
xen.lds efi.lds: xen.lds.S
        ...

In fact I first wanted to do it this way, then thought the EFI special case shouldn't come earlier than the general one. But since you ask for it ...

Quoted 1 line

Either way, Acked-by: Andrew Cooper <[email protected]>

Thanks.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/1
#3 lore raw
In reply to Jan Beulich
Quoted 5 lines · Jan Beulich

There's no need to have twice almost the same rule. Simply add the extra -DEFI to AFLAGS for the EFI variant, and specify both targets for the then single rule.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel