From nobody Tue Dec 23 12:39:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1585650757; cv=none; d=zohomail.com; s=zohoarc; b=DaEFM168j3KwySCrPYb+HwKOpF2X5mkrMVNg29iPgR5AcJoQj6P/eKsQLVX2mbD1q1lx+Sxp/iPzR5praJdi5rp7U0oAT+Vi0ICMgyvYOTLDhr3WDs88yGVIRGok1szoujVNGfBK7+LPM70LYBVLYAeL48O+MtJjTHfRqpMBOVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585650757; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ckke9Vg+k4p1bI3H1ZqGEUHEDEeXbaLsVaUl0l1kZHE=; b=P6gTS6Ixm4BqRpqM6wuaZ8BRRoDyZaKuWmPEdqcnWBYcscO9FmfZXsyHCxFcoFvYQdufV1yZ661IGkllzpS/iO84FsQz/Er6+jjPLt/C0s9mocIUAQ0bwrjMUjzVJdzvhEUAXkfMgOwefACroK7wDtN0QORPn5C2EMexWuvjnes= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1585650757405512.7395019552049; Tue, 31 Mar 2020 03:32:37 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jJEBV-0001Hg-6Z; Tue, 31 Mar 2020 10:31:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jJEBU-0001Gy-4X for xen-devel@lists.xenproject.org; Tue, 31 Mar 2020 10:31:52 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d09ef088-733a-11ea-83d8-bc764e2007e4; Tue, 31 Mar 2020 10:31:43 +0000 (UTC) X-Inumbo-ID: d09ef088-733a-11ea-83d8-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1585650703; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=urX0oNruXSy704Xb8768tt/5GIHekC4HLoiuLnPVD/c=; b=LlNkG8TEHFa+CWjds2RDWA4zBIgCpxYqTFi+J78LkG0VX1qCLVt1odTF 2epO1u8s2Zb74QcMVBKiketAmqioS+INRHWXcT/RzyTE33ndXSv07EBfO uJLV55VvvKRonvd3qrgaStROQCVGtu66cHZ+wufv0YiidhcHEpNAFsfta 8=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 0yoP6ZNd3hbcRXq3TRT5lLXe+Po9gv3SZLR28+g94EwCZZi9ze9HxYXjO9N2G3KE0cGS+8A2Ij QuLVtsgn8Dc6TZ5FB6upkk8GNPZGJahhgQH1/idqr+91uzY0xEasjgU+0O7KB8AhP3ik0HwLeC +bpNVfV1XxpQyAobH4L7h5abdt3lz4lJcW+FqQc3fN7eKpK5xZ3CeS2+/Nru8Ob4x10IpZpmF3 XOozLuGEzM9bTeV4d1IGExjx0FkhVRhxtpkGtt8jTGXaAh257X8yVQQtouYIwqg/GzyhxJS9nc M0s= X-SBRS: 2.7 X-MesageID: 15575939 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.72,327,1580792400"; d="scan'208";a="15575939" From: Anthony PERARD To: Subject: [XEN PATCH v4 06/18] xen/build: have the root Makefile generates the CFLAGS Date: Tue, 31 Mar 2020 11:30:50 +0100 Message-ID: <20200331103102.1105674-7-anthony.perard@citrix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200331103102.1105674-1-anthony.perard@citrix.com> References: <20200331103102.1105674-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Jan Beulich , Anthony PERARD , Daniel De Graaf , Volodymyr Babchuk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Instead of generating the CFLAGS in Rules.mk everytime we enter a new subdirectory, we are going to generate most of them a single time, and export the result in the environment so that Rules.mk can use it. The only flags left to be generated are the ones that depend on the targets, but the variable $(c_flags) takes care of that. Arch specific CFLAGS are generated by a new file "arch/*/arch.mk" which is included by the root Makefile. We export the *FLAGS via the environment variables XEN_*FLAGS because Rules.mk still includes Config.mk and would add duplicated flags to CFLAGS. When running Rules.mk in the root directory (xen/), the variable `root-make-done' is set, so `need-config' will remain undef and so the root Makefile will not generate the cflags again. We can't use CFLAGS in subdirectories to add flags to particular targets, instead start to use CFLAGS-y. Idem for AFLAGS. So there are two different CFLAGS-y, the one in xen/Makefile (and arch.mk), and the one in subdirs that Rules.mk is going to use. We can't add to XEN_CFLAGS because it is exported, so making change to it might be propagated to subdirectory which isn't intended. Some style change are introduced in this patch: when LDFLAGS_DIRECT is included in LDFLAGS use of CFLAGS-$(CONFIG_INDIRECT_THUNK) instead of ifeq(). There is on FIXME added about LTO build, but since LTO is marked as BROKEN, this commit doesn't attempt to filter -flto flags out of the CFLAGS. Signed-off-by: Anthony PERARD --- Notes: v4: - typos - Adding $(AFLAGS-y) to $(AFLAGS) =20 v3: - squash "xen/build: introduce ccflags-y and CFLAGS_$@" here, with those changes: - rename ccflags-y to simply CFLAGS-y and start using AFLAGS-y in subdirs. - remove CFLAGS_$@, we don't need it yet. - fix build of xen.lds and efi.lds which needed -D to be a_flags - remove arch_ccflags, and modify c_flags directly with that change, reorder c_flags, so that target specific flags are = last. - remove HAVE_AS_QUOTED_SYM from envvar and check XEN_CFLAGS to find if it's there when adding -D__OBJECT_LABEL__. - fix missing some flags in AFLAGS (like -fshort-wchar in xen/arch/x86/efi/Makefile, and -D__OBJECT_LABEL__ and CFLAGS-stack-boundary) - keep COV_FLAGS generation in Rules.mk since it doesn't invovle to call CC - fix clang test for "asm()-s support .include." (in a new patch done ahead) - include Kconfig.include in xen/Makefile because as-option-add is defined there now. xen/Makefile | 58 +++++++++++++++++++ xen/Rules.mk | 74 +++++++----------------- xen/arch/arm/Makefile | 10 ++-- xen/arch/arm/Rules.mk | 23 -------- xen/arch/arm/{Rules.mk =3D> arch.mk} | 5 -- xen/arch/arm/efi/Makefile | 2 +- xen/arch/x86/Makefile | 24 ++++---- xen/arch/x86/Rules.mk | 91 ++---------------------------- xen/arch/x86/{Rules.mk =3D> arch.mk} | 17 ++---- xen/arch/x86/efi/Makefile | 2 +- xen/common/libelf/Makefile | 4 +- xen/common/libfdt/Makefile | 4 +- xen/include/Makefile | 2 +- xen/xsm/flask/Makefile | 2 +- xen/xsm/flask/ss/Makefile | 2 +- 15 files changed, 115 insertions(+), 205 deletions(-) copy xen/arch/arm/{Rules.mk =3D> arch.mk} (85%) copy xen/arch/x86/{Rules.mk =3D> arch.mk} (87%) diff --git a/xen/Makefile b/xen/Makefile index 8375070e0d41..372692841913 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -115,6 +115,64 @@ $(KCONFIG_CONFIG): include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG) $(MAKE) $(kconfig) syncconfig =20 +ifeq ($(CONFIG_DEBUG),y) +CFLAGS +=3D -O1 +else +CFLAGS +=3D -O2 +endif + +ifeq ($(CONFIG_FRAME_POINTER),y) +CFLAGS +=3D -fno-omit-frame-pointer +else +CFLAGS +=3D -fomit-frame-pointer +endif + +CFLAGS +=3D -nostdinc -fno-builtin -fno-common +CFLAGS +=3D -Werror -Wredundant-decls -Wno-pointer-arith +$(call cc-option-add,CFLAGS,CC,-Wvla) +CFLAGS +=3D -pipe -D__XEN__ -include $(BASEDIR)/include/xen/config.h +CFLAGS-$(CONFIG_DEBUG_INFO) +=3D -g + +ifneq ($(CONFIG_CC_IS_CLANG),y) +# Clang doesn't understand this command line argument, and doesn't appear = to +# have an suitable alternative. The resulting compiled binary does functi= on, +# but has an excessively large symbol table. +CFLAGS +=3D -Wa,--strip-local-absolute +endif + +AFLAGS +=3D -D__ASSEMBLY__ + +CFLAGS +=3D $(CFLAGS-y) +# allow extra CFLAGS externally via EXTRA_CFLAGS_XEN_CORE +CFLAGS +=3D $(EXTRA_CFLAGS_XEN_CORE) + +# Most CFLAGS are safe for assembly files: +# -std=3Dgnu{89,99} gets confused by #-prefixed end-of-line comments +# -flto makes no sense and annoys clang +AFLAGS +=3D $(filter-out -std=3Dgnu% -flto,$(CFLAGS)) $(AFLAGS-y) + +# LDFLAGS are only passed directly to $(LD) +LDFLAGS +=3D $(LDFLAGS_DIRECT) $(LDFLAGS-y) + +ifeq ($(CONFIG_UBSAN),y) +CFLAGS_UBSAN :=3D -fsanitize=3Dundefined +else +CFLAGS_UBSAN :=3D +endif + +ifeq ($(CONFIG_LTO),y) +CFLAGS +=3D -flto +LDFLAGS-$(CONFIG_CC_IS_CLANG) +=3D -plugin LLVMgold.so +endif + +include $(BASEDIR)/arch/$(TARGET_ARCH)/arch.mk + +# define new variables to avoid the ones defines in Config.mk +export XEN_CFLAGS :=3D $(CFLAGS) +export XEN_AFLAGS :=3D $(AFLAGS) +export XEN_LDFLAGS :=3D $(LDFLAGS) +export CFLAGS_UBSAN + endif # need-config =20 .PHONY: build install uninstall clean distclean MAP diff --git a/xen/Rules.mk b/xen/Rules.mk index 3408a35dbf53..0def40a00a09 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -38,59 +38,17 @@ ALL_OBJS-y +=3D $(BASEDIR)/arch/$(TARGET_= ARCH)/built_in.o ALL_OBJS-$(CONFIG_CRYPTO) +=3D $(BASEDIR)/crypto/built_in.o =20 # Initialise some variables -CFLAGS_UBSAN :=3D - -ifeq ($(CONFIG_DEBUG),y) -CFLAGS +=3D -O1 -else -CFLAGS +=3D -O2 -endif - -ifeq ($(CONFIG_FRAME_POINTER),y) -CFLAGS +=3D -fno-omit-frame-pointer -else -CFLAGS +=3D -fomit-frame-pointer -endif - -CFLAGS +=3D -nostdinc -fno-builtin -fno-common -CFLAGS +=3D -Werror -Wredundant-decls -Wno-pointer-arith -$(call cc-option-add,CFLAGS,CC,-Wvla) -CFLAGS +=3D -pipe -D__XEN__ -include $(BASEDIR)/include/xen/config.h -CFLAGS-$(CONFIG_DEBUG_INFO) +=3D -g - -ifneq ($(CONFIG_CC_IS_CLANG),y) -# Clang doesn't understand this command line argument, and doesn't appear = to -# have an suitable alternative. The resulting compiled binary does functi= on, -# but has an excessively large symbol table. -CFLAGS +=3D -Wa,--strip-local-absolute -endif - -AFLAGS +=3D -D__ASSEMBLY__ +CFLAGS-y :=3D +AFLAGS-y :=3D =20 ALL_OBJS :=3D $(ALL_OBJS-y) =20 -CFLAGS +=3D $(CFLAGS-y) -# allow extra CFLAGS externally via EXTRA_CFLAGS_XEN_CORE -CFLAGS +=3D $(EXTRA_CFLAGS_XEN_CORE) - -# Most CFLAGS are safe for assembly files: -# -std=3Dgnu{89,99} gets confused by #-prefixed end-of-line comments -# -flto makes no sense and annoys clang -AFLAGS +=3D $(filter-out -std=3Dgnu% -flto,$(CFLAGS)) - -# LDFLAGS are only passed directly to $(LD) -LDFLAGS +=3D $(LDFLAGS_DIRECT) - -LDFLAGS +=3D $(LDFLAGS-y) - SPECIAL_DATA_SECTIONS :=3D rodata $(foreach a,1 2 4 8 16, \ $(foreach w,1 2 4, \ rodata.str$(w).$(a= )) \ rodata.cst$(a)) \ $(foreach r,rel rel.ro,data.$(r).local) =20 -include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk - include Makefile =20 define gendep @@ -107,7 +65,7 @@ $(foreach o,$(filter-out %/,$(obj-y) $(obj-bin-y) $(extr= a-y)),$(eval $(call gend subdir-y :=3D $(subdir-y) $(filter %/, $(obj-y)) obj-y :=3D $(patsubst %/, %/built_in.o, $(obj-y)) =20 -$(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS +=3D -DINIT_SE= CTIONS_ONLY +$(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS-y +=3D -DINIT_= SECTIONS_ONLY =20 ifeq ($(CONFIG_COVERAGE),y) ifeq ($(CONFIG_CC_IS_CLANG),y) @@ -115,19 +73,16 @@ ifeq ($(CONFIG_CC_IS_CLANG),y) else COV_FLAGS :=3D -fprofile-arcs -ftest-coverage endif -$(filter-out %.init.o $(nocov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS= +=3D $(COV_FLAGS) +$(filter-out %.init.o $(nocov-y),$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS= -y +=3D $(COV_FLAGS) endif =20 ifeq ($(CONFIG_UBSAN),y) -CFLAGS_UBSAN +=3D -fsanitize=3Dundefined # Any -fno-sanitize=3D options need to come after any -fsanitize=3D options $(filter-out %.init.o $(noubsan-y),$(obj-y) $(obj-bin-y) $(extra-y)): \ -CFLAGS +=3D $(filter-out -fno-%,$(CFLAGS_UBSAN)) $(filter -fno-%,$(CFLAGS_= UBSAN)) +CFLAGS-y +=3D $(filter-out -fno-%,$(CFLAGS_UBSAN)) $(filter -fno-%,$(CFLAG= S_UBSAN)) endif =20 ifeq ($(CONFIG_LTO),y) -CFLAGS +=3D -flto -LDFLAGS-$(CONFIG_CC_IS_CLANG) +=3D -plugin LLVMgold.so # Would like to handle all object files as bitcode, but objects made from # pure asm are in a different format and have to be collected separately. # Mirror the directory tree, collecting them as built_in_bin.o. @@ -140,10 +95,19 @@ obj-bin-y :=3D endif =20 # Always build obj-bin files as binary even if they come from C source.=20 -$(obj-bin-y): CFLAGS :=3D $(filter-out -flto,$(CFLAGS)) +# FIXME LTO broken, but we would need a different way to filter -flto out +# $(obj-bin-y): CFLAGS :=3D $(filter-out -flto,$(CFLAGS)) + +# Calculation of flags, first the generic flags, then the arch specific fl= ags, +# and last the flags modified for a target or a directory. + +c_flags =3D -MMD -MP -MF $(@D)/.$(@F).d $(XEN_CFLAGS) '-D__OBJECT_FILE__= =3D"$@"' +a_flags =3D -MMD -MP -MF $(@D)/.$(@F).d $(XEN_AFLAGS) + +include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk =20 -c_flags =3D -MMD -MP -MF $(@D)/.$(@F).d $(CFLAGS) '-D__OBJECT_FILE__=3D"$@= "' -a_flags =3D -MMD -MP -MF $(@D)/.$(@F).d $(AFLAGS) +c_flags +=3D $(CFLAGS-y) +a_flags +=3D $(CFLAGS-y) $(AFLAGS-y) =20 built_in.o: $(obj-y) $(extra-y) ifeq ($(obj-y),) @@ -152,7 +116,7 @@ else ifeq ($(CONFIG_LTO),y) $(LD_LTO) -r -o $@ $(filter-out $(extra-y),$^) else - $(LD) $(LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^) + $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^) endif endif =20 @@ -160,7 +124,7 @@ built_in_bin.o: $(obj-bin-y) $(extra-y) ifeq ($(obj-bin-y),) $(CC) $(a_flags) -c -x assembler /dev/null -o $@ else - $(LD) $(LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^) + $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out $(extra-y),$^) endif =20 # Force execution of pattern rules (for which PHONY cannot be directly use= d). diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 913f6cdeed3f..9f1ab2335756 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -95,24 +95,24 @@ prelink_lto.o: $(ALL_OBJS) =20 # Link it with all the binary objects prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_l= to.o - $(LD) $(LDFLAGS) -r -o $@ $^ + $(LD) $(XEN_LDFLAGS) -r -o $@ $^ else prelink.o: $(ALL_OBJS) - $(LD) $(LDFLAGS) -r -o $@ $^ + $(LD) $(XEN_LDFLAGS) -r -o $@ $^ endif =20 $(TARGET)-syms: prelink.o xen.lds - $(LD) $(LDFLAGS) -T xen.lds -N prelink.o \ + $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o \ $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0 $(NM) -pa --format=3Dsysv $(@D)/.$(@F).0 \ | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).0.S $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0.o - $(LD) $(LDFLAGS) -T xen.lds -N prelink.o \ + $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o \ $(@D)/.$(@F).0.o -o $(@D)/.$(@F).1 $(NM) -pa --format=3Dsysv $(@D)/.$(@F).1 \ | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).1.S $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1.o - $(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ + $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).1.o -o $@ $(NM) -pa --format=3Dsysv $(@D)/$(@F) \ | $(BASEDIR)/tools/symbols --xensyms --sysv --sort \ diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk index 3ad284aa71a4..e69de29bb2d1 100644 --- a/xen/arch/arm/Rules.mk +++ b/xen/arch/arm/Rules.mk @@ -1,23 +0,0 @@ -######################################## -# arm-specific definitions - -# -# If you change any of these configuration options then you must -# 'make clean' before rebuilding. -# - -CFLAGS +=3D -I$(BASEDIR)/include - -$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) -$(call cc-option-add,CFLAGS,CC,-Wnested-externs) - -# Prevent floating-point variables from creeping into Xen. -CFLAGS-$(CONFIG_ARM_32) +=3D -msoft-float -CFLAGS-$(CONFIG_ARM_32) +=3D -mcpu=3Dcortex-a15 - -CFLAGS-$(CONFIG_ARM_64) +=3D -mcpu=3Dgeneric -CFLAGS-$(CONFIG_ARM_64) +=3D -mgeneral-regs-only # No fp registers etc - -ifneq ($(filter command line environment,$(origin CONFIG_EARLY_PRINTK)),) - $(error You must use 'make menuconfig' to enable/disable early printk = now) -endif diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/arch.mk similarity index 85% copy from xen/arch/arm/Rules.mk copy to xen/arch/arm/arch.mk index 3ad284aa71a4..c8186f58288d 100644 --- a/xen/arch/arm/Rules.mk +++ b/xen/arch/arm/arch.mk @@ -1,11 +1,6 @@ ######################################## # arm-specific definitions =20 -# -# If you change any of these configuration options then you must -# 'make clean' before rebuilding. -# - CFLAGS +=3D -I$(BASEDIR)/include =20 $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) diff --git a/xen/arch/arm/efi/Makefile b/xen/arch/arm/efi/Makefile index d34c9168914a..e3ff2c3f283c 100644 --- a/xen/arch/arm/efi/Makefile +++ b/xen/arch/arm/efi/Makefile @@ -1,4 +1,4 @@ -CFLAGS +=3D -fshort-wchar +CFLAGS-y +=3D -fshort-wchar =20 obj-y +=3D boot.init.o runtime.o obj-$(CONFIG_ACPI) +=3D efi-dom0.init.o diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 1405525105d9..a805e9982e85 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -121,32 +121,32 @@ prelink-efi_lto.o: $(ALL_OBJS) efi/runtime.o efi/comp= at.o =20 # Link it with all the binary objects prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_l= to.o - $(LD) $(LDFLAGS) -r -o $@ $^ + $(LD) $(XEN_LDFLAGS) -r -o $@ $^ =20 prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) preli= nk-efi_lto.o efi/boot.init.o - $(LD) $(LDFLAGS) -r -o $@ $^ + $(LD) $(XEN_LDFLAGS) -r -o $@ $^ else prelink.o: $(ALL_OBJS) - $(LD) $(LDFLAGS) -r -o $@ $^ + $(LD) $(XEN_LDFLAGS) -r -o $@ $^ =20 prelink-efi.o: $(ALL_OBJS) efi/boot.init.o efi/runtime.o efi/compat.o - $(LD) $(LDFLAGS) -r -o $@ $(filter-out %/efi/built_in.o,$^) + $(LD) $(XEN_LDFLAGS) -r -o $@ $(filter-out %/efi/built_in.o,$^) endif =20 $(TARGET)-syms: prelink.o xen.lds - $(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ + $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0 $(NM) -pa --format=3Dsysv $(@D)/.$(@F).0 \ | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort \ >$(@D)/.$(@F).0.S $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0.o - $(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ + $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).0.o -o $(@D)/.$(@F).1 $(NM) -pa --format=3Dsysv $(@D)/.$(@F).1 \ | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort $(syms-warn-dup-= y) \ >$(@D)/.$(@F).1.S $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1.o - $(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ + $(LD) $(XEN_LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ $(@D)/.$(@F).1.o -o $@ $(NM) -pa --format=3Dsysv $(@D)/$(@F) \ | $(BASEDIR)/tools/symbols --xensyms --sysv --sort \ @@ -159,7 +159,7 @@ note.o: $(TARGET)-syms --rename-section=3D.data=3D.note.gnu.build-id -S $@.bin $@ rm -f $@.bin =20 -EFI_LDFLAGS =3D $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=3D10 +EFI_LDFLAGS =3D $(patsubst -m%,-mi386pep,$(XEN_LDFLAGS)) --subsystem=3D10 EFI_LDFLAGS +=3D --image-base=3D$(1) --stack=3D0,0 --heap=3D0,0 --strip-de= bug EFI_LDFLAGS +=3D --section-alignment=3D0x200000 --file-alignment=3D0x20 EFI_LDFLAGS +=3D --major-image-version=3D$(XEN_VERSION) @@ -168,7 +168,7 @@ EFI_LDFLAGS +=3D --major-os-version=3D2 --minor-os-vers= ion=3D0 EFI_LDFLAGS +=3D --major-subsystem-version=3D2 --minor-subsystem-version= =3D0 =20 # Check if the compiler supports the MS ABI. -export XEN_BUILD_EFI :=3D $(shell $(CC) $(CFLAGS) -c efi/check.c -o efi/ch= eck.o 2>/dev/null && echo y) +export XEN_BUILD_EFI :=3D $(shell $(CC) $(XEN_CFLAGS) -c efi/check.c -o ef= i/check.o 2>/dev/null && echo y) # Check if the linker supports PE. XEN_BUILD_PE :=3D $(if $(XEN_BUILD_EFI),$(shell $(LD) -mi386pep --subsyste= m=3D10 -o efi/check.efi efi/check.o 2>/dev/null && echo y)) CFLAGS-$(XEN_BUILD_EFI) +=3D -DXEN_BUILD_EFI @@ -178,7 +178,7 @@ $(TARGET).efi: ALT_BASE =3D 0x$(shell $(NM) efi/relocs-= dummy.o | sed -n 's, A ALT_ =20 ifneq ($(build_id_linker),) ifeq ($(call ld-ver-build-id,$(LD) $(filter -m%,$(EFI_LDFLAGS))),y) -CFLAGS +=3D -DBUILD_ID_EFI +CFLAGS-y +=3D -DBUILD_ID_EFI EFI_LDFLAGS +=3D $(build_id_linker) note_file :=3D efi/buildid.o # NB: this must be the last input in the linker call, because inputs follo= wing @@ -225,7 +225,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 $@ $< =20 -asm-macros.i: CFLAGS +=3D -D__ASSEMBLY__ -P +asm-macros.i: CFLAGS-y +=3D -D__ASSEMBLY__ -P =20 $(BASEDIR)/include/asm-x86/asm-macros.h: asm-macros.i Makefile echo '#if 0' >$@.new @@ -238,7 +238,7 @@ $(BASEDIR)/include/asm-x86/asm-macros.h: asm-macros.i M= akefile echo '#endif' >>$@.new $(call move-if-changed,$@.new,$@) =20 -efi.lds: AFLAGS +=3D -DEFI +efi.lds: AFLAGS-y +=3D -DEFI xen.lds efi.lds: xen.lds.S $(CC) -P -E -Ui386 $(filter-out -Wa$(comma)%,$(a_flags)) -o $@ $< sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk index 4b7ab784670c..56fe22c979ea 100644 --- a/xen/arch/x86/Rules.mk +++ b/xen/arch/x86/Rules.mk @@ -1,89 +1,10 @@ ######################################## # x86-specific definitions =20 -XEN_IMG_OFFSET :=3D 0x200000 - -CFLAGS +=3D -I$(BASEDIR)/include -CFLAGS +=3D -I$(BASEDIR)/include/asm-x86/mach-generic -CFLAGS +=3D -I$(BASEDIR)/include/asm-x86/mach-default -CFLAGS +=3D -DXEN_IMG_OFFSET=3D$(XEN_IMG_OFFSET) -CFLAGS +=3D '-D__OBJECT_LABEL__=3D$(subst /,$$,$(subst -,_,$(subst $(BASED= IR)/,,$(CURDIR))/$@))' - -# Prevent floating-point variables from creeping into Xen. -CFLAGS +=3D -msoft-float - -ifeq ($(CONFIG_CC_IS_CLANG),y) -# Note: Any test which adds -no-integrated-as will cause subsequent tests = to -# succeed, and not trigger further additions. -# -# The tests to select whether the integrated assembler is usable need to h= appen -# before testing any assembler features, or else the result of the tests w= ould -# be stale if the integrated assembler is not used. - -# Older clang's built-in assembler doesn't understand .skip with labels: -# https://bugs.llvm.org/show_bug.cgi?id=3D27369 -$(call as-option-add,CFLAGS,CC,".L0: .L1: .skip (.L1 - .L0)",,\ - -no-integrated-as) - -# Check whether clang asm()-s support .include. -$(call as-option-add,CFLAGS,CC,".include \"asm-x86/indirect_thunk_asm.h\""= ,,\ - -no-integrated-as) - -# Check whether clang keeps .macro-s between asm()-s: -# https://bugs.llvm.org/show_bug.cgi?id=3D36110 -$(call as-option-add,CFLAGS,CC,\ - ".macro FOO;.endm"$$(close); asm volatile $$(open)".m= acro FOO;.endm",\ - -no-integrated-as) -endif - -$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) -$(call cc-option-add,CFLAGS,CC,-Wnested-externs) -$(call as-option-add,CFLAGS,CC,"vmcall",-DHAVE_AS_VMX) -$(call as-option-add,CFLAGS,CC,"crc32 %eax$$(comma)%eax",-DHAVE_AS_SSE4_2) -$(call as-option-add,CFLAGS,CC,"invept (%rax)$$(comma)%rax",-DHAVE_AS_EPT) -$(call as-option-add,CFLAGS,CC,"rdrand %eax",-DHAVE_AS_RDRAND) -$(call as-option-add,CFLAGS,CC,"rdfsbase %rax",-DHAVE_AS_FSGSBASE) -$(call as-option-add,CFLAGS,CC,"xsaveopt (%rax)",-DHAVE_AS_XSAVEOPT) -$(call as-option-add,CFLAGS,CC,"rdseed %eax",-DHAVE_AS_RDSEED) -$(call as-option-add,CFLAGS,CC,"clwb (%rax)",-DHAVE_AS_CLWB) -$(call as-option-add,CFLAGS,CC,".equ \"x\"$$(comma)1", \ - -U__OBJECT_LABEL__ -DHAVE_AS_QUOTED_SYM \ - '-D__OBJECT_LABEL__=3D$(subst $(BASEDIR)/,,$(CURDIR))= /$$@') -$(call as-option-add,CFLAGS,CC,"invpcid (%rax)$$(comma)%rax",-DHAVE_AS_INV= PCID) - -# GAS's idea of true is -1. Clang's idea is 1 -$(call as-option-add,CFLAGS,CC,\ - ".if ((1 > 0) < 0); .error \"\";.endif",,-DHAVE_AS_NEGATIVE_TRUE) - -# Check to see whether the assmbler supports the .nop directive. -$(call as-option-add,CFLAGS,CC,\ - ".L1: .L2: .nops (.L2 - .L1)$$(comma)9",-DHAVE_AS_NOPS_DIRECTIVE) - -CFLAGS +=3D -mno-red-zone -fpic -fno-asynchronous-unwind-tables - -# Xen doesn't use SSE interally. If the compiler supports it, also skip t= he -# SSE setup for variadic function calls. -CFLAGS +=3D -mno-sse $(call cc-option,$(CC),-mskip-rax-setup) - -# Compile with thunk-extern, indirect-branch-register if avaiable. -ifeq ($(CONFIG_INDIRECT_THUNK),y) -CFLAGS +=3D -mindirect-branch=3Dthunk-extern -mindirect-branch-register -CFLAGS +=3D -fno-jump-tables +ifneq ($(filter -DHAVE_AS_QUOTED_SYM,$(XEN_CFLAGS)),) +object_label_flags =3D '-D__OBJECT_LABEL__=3D$(subst $(BASEDIR)/,,$(CURDIR= ))/$@' +else +object_label_flags =3D '-D__OBJECT_LABEL__=3D$(subst /,$$,$(subst -,_,$(su= bst $(BASEDIR)/,,$(CURDIR))/$@))' endif - -# If supported by the compiler, reduce stack alignment to 8 bytes. But all= ow -# this to be overridden elsewhere. -$(call cc-option-add,CFLAGS-stack-boundary,CC,-mpreferred-stack-boundary= =3D3) -CFLAGS +=3D $(CFLAGS-stack-boundary) - -ifeq ($(CONFIG_UBSAN),y) -# Don't enable alignment sanitisation. x86 has efficient unaligned access= es, -# and various things (ACPI tables, hypercall pages, stubs, etc) are wont-f= ix. -# It also causes an as-yet-unidentified crash on native boot before the -# console starts. -$(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=3Dalignment) -endif - -# Set up the assembler include path properly for older toolchains. -CFLAGS +=3D -Wa,-I$(BASEDIR)/include - +c_flags +=3D $(object_label_flags) $(CFLAGS-stack-boundary) +a_flags +=3D $(object_label_flags) $(CFLAGS-stack-boundary) diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/arch.mk similarity index 87% copy from xen/arch/x86/Rules.mk copy to xen/arch/x86/arch.mk index 4b7ab784670c..2a51553edb3c 100644 --- a/xen/arch/x86/Rules.mk +++ b/xen/arch/x86/arch.mk @@ -1,13 +1,12 @@ ######################################## # x86-specific definitions =20 -XEN_IMG_OFFSET :=3D 0x200000 +export XEN_IMG_OFFSET :=3D 0x200000 =20 CFLAGS +=3D -I$(BASEDIR)/include CFLAGS +=3D -I$(BASEDIR)/include/asm-x86/mach-generic CFLAGS +=3D -I$(BASEDIR)/include/asm-x86/mach-default CFLAGS +=3D -DXEN_IMG_OFFSET=3D$(XEN_IMG_OFFSET) -CFLAGS +=3D '-D__OBJECT_LABEL__=3D$(subst /,$$,$(subst -,_,$(subst $(BASED= IR)/,,$(CURDIR))/$@))' =20 # Prevent floating-point variables from creeping into Xen. CFLAGS +=3D -msoft-float @@ -46,9 +45,7 @@ $(call as-option-add,CFLAGS,CC,"rdfsbase %rax",-DHAVE_AS_= FSGSBASE) $(call as-option-add,CFLAGS,CC,"xsaveopt (%rax)",-DHAVE_AS_XSAVEOPT) $(call as-option-add,CFLAGS,CC,"rdseed %eax",-DHAVE_AS_RDSEED) $(call as-option-add,CFLAGS,CC,"clwb (%rax)",-DHAVE_AS_CLWB) -$(call as-option-add,CFLAGS,CC,".equ \"x\"$$(comma)1", \ - -U__OBJECT_LABEL__ -DHAVE_AS_QUOTED_SYM \ - '-D__OBJECT_LABEL__=3D$(subst $(BASEDIR)/,,$(CURDIR))= /$$@') +$(call as-option-add,CFLAGS,CC,".equ \"x\"$$(comma)1",-DHAVE_AS_QUOTED_SYM) $(call as-option-add,CFLAGS,CC,"invpcid (%rax)$$(comma)%rax",-DHAVE_AS_INV= PCID) =20 # GAS's idea of true is -1. Clang's idea is 1 @@ -66,15 +63,14 @@ CFLAGS +=3D -mno-red-zone -fpic -fno-asynchronous-unwin= d-tables CFLAGS +=3D -mno-sse $(call cc-option,$(CC),-mskip-rax-setup) =20 # Compile with thunk-extern, indirect-branch-register if avaiable. -ifeq ($(CONFIG_INDIRECT_THUNK),y) -CFLAGS +=3D -mindirect-branch=3Dthunk-extern -mindirect-branch-register -CFLAGS +=3D -fno-jump-tables -endif +CFLAGS-$(CONFIG_INDIRECT_THUNK) +=3D -mindirect-branch=3Dthunk-extern +CFLAGS-$(CONFIG_INDIRECT_THUNK) +=3D -mindirect-branch-register +CFLAGS-$(CONFIG_INDIRECT_THUNK) +=3D -fno-jump-tables =20 # If supported by the compiler, reduce stack alignment to 8 bytes. But all= ow # this to be overridden elsewhere. $(call cc-option-add,CFLAGS-stack-boundary,CC,-mpreferred-stack-boundary= =3D3) -CFLAGS +=3D $(CFLAGS-stack-boundary) +export CFLAGS-stack-boundary =20 ifeq ($(CONFIG_UBSAN),y) # Don't enable alignment sanitisation. x86 has efficient unaligned access= es, @@ -86,4 +82,3 @@ endif =20 # Set up the assembler include path properly for older toolchains. CFLAGS +=3D -Wa,-I$(BASEDIR)/include - diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile index 4bc0a196e9ca..490d791aae2d 100644 --- a/xen/arch/x86/efi/Makefile +++ b/xen/arch/x86/efi/Makefile @@ -1,4 +1,4 @@ -CFLAGS +=3D -fshort-wchar +CFLAGS-y +=3D -fshort-wchar =20 %.o: %.ihex $(OBJCOPY) -I ihex -O binary $< $@ diff --git a/xen/common/libelf/Makefile b/xen/common/libelf/Makefile index 3d9e38f27e65..464c448d9d37 100644 --- a/xen/common/libelf/Makefile +++ b/xen/common/libelf/Makefile @@ -3,10 +3,10 @@ nocov-y +=3D libelf.o =20 SECTIONS :=3D text data $(SPECIAL_DATA_SECTIONS) =20 -CFLAGS +=3D -Wno-pointer-sign +CFLAGS-y +=3D -Wno-pointer-sign =20 libelf.o: libelf-temp.o Makefile $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=3D.init.$(s)) $= < $@ =20 libelf-temp.o: libelf-tools.o libelf-loader.o libelf-dominfo.o #libelf-rel= ocate.o - $(LD) $(LDFLAGS) -r -o $@ $^ + $(LD) $(XEN_LDFLAGS) -r -o $@ $^ diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile index c075bbf5462a..e2a5e59380a0 100644 --- a/xen/common/libfdt/Makefile +++ b/xen/common/libfdt/Makefile @@ -5,10 +5,10 @@ SECTIONS :=3D text data $(SPECIAL_DATA_SECTIONS) obj-y +=3D libfdt.o nocov-y +=3D libfdt.o =20 -CFLAGS +=3D -I$(BASEDIR)/include/xen/libfdt/ +CFLAGS-y +=3D -I$(BASEDIR)/include/xen/libfdt/ =20 libfdt.o: libfdt-temp.o Makefile $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=3D.init.$(s)) $= < $@ =20 libfdt-temp.o: $(LIBFDT_OBJS) - $(LD) $(LDFLAGS) -r -o $@ $^ + $(LD) $(XEN_LDFLAGS) -r -o $@ $^ diff --git a/xen/include/Makefile b/xen/include/Makefile index a488a98d8bb7..2a10725d689b 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -64,7 +64,7 @@ compat/%.h: compat/%.i Makefile $(BASEDIR)/tools/compat-b= uild-header.py mv -f $@.new $@ =20 compat/%.i: compat/%.c Makefile - $(CPP) $(filter-out -Wa$(comma)% -include %/include/xen/config.h,$(CFLAGS= )) $(cppflags-y) -o $@ $< + $(CPP) $(filter-out -Wa$(comma)% -include %/include/xen/config.h,$(XEN_CF= LAGS)) $(cppflags-y) -o $@ $< =20 compat/%.c: public/%.h xlat.lst Makefile $(BASEDIR)/tools/compat-build-sou= rce.py mkdir -p $(@D) diff --git a/xen/xsm/flask/Makefile b/xen/xsm/flask/Makefile index b1fd45421993..011ef5ca91f8 100644 --- a/xen/xsm/flask/Makefile +++ b/xen/xsm/flask/Makefile @@ -4,7 +4,7 @@ obj-y +=3D flask_op.o =20 obj-y +=3D ss/ =20 -CFLAGS +=3D -I./include +CFLAGS-y +=3D -I./include =20 AWK =3D awk =20 diff --git a/xen/xsm/flask/ss/Makefile b/xen/xsm/flask/ss/Makefile index 046ce8f53326..d32b9e07138e 100644 --- a/xen/xsm/flask/ss/Makefile +++ b/xen/xsm/flask/ss/Makefile @@ -8,4 +8,4 @@ obj-y +=3D services.o obj-y +=3D conditional.o obj-y +=3D mls.o =20 -CFLAGS +=3D -I../include +CFLAGS-y +=3D -I../include --=20 Anthony PERARD