|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [XEN PATCH v2 11/12] xen/build: introduce ccflags-y and CFLAGS_$@
We are going to want $(CFLAGS) to be static and never change during
the build, so introduce new variables that can be use to change the
flags of a single target or of a whole directory.
Those two variables are taken from Kbuild, in Linux v5.4.
Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
xen/Rules.mk | 7 ++++++-
xen/arch/arm/efi/Makefile | 2 +-
xen/arch/x86/Makefile | 6 +++---
xen/arch/x86/efi/Makefile | 2 +-
xen/common/libelf/Makefile | 2 +-
xen/common/libfdt/Makefile | 2 +-
xen/xsm/flask/Makefile | 2 +-
xen/xsm/flask/ss/Makefile | 2 +-
8 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/xen/Rules.mk b/xen/Rules.mk
index c98d5372f3db..f0111f2bc1b4 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -39,6 +39,7 @@ ALL_OBJS-$(CONFIG_CRYPTO) += $(BASEDIR)/crypto/built_in.o
# Initialise some variables
CFLAGS_UBSAN :=
+ccflags-y :=
ifeq ($(CONFIG_DEBUG),y)
CFLAGS += -O1
@@ -137,9 +138,13 @@ endif
# Always build obj-bin files as binary even if they come from C source.
$(obj-bin-y): CFLAGS := $(filter-out -flto,$(CFLAGS))
+# target with its suffix stripped
+target-stem = $(basename $@)
+
c_flags = -MMD -MF $(@D)/.$(@F).d \
$(CFLAGS) \
- '-D__OBJECT_FILE__="$@"'
+ '-D__OBJECT_FILE__="$@"' \
+ $(ccflags-y) $(CFLAGS_$(target-stem).o)
a_flags = -MMD -MF $(@D)/.$(@F).d \
$(AFLAGS)
diff --git a/xen/arch/arm/efi/Makefile b/xen/arch/arm/efi/Makefile
index d34c9168914a..e4aaba3e074b 100644
--- a/xen/arch/arm/efi/Makefile
+++ b/xen/arch/arm/efi/Makefile
@@ -1,4 +1,4 @@
-CFLAGS += -fshort-wchar
+ccflags-y += -fshort-wchar
obj-y += boot.init.o runtime.o
obj-$(CONFIG_ACPI) += efi-dom0.init.o
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 472e3fadb719..acf4c145c896 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -174,14 +174,14 @@ EFI_LDFLAGS += --major-subsystem-version=2
--minor-subsystem-version=0
export XEN_BUILD_EFI := $(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS))
-c efi/check.c -o efi/check.o 2>/dev/null && echo y)
# Check if the linker supports PE.
XEN_BUILD_PE := $(if $(XEN_BUILD_EFI),$(shell $(LD) -mi386pep --subsystem=10
-o efi/check.efi efi/check.o 2>/dev/null && echo y))
-CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI
+ccflags-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI
$(TARGET).efi: VIRT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A
VIRT_START$$,,p')
$(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A
ALT_START$$,,p')
ifneq ($(build_id_linker),)
ifeq ($(call ld-ver-build-id,$(LD) $(filter -m%,$(EFI_LDFLAGS))),y)
-CFLAGS += -DBUILD_ID_EFI
+ccflags-y += -DBUILD_ID_EFI
EFI_LDFLAGS += $(build_id_linker)
note_file := efi/buildid.o
# NB: this must be the last input in the linker call, because inputs following
@@ -227,7 +227,7 @@ efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o
efi/relocs-dummy.o: ;
asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c
$(BASEDIR)/include/asm-x86/asm-macros.h
$(CC) $(filter-out -Wa$(comma)% -flto,$(c_flags)) -S -o $@ $<
-asm-macros.i: CFLAGS += -D__ASSEMBLY__ -P
+CFLAGS_asm-macros.o += -D__ASSEMBLY__ -P
$(BASEDIR)/include/asm-x86/asm-macros.h: asm-macros.i Makefile
echo '#if 0' >$@.new
diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile
index 4bc0a196e9ca..2cbb3de3a8ab 100644
--- a/xen/arch/x86/efi/Makefile
+++ b/xen/arch/x86/efi/Makefile
@@ -1,4 +1,4 @@
-CFLAGS += -fshort-wchar
+ccflags-y += -fshort-wchar
%.o: %.ihex
$(OBJCOPY) -I ihex -O binary $< $@
diff --git a/xen/common/libelf/Makefile b/xen/common/libelf/Makefile
index 3d9e38f27e65..9a433f01fbd4 100644
--- a/xen/common/libelf/Makefile
+++ b/xen/common/libelf/Makefile
@@ -3,7 +3,7 @@ nocov-y += libelf.o
SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
-CFLAGS += -Wno-pointer-sign
+ccflags-y += -Wno-pointer-sign
libelf.o: libelf-temp.o Makefile
$(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s))
$< $@
diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile
index c075bbf5462a..9ea5c696d52a 100644
--- a/xen/common/libfdt/Makefile
+++ b/xen/common/libfdt/Makefile
@@ -5,7 +5,7 @@ SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
obj-y += libfdt.o
nocov-y += libfdt.o
-CFLAGS += -I$(BASEDIR)/include/xen/libfdt/
+ccflags-y += -I$(BASEDIR)/include/xen/libfdt/
libfdt.o: libfdt-temp.o Makefile
$(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s))
$< $@
diff --git a/xen/xsm/flask/Makefile b/xen/xsm/flask/Makefile
index b1fd45421993..3bf0a6fa0456 100644
--- a/xen/xsm/flask/Makefile
+++ b/xen/xsm/flask/Makefile
@@ -4,7 +4,7 @@ obj-y += flask_op.o
obj-y += ss/
-CFLAGS += -I./include
+ccflags-y += -I./include
AWK = awk
diff --git a/xen/xsm/flask/ss/Makefile b/xen/xsm/flask/ss/Makefile
index 046ce8f53326..30f910a9c9c1 100644
--- a/xen/xsm/flask/ss/Makefile
+++ b/xen/xsm/flask/ss/Makefile
@@ -8,4 +8,4 @@ obj-y += services.o
obj-y += conditional.o
obj-y += mls.o
-CFLAGS += -I../include
+ccflags-y += -I../include
--
Anthony PERARD
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |