From patchwork Tue Mar 27 05:29:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 132447 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp4654791ljb; Mon, 26 Mar 2018 22:34:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ZQO+4cSBlAgNSdxGUV0fp8kJsH5xwtsBJYX1qzhH23SpF/bSdRrcPJOReECIK8RRRpQpz X-Received: by 2002:a17:902:6b8b:: with SMTP id p11-v6mr6806189plk.213.1522128852068; Mon, 26 Mar 2018 22:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522128852; cv=none; d=google.com; s=arc-20160816; b=qWEOx/jE2LnEnEmHpC3DPSdX1kCDU0DaRZyJatw4qW6z6NyGasI5h86UnXDeE/OhjI 9GmLN/c2EA+FeDuniEnt013zTbcwkFXP/hFg1V+S3+x/mB3JOxFHsOTUYzaQfsur0bya CyQ2HY9dCM5cse5zbskyvYDUzmW1qyMhW1jWEbeIPi2cgI9XAf2TKlnYlkpKudWPZfTc mCaXJGRubk+m0dtiO/xzIt9Sse+KCZ4VNAaiis7QO1irrNYrPiEGPGWPy5CCO+RzeFyZ RKLHumo1PvKsU8HJP2wXE79Oa72+Y9BIGrZH750YR6gX7brx4VcguNIrSYOGPC/O89C/ uzyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=RYqC1QRkceoAm9+CHevbEu7OH/qqF2FDZaEeQkX7ooA=; b=t2IPAViFE8WMbE7Atbe9vk3MQcvFxl+ugdKkQ9McImxHNOPsSZcCBdOp+4tEzdpoph mMptFdfHPlEXYogcAWhVuCd/4KNp72hVKx+wksLFkWirYH6X6oo/1/fGjqThiGGrpvP+ xGxGR4fyYMOVVp37QAq7mlhGIuuS/NzwSj57weCpoIOBmU2wMTF35RLjtozQoSaxcx/z f1eO9YLV5AeGZYrHws2Ru5oZ4FwWPAFpnJHnB8UWNiMowvA+U2B7rV5CFQ9hX4/7n/Pb ad7Eng+Xkl998DqNB1sxVbdJNZh2UOyO8iHHUtdPFMFBP22nB7G2Ez9v+F3lMVlf3t2i bgeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=qfBbq9xZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1-v6si533308pld.130.2018.03.26.22.34.11; Mon, 26 Mar 2018 22:34:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=qfBbq9xZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752555AbeC0FeH (ORCPT + 28 others); Tue, 27 Mar 2018 01:34:07 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:44827 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751185AbeC0FcF (ORCPT ); Tue, 27 Mar 2018 01:32:05 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id w2R5TaLx011947; Tue, 27 Mar 2018 14:29:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com w2R5TaLx011947 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1522128595; bh=RYqC1QRkceoAm9+CHevbEu7OH/qqF2FDZaEeQkX7ooA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qfBbq9xZpkLZktyLSn3fl0c8ncv5jNBx9GT/3WR0oVyI4PbQC84NrVxEG915JvER/ tu9k2lx4WJXlHRaz5YabEVxvl5jgoSF7p291eZK/pLuMWPi/Sjyi/cRBDXUxAcS0MN vwZb39ejcMb1sbZ5+c6AdLmo05v78/AyA/Sbe062qbk6eDu4r/mdnSvdkPzf7QC1+Y T5kGReS/Y3pfNB0Al1dRIIpXvOa7Fruxpkemvc/Ik7SAkzSmRiBxzhcPqAgvCPE3dP PVBRs+7nJaKinEXumLzSE0WO8jbXKG4jbRA1wkZGJW7mPOkaLQ5TqvuT/D+lpUfrWa OvR6N2UnjWtkQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Linus Torvalds , Arnd Bergmann , Ulf Magnusson , Kees Cook , Thomas Gleixner , Greg Kroah-Hartman , Randy Dunlap , "Luis R . Rodriguez" , Nicolas Pitre , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 14/21] kconfig: add CC_IS_CLANG and CLANG_VERSION Date: Tue, 27 Mar 2018 14:29:28 +0900 Message-Id: <1522128575-5326-15-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522128575-5326-1-git-send-email-yamada.masahiro@socionext.com> References: <1522128575-5326-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will be useful to describe the clang version dependency. Signed-off-by: Masahiro Yamada --- Changes in v2: None init/Kconfig | 7 +++++++ scripts/clang-version.sh | 24 +++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) -- 2.7.4 Reviewed-by: Kees Cook diff --git a/init/Kconfig b/init/Kconfig index 923cab5..5998034 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -22,6 +22,13 @@ config GCC_VERSION default $(shell $srctree/scripts/gcc-version.sh -p $CC | sed 's/^0*//') if CC_IS_GCC default 0 +config CC_IS_CLANG + def_bool $(success $CC --version | grep -q clang) + +config CLANG_VERSION + int + default $(shell $srctree/scripts/clang-version.sh $CC) + config CONSTRUCTORS bool depends on !UML diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh index 9780efa..d8002d2 100755 --- a/scripts/clang-version.sh +++ b/scripts/clang-version.sh @@ -10,24 +10,22 @@ # clang-5.0.1 etc. # -if [ "$1" = "-p" ] ; then - with_patchlevel=1; - shift; -fi - compiler="$*" if [ ${#compiler} -eq 0 ]; then - echo "Error: No compiler specified." - printf "Usage:\n\t$0 \n" + echo "Error: No compiler specified." >&2 + printf "Usage:\n\t$0 \n" >&2 + echo 0 + exit 1 +fi + +if !( $compiler --version | grep -q clang) ; then + echo "This is not clang." >&2 + 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) -if [ "x$with_patchlevel" != "x" ] ; then - PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) - printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL -else - printf "%02d%02d\\n" $MAJOR $MINOR -fi +PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL