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: 10309275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE90E60212 for ; Tue, 27 Mar 2018 05:34:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC1D429ADE for ; Tue, 27 Mar 2018 05:34:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD4D229AE0; Tue, 27 Mar 2018 05:34:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41A0F29ADE for ; Tue, 27 Mar 2018 05:34:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752507AbeC0FeE (ORCPT ); Tue, 27 Mar 2018 01:34:04 -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-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This will be useful to describe the clang version dependency. Signed-off-by: Masahiro Yamada Reviewed-by: Kees Cook --- Changes in v2: None init/Kconfig | 7 +++++++ scripts/clang-version.sh | 24 +++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) 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