From nobody Mon Feb 9 16:02:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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=1576175319; cv=none; d=zohomail.com; s=zohoarc; b=CQeT38+RKJjCC9JQtclgPZQuZo75jDPwGquvgiiLcUak7JBc3eOMr17XQSPTR92BRb7dQ7ZdVJrFRbKdEGgR0Ukh+BWeMi6IkXo9j1UoMKwKt4aUMSY6VLceOzVxpI2A2MACpsD/syjd1j687nslFQzXQhHsywMDptoi1S+jGfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576175319; 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=HvvFApwsOnuebkZcY7nIWd8E7fjlB/NH23iiqdOlCis=; b=Oo3I/UaH8XSv3mHq4lMB6j21ORc6R0wq2y7TgcqFxmtzUuh3rTLuT4TTdWppmL/zIMYSJlvlfPXSzEvhT8/27s7ZFTUXsxpvpvWmgTu8iST4b6OkcPpozcj5Zdc88nC04/gpeX4e6rSA1MV1Eva06hpzcOT25pdIXbiLCf4uGjE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1576175319010544.2534891728168; Thu, 12 Dec 2019 10:28:39 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifTBr-0007BN-Sn; Thu, 12 Dec 2019 18:27:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifTBq-0007BE-Kr for xen-devel@lists.xenproject.org; Thu, 12 Dec 2019 18:27:54 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 17319782-1d0d-11ea-b6f1-bc764e2007e4; Thu, 12 Dec 2019 18:27:45 +0000 (UTC) X-Inumbo-ID: 17319782-1d0d-11ea-b6f1-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1576175265; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=t9l+/Rr/KBGv1lyV9eKOdV0kQZ3zp2qzFnwYEbAKgUU=; b=UPCrtKj4ipsePhM89LdW1BhZdC/HZqU3UP5BlWS/wA2M5OsFl6wwauCV X7xehL50XdxBpxcVeC2MqrGjRVzfUI9xR8Jki5BZPiIlFiXKR1+pX/TQv 6gtRR039MDxvqez9UsCQQBDlOEP9qhFzvPa+tWbxZaObQDXTb3YEhdEkp 0=; Authentication-Results: esa6.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: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: PQrzsUT1Cfj9SxcPNUlWzotRe8Mef+gZvxGH6T1fM0kNoh15jC+FxCoX+h7jUlGNwPy2QoS6Vo iIgMZvYyyCBCqpBq7G3gksVEP7MmMXbhjxE5UDze4wStTEiYyBVoTGWRRAQ7IsNyCxvZChTXmO qDK7NMD9QSJARhZGt+8YibulE7ZNc7QIKThw9bXXWBm8ocaHAQlf8P5OcMwg+Dw/xs0w7i0fhk kvqCXVBw8FOh6f11s0TiZS7ov/oMC8WWdozx/AlmKT9BEs5U1StzaS8VSibdCwbdZ0A5pamiCh ocY= X-SBRS: 2.7 X-MesageID: 10021228 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,306,1571716800"; d="scan'208";a="10021228" From: Anthony PERARD To: Date: Thu, 12 Dec 2019 18:27:36 +0000 Message-ID: <20191212182740.2190199-5-anthony.perard@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191212182740.2190199-1-anthony.perard@citrix.com> References: <20191212182740.2190199-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH 4/8] xen: Have Kconfig check $(CC)'s version 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 , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich , Anthony PERARD Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This import several files from Linux v5.3 - scripts/Kconfig.include - scripts/clang-version.sh - scripts/gcc-version.sh and several config values from from Linux's init/Kconfig file. Files are copied into scripts/ directory because that's were the files are found in Linux tree, and also because we are going to import more of Kbuild from Linux which is located in scripts/. CONFIG_GCC_VERSION and CONFIG_CC_IS_CLANG are going to be use in follow-up patches. Signed-off-by: Anthony PERARD --- xen/Kconfig | 17 ++++++++++++++++ xen/Makefile | 1 + xen/scripts/Kconfig.include | 39 ++++++++++++++++++++++++++++++++++++ xen/scripts/clang-version.sh | 19 ++++++++++++++++++ xen/scripts/gcc-version.sh | 20 ++++++++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 xen/scripts/Kconfig.include create mode 100755 xen/scripts/clang-version.sh create mode 100755 xen/scripts/gcc-version.sh diff --git a/xen/Kconfig b/xen/Kconfig index 01067326b4e7..9f6512d65b08 100644 --- a/xen/Kconfig +++ b/xen/Kconfig @@ -4,9 +4,26 @@ # mainmenu "Xen/$(SRCARCH) $(XEN_FULLVERSION) Configuration" =20 +source "scripts/Kconfig.include" + config BROKEN bool =20 +config CC_IS_GCC + def_bool $(success,$(CC) --version | head -n 1 | grep -q gcc) + +config GCC_VERSION + int + default $(shell,$(BASEDIR)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC + default 0 + +config CC_IS_CLANG + def_bool $(success,$(CC) --version | head -n 1 | grep -q clang) + +config CLANG_VERSION + int + default $(shell,$(BASEDIR)/scripts/clang-version.sh $(CC)) + source "arch/$(SRCARCH)/Kconfig" =20 config DEFCONFIG_LIST diff --git a/xen/Makefile b/xen/Makefile index efbe9605e52b..0cf4ded9d9d4 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -267,6 +267,7 @@ $(foreach base,arch/x86/mm/guest_walk_% \ arch/x86/mm/shadow/guest_%, \ $(foreach ext,o i s,$(call build-intermediate,$(base).$(ext)))) =20 +export CC LD kconfig :=3D oldconfig config menuconfig defconfig \ nconfig xconfig gconfig savedefconfig listnewconfig olddefconfig \ randconfig $(notdir $(wildcard arch/$(SRCARCH)/configs/*_defconfig)) diff --git a/xen/scripts/Kconfig.include b/xen/scripts/Kconfig.include new file mode 100644 index 000000000000..8221095ca34b --- /dev/null +++ b/xen/scripts/Kconfig.include @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Kconfig helper macros + +# Convenient variables +comma :=3D , +quote :=3D " +squote :=3D ' +empty :=3D +space :=3D $(empty) $(empty) +dollar :=3D $ +right_paren :=3D ) +left_paren :=3D ( + +# $(if-success,,,) +# Return if exits with 0, otherwise. +if-success =3D $(shell,{ $(1); } >/dev/null 2>&1 && echo "$(2)" || echo "$= (3)") + +# $(success,) +# Return y if exits with 0, n otherwise +success =3D $(if-success,$(1),y,n) + +# $(failure,) +# Return n if exits with 0, y otherwise +failure =3D $(if-success,$(1),n,y) + +# $(cc-option,) +# Return y if the compiler supports , n otherwise +cc-option =3D $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/nul= l -o /dev/null) + +# $(ld-option,) +# Return y if the linker supports , n otherwise +ld-option =3D $(success,$(LD) -v $(1)) + +# check if $(CC) and $(LD) exist +$(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found) +$(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found) + +# gcc version including patch level +gcc-version :=3D $(shell,$(BASEDIR)/scripts/gcc-version.sh $(CC)) diff --git a/xen/scripts/clang-version.sh b/xen/scripts/clang-version.sh new file mode 100755 index 000000000000..6fabf0695761 --- /dev/null +++ b/xen/scripts/clang-version.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# clang-version clang-command +# +# Print the compiler version of `clang-command' in a 5 or 6-digit form +# such as `50001' for clang-5.0.1 etc. + +compiler=3D"$*" + +if ! ( $compiler --version | grep -q clang) ; then + echo 0 + exit 1 +fi + +MAJOR=3D$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) +MINOR=3D$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) +PATCHLEVEL=3D$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL diff --git a/xen/scripts/gcc-version.sh b/xen/scripts/gcc-version.sh new file mode 100755 index 000000000000..ae353432539b --- /dev/null +++ b/xen/scripts/gcc-version.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# gcc-version gcc-command +# +# Print the gcc version of `gcc-command' in a 5 or 6-digit form +# such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc. + +compiler=3D"$*" + +if [ ${#compiler} -eq 0 ]; then + echo "Error: No compiler specified." >&2 + printf "Usage:\n\t$0 \n" >&2 + exit 1 +fi + +MAJOR=3D$(echo __GNUC__ | $compiler -E -x c - | tail -n 1) +MINOR=3D$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1) +PATCHLEVEL=3D$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL --=20 Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel