From nobody Mon Apr 29 16:30:15 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; 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=1590767075; cv=none; d=zohomail.com; s=zohoarc; b=ZDGFvUpTgjg0gowzdZee4PXZ/iiMGw0cOj2ZGVe5f027Nqs2p7wD48G10+0AXhIi5pYXF88cZVUOG5xI13kFlMlXBn+ukILmQRVfltp5mjgaJC7qDudsRWFEs6wHbr50wkJtwbcwWY5Jqr4PkJ8J1D5hfCs0/teC2RT+JHMkwzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590767075; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=9uNfJQhOqUamZ8Kc9pIyQWQzfksVU4GT+fzA55YLSx4=; b=J2yPCD+ZdxS111iiPVOVnt1XM+mDKN3Ry/u3XCWnxQeORp++XlX4MsweWrQNyb6ai7/7mDnD1Kzpc641codRspZVza6uSn8BCczIvM86035AQ4aUOEj2ooVr+vsg/j4rvkUui5oxxvUNQHmzaKsRkJWf+ML4vDhEuiL3Jsj77S0= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1590767075003841.8706934486374; Fri, 29 May 2020 08:44:35 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jehBC-0000Sk-LP; Fri, 29 May 2020 15:44:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jehBB-0000SB-25 for xen-devel@lists.xenproject.org; Fri, 29 May 2020 15:44:17 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 40391566-a1c3-11ea-81bc-bc764e2007e4; Fri, 29 May 2020 15:44:16 +0000 (UTC) X-Inumbo-ID: 40391566-a1c3-11ea-81bc-bc764e2007e4 Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: ONeqteup3dw6Lh+z7jrKEbgJlIGDTIAlGo2dQNpr7TcYtTUojg5zTrQwssXp7yTfM4ySGg2kHA mQgz2TfSfCiwoyClkyLr+re1BT+Nh4KUpGErp6z3FA2eOgGuQn4Ax1HjzILlfKuNsVi97p7S+D 9bE5ffjwgsHfXnFdbtnJJ5gVSi8Ldcfo4oaVKY9YlAjZvvUK8/io0jYhZ3zCS9J4JD2CZopgBl MbZiWfLrLafq1rm23E+/5gvbnGZX0xk85wRr47uHOv6Vj+gGc9qoWmTVwZZ1AsIZl5yt08ewB4 +dA= X-SBRS: 2.7 X-MesageID: 19024984 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,449,1583211600"; d="scan'208";a="19024984" From: Anthony PERARD To: Subject: [XEN PATCH] xen/build: introduce CLANG_FLAGS for testing other CFLAGS Date: Fri, 29 May 2020 16:43:43 +0100 Message-ID: <20200529154343.1616925-1-anthony.perard@citrix.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 , Jan Beulich , Anthony PERARD , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Type: text/plain; charset="utf-8" Commit 534519f0514f ("xen: Have Kconfig check $(CC)'s version") introduced the use of CLANG_FLAGS in Kconfig which is used when testing for other CFLAGS via $(cc-option ...) but CLANG_FLAGS doesn't exist in the Xen build system. (It's a Linux/Kbuild variable that haven't been added yet.) The missing CLANG_FLAGS isn't an issue for $(cc-option ..) but it would be when $(as-instr ..) gets imported from Kbuild to tests assembly instruction. We need to know if we are going to use clang's assembler or not. CLANG_FLAGS needs to be calculated before we call Kconfig. So, this patch adds CLANG_FLAGS which may contain two flags which are needed for further testing of $(CC)'s capabilities: -no-integrated-as This flags isn't new, but simply tested earlier so that it can be used in Kconfig. The flags is only added for x86 builds like before. -Werror=3Dunknown-warning-option The one is new and is to make sure that the warning is enabled, even though it is by default but could be disabled in a particular build of clang, see Linux's commit e8de12fb7cde ("kbuild: Check for unknown options with cc-option usage in Kconfig and clang") It is present in clang 3.0.0, according Linux's commit 589834b3a009 ("kbuild: Add -Werror=3Dunknown-warning-option to CLANG_FLAGS"). (The "note" that say that the flags was only added once wasn't true when tested on CentOS 6, so the patch uses $(or) and the flag will only be added once.) Fixes: 534519f0514f ("xen: Have Kconfig check $(CC)'s version") Signed-off-by: Anthony PERARD Acked-by: Andrew Cooper --- xen/Makefile | 31 +++++++++++++++++++++++++++++-- xen/arch/x86/arch.mk | 24 ------------------------ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/xen/Makefile b/xen/Makefile index 30c3568a4791..2e897f222cc9 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -48,6 +48,7 @@ default: build .PHONY: dist dist: install =20 +include scripts/Kbuild.include =20 ifneq ($(root-make-done),y) # section to run before calling Rules.mk, but only once. @@ -124,11 +125,37 @@ ifneq ($(filter %config,$(MAKECMDGOALS)),) config-build :=3D y endif =20 +# CLANG_FLAGS needs to be calculated before calling Kconfig +ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) +CLANG_FLAGS :=3D + +ifeq ($(TARGET_ARCH),x86) +# 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 +t1 =3D $(call as-insn,$(CC),".L0: .L1: .skip (.L1 - .L0)",,-no-integrated-= as) + +# Check whether clang asm()-s support .include. +t2 =3D $(call as-insn,$(CC) -I$(BASEDIR)/include,".include \"asm-x86/indir= ect_thunk_asm.h\"",,-no-integrated-as) + +# Check whether clang keeps .macro-s between asm()-s: +# https://bugs.llvm.org/show_bug.cgi?id=3D36110 +t3 =3D $(call as-insn,$(CC),".macro FOO;.endm"$(close); asm volatile $(ope= n)".macro FOO;.endm",-no-integrated-as) + +CLANG_FLAGS +=3D $(call or,$(t1),$(t2),$(t3)) +endif + +CLANG_FLAGS +=3D -Werror=3Dunknown-warning-option +CFLAGS +=3D $(CLANG_FLAGS) +export CLANG_FLAGS +endif + export root-make-done :=3D y endif # root-make-done =20 -include scripts/Kbuild.include - # Shorthand for kconfig kconfig =3D -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=3D$(ARCH) SR= CARCH=3D$(SRCARCH) HOSTCC=3D"$(HOSTCC)" HOSTCXX=3D"$(HOSTCXX)" =20 diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk index 62b7c9700776..1f7211623399 100644 --- a/xen/arch/x86/arch.mk +++ b/xen/arch/x86/arch.mk @@ -11,30 +11,6 @@ CFLAGS +=3D -DXEN_IMG_OFFSET=3D$(XEN_IMG_OFFSET) # Prevent floating-point variables from creeping into Xen. CFLAGS +=3D -msoft-float =20 -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) --=20 Anthony PERARD