From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>, "Wei Liu" <wl@xen.org>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"George Dunlap" <George.Dunlap@eu.citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Anthony PERARD" <anthony.perard@citrix.com>,
"Daniel De Graaf" <dgdegra@tycho.nsa.gov>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [XEN PATCH v2 11/12] xen/build: introduce ccflags-y and CFLAGS_$@
Date: Fri, 17 Jan 2020 10:53:57 +0000 [thread overview]
Message-ID: <20200117105358.607910-12-anthony.perard@citrix.com> (raw)
In-Reply-To: <20200117105358.607910-1-anthony.perard@citrix.com>
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@citrix.com>
---
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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2020-01-17 11:11 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 10:53 [Xen-devel] [XEN PATCH v2 00/12] xen: Build system improvements Anthony PERARD
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 01/12] xen/build: Remove left over -DMAX_PHYS_IRQS Anthony PERARD
2020-01-17 11:03 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 02/12] xen/build: Use obj-y += subdir/ instead of subdir-y Anthony PERARD
2020-01-29 14:19 ` Jan Beulich
2020-01-30 16:54 ` Anthony PERARD
2020-01-31 8:35 ` Jan Beulich
2020-02-03 11:31 ` Anthony PERARD
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 03/12] xen/build: use $(clean) shorthand for clean targets Anthony PERARD
2020-01-29 14:21 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 04/12] xen/build: extract clean target from Rules.mk Anthony PERARD
2020-01-29 14:30 ` Jan Beulich
2020-01-30 18:10 ` Anthony PERARD
2020-01-31 8:50 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 05/12] xen/include: remove include of Config.mk Anthony PERARD
2020-01-29 15:28 ` Jan Beulich
2020-01-29 15:33 ` Jan Beulich
2020-01-30 18:34 ` Anthony PERARD
2020-01-31 8:56 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 06/12] xen/test/livepatch: " Anthony PERARD
2020-01-17 17:17 ` Ross Lagerwall
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 07/12] xen/build: run targets csopes, tags, .. without Rules.mk Anthony PERARD
2020-01-30 11:29 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 08/12] xen/build: make tests in test/ directly Anthony PERARD
2020-01-30 11:31 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 09/12] xen/build: include include/config/auto.conf in main Makefile Anthony PERARD
2020-01-30 13:06 ` Jan Beulich
2020-02-03 11:45 ` Anthony PERARD
2020-02-03 12:20 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 10/12] xen/build: use new $(c_flags) and $(a_flags) instead of $(CFLAGS) Anthony PERARD
2020-01-30 13:29 ` Jan Beulich
2020-02-03 12:17 ` Anthony PERARD
2020-02-03 12:34 ` Jan Beulich
2020-01-17 10:53 ` Anthony PERARD [this message]
2020-01-30 13:39 ` [Xen-devel] [XEN PATCH v2 11/12] xen/build: introduce ccflags-y and CFLAGS_$@ Jan Beulich
2020-02-03 14:23 ` Anthony PERARD
2020-02-03 15:20 ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 12/12] xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-01-30 14:33 ` Jan Beulich
2020-02-03 13:57 ` Anthony PERARD
2020-02-03 15:26 ` Jan Beulich
2020-01-21 13:59 ` [Xen-devel] [XEN PATCH v2.1 13/12] Makefile: Fix install-tests Anthony PERARD
2020-01-30 11:37 ` Jan Beulich
2020-02-03 14:29 ` Anthony PERARD
2020-02-03 15:21 ` Jan Beulich
2020-01-21 13:59 ` [Xen-devel] [XEN PATCH v2.1 14/12] squash! xen/build: introduce ccflags-y and CFLAGS_$@ Anthony PERARD
2020-01-21 13:59 ` [Xen-devel] [XEN PATCH v2.1 15/12] squash! xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-01-30 13:32 ` Jan Beulich
2020-02-03 14:32 ` Anthony PERARD
2020-01-21 14:08 ` [Xen-devel] [XEN PATCH v2 00/12] xen: Build system improvements Anthony PERARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200117105358.607910-12-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=konrad.wilk@oracle.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).