From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DC83C54FCB for ; Thu, 23 Apr 2020 16:40:56 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D94AA20728 for ; Thu, 23 Apr 2020 16:40:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D94AA20728 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jRety-0002eC-Pi; Thu, 23 Apr 2020 16:40:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jRetx-0002e7-JL for xen-devel@lists.xenproject.org; Thu, 23 Apr 2020 16:40:37 +0000 X-Inumbo-ID: 283b293a-8581-11ea-b4f4-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 283b293a-8581-11ea-b4f4-bc764e2007e4; Thu, 23 Apr 2020 16:40:36 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 72811ADB5; Thu, 23 Apr 2020 16:40:34 +0000 (UTC) Subject: Re: [XEN PATCH v5 04/16] xen/build: have the root Makefile generates the CFLAGS To: Anthony PERARD References: <20200421161208.2429539-1-anthony.perard@citrix.com> <20200421161208.2429539-5-anthony.perard@citrix.com> From: Jan Beulich Message-ID: <28aeea6d-cd52-d8bf-f114-96ec435363c6@suse.com> Date: Thu, 23 Apr 2020 18:40:33 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200421161208.2429539-5-anthony.perard@citrix.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 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 , xen-devel@lists.xenproject.org, Daniel De Graaf , Volodymyr Babchuk , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 21.04.2020 18:11, Anthony PERARD wrote: > 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(). > > The LTO change hasn't been tested properly, as LTO is marked as > broken. > > Signed-off-by: Anthony PERARD Reviewed-by: Jan Beulich with one further question: > --- a/xen/arch/x86/Rules.mk > +++ b/xen/arch/x86/Rules.mk > @@ -1,89 +1,10 @@ > ######################################## > # x86-specific definitions > > -XEN_IMG_OFFSET := 0x200000 > - > -CFLAGS += -I$(BASEDIR)/include > -CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic > -CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default > -CFLAGS += -DXEN_IMG_OFFSET=$(XEN_IMG_OFFSET) > -CFLAGS += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))' > - > -# Prevent floating-point variables from creeping into Xen. > -CFLAGS += -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 happen > -# before testing any assembler features, or else the result of the tests would > -# 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=27369 > -$(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=36110 > -$(call as-option-add,CFLAGS,CC,\ > - ".macro FOO;.endm"$$(close); asm volatile $$(open)".macro 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__=$(subst $(BASEDIR)/,,$(CURDIR))/$$@') > -$(call as-option-add,CFLAGS,CC,"invpcid (%rax)$$(comma)%rax",-DHAVE_AS_INVPCID) > - > -# 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 += -mno-red-zone -fpic -fno-asynchronous-unwind-tables > - > -# Xen doesn't use SSE interally. If the compiler supports it, also skip the > -# SSE setup for variadic function calls. > -CFLAGS += -mno-sse $(call cc-option,$(CC),-mskip-rax-setup) > - > -# Compile with thunk-extern, indirect-branch-register if avaiable. > -ifeq ($(CONFIG_INDIRECT_THUNK),y) > -CFLAGS += -mindirect-branch=thunk-extern -mindirect-branch-register > -CFLAGS += -fno-jump-tables > +ifneq ($(filter -DHAVE_AS_QUOTED_SYM,$(XEN_CFLAGS)),) > +object_label_flags = '-D__OBJECT_LABEL__=$(subst $(BASEDIR)/,,$(CURDIR))/$@' > +else > +object_label_flags = '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))' > endif > - > -# If supported by the compiler, reduce stack alignment to 8 bytes. But allow > -# this to be overridden elsewhere. > -$(call cc-option-add,CFLAGS-stack-boundary,CC,-mpreferred-stack-boundary=3) > -CFLAGS += $(CFLAGS-stack-boundary) > - > -ifeq ($(CONFIG_UBSAN),y) > -# Don't enable alignment sanitisation. x86 has efficient unaligned accesses, > -# and various things (ACPI tables, hypercall pages, stubs, etc) are wont-fix. > -# It also causes an as-yet-unidentified crash on native boot before the > -# console starts. > -$(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=alignment) > -endif > - > -# Set up the assembler include path properly for older toolchains. > -CFLAGS += -Wa,-I$(BASEDIR)/include > - > +c_flags += $(object_label_flags) $(CFLAGS-stack-boundary) > +a_flags += $(object_label_flags) $(CFLAGS-stack-boundary) Why are you also adding these to a_flags? It probably doesn't hurt, but I'd prefer if it was removed (could be done while committing if all acks arrive and other other need for av6 arises) if there's no clear need. Jan