From patchwork Thu Dec 12 18:27:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11289053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 342F0109A for ; Thu, 12 Dec 2019 18:29:02 +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 107752253D for ; Thu, 12 Dec 2019 18:29:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="UPCrtKj4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 107752253D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none 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.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 X-Inumbo-ID: 17319782-1d0d-11ea-b6f1-bc764e2007e4 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) 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 (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 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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" +source "scripts/Kconfig.include" + config BROKEN bool +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" 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)))) +export CC LD kconfig := 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 := , +quote := " +squote := ' +empty := +space := $(empty) $(empty) +dollar := $ +right_paren := ) +left_paren := ( + +# $(if-success,,,) +# Return if exits with 0, otherwise. +if-success = $(shell,{ $(1); } >/dev/null 2>&1 && echo "$(2)" || echo "$(3)") + +# $(success,) +# Return y if exits with 0, n otherwise +success = $(if-success,$(1),y,n) + +# $(failure,) +# Return n if exits with 0, y otherwise +failure = $(if-success,$(1),n,y) + +# $(cc-option,) +# Return y if the compiler supports , n otherwise +cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/null -o /dev/null) + +# $(ld-option,) +# Return y if the linker supports , n otherwise +ld-option = $(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 := $(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="$*" + +if ! ( $compiler --version | grep -q clang) ; then + echo 0 + exit 1 +fi + +MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) +MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) +PATCHLEVEL=$(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="$*" + +if [ ${#compiler} -eq 0 ]; then + echo "Error: No compiler specified." >&2 + printf "Usage:\n\t$0 \n" >&2 + exit 1 +fi + +MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1) +MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1) +PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL