Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2141383imm; Mon, 28 May 2018 02:27:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL0NdW+8f/bKqLtBoARMgnsYXwiy0kQ8zp2UApDYT2EgT78e354L33mfn8i0tZzGlA2+94s X-Received: by 2002:a17:902:7c16:: with SMTP id x22-v6mr6827245pll.77.1527499636966; Mon, 28 May 2018 02:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527499636; cv=none; d=google.com; s=arc-20160816; b=dSUA0qwFNwE3vAK6bpxmW2tGnn+taM/70Yjq/ygB99JKDe0Ki8ibL0RdgpdhNRKxgH PLOT0/hGDn6vj53Pwk/k6C447gS8CAIRq5J5sA/gP6oGh8J2H2fz/0Uogot6doUrrcWJ vhlu1fsn5bQY1vq5I0UdMeq2lVDboqUasvN5Gt66u5UPKGN4VO89lRM5IvpIxx+HW+Fh ZH5xI3Y8a6QYeNcGGIab6MhP1XSe7s884zHQKMdaeGGefuisPkQJODZbCNOvbqudbh48 PyRpvurw8z4lPIr+uFi/3LtrdktEm7fODZEQbsaredTAuEULZkHgjcRz6vqUf5cyfO64 N7gw== 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=0mlkdVUrNIHStmyOwsbiABMg5JGMCZKqWBfmaYib8q0=; b=PaxU8JaruiAN+M0Q4iFmwEomzN7Q9bnCNPJPymHoX7RZAhEr7sJflmASkn+vjgpO3f yqRu3vHUMUB52FYFp4JqqQlccG+5Crn1lDVOr6uJkLQbDkQ7i65Bxlp1EZq6B10NuSVU fGjNAbRmVDmGATCWY1YMz/h/C2RoHfpOeONv2ZDdjR9PghcjAE7NWjyCRixqgDWp2zVL Krpawsi2aDaihsZbGWwL7WqsboKdT8D/OWs5JuIdaxxf4LWnVLZvt00Uwk60wazz1vw7 jIBWZvHJEZyzMVprgc7PzJoK6sm4fBDhJQqFKfFytjwYje6rg6zd9Rhd0YEzk9Yt1bsm tQsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=nEO65nls; 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 f4-v6si23261643pgs.16.2018.05.28.02.27.02; Mon, 28 May 2018 02:27:16 -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=nEO65nls; 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 S933633AbeE1JZH (ORCPT + 99 others); Mon, 28 May 2018 05:25:07 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:22951 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933272AbeE1JZC (ORCPT ); Mon, 28 May 2018 05:25:02 -0400 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-10.nifty.com with ESMTP id w4S9MIng027506; Mon, 28 May 2018 18:22:39 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w4S9MIng027506 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1527499360; bh=0mlkdVUrNIHStmyOwsbiABMg5JGMCZKqWBfmaYib8q0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nEO65nlsqqxKr4ao159eu9E23yYDfGNST1WYTGCVN+VqGP6u7zXICdnx9ZUWK7n3h ULuZiIMzKDlnWDr5MnvuXPVZxVi6UjFlsaOouz0jZg6VLXgtuZ9EXBcqSVezbiSTJj agLt0IBQq4OMyf95Ro2V23t5RuBazNilbjobUL7iphSJMms+jP3pGi8kPBq/JFZ7cG h77W8/MkXn3dH+yZ7tHwrSZcfolb/n4+9FnehazHuHej0JD1KnNhqXRRlTuwPzIKAu tNSR8G6yHIKzzG7k2J9uSLW1n0yWO6fZf+QiVXZRNbzq4oO6xyr0AY3/l7zgfAm8RF 7+eiH57CoOzKQ== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Kees Cook , Nicholas Piggin , "Luis R . Rodriguez" , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Linus Torvalds , Masahiro Yamada Subject: [PATCH v5 25/31] kconfig: add CC_IS_CLANG and CLANG_VERSION Date: Mon, 28 May 2018 18:22:02 +0900 Message-Id: <1527499328-13213-26-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527499328-13213-1-git-send-email-yamada.masahiro@socionext.com> References: <1527499328-13213-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 Reviewed-by: Kees Cook --- Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None init/Kconfig | 7 +++++++ scripts/clang-version.sh | 18 ++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 2e33d93..22e095d 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -16,6 +16,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..dbf0a31 100755 --- a/scripts/clang-version.sh +++ b/scripts/clang-version.sh @@ -10,24 +10,14 @@ # 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" +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) -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 -- 2.7.4