From patchwork Wed Nov 29 00:00:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 10081239 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 DCA73602DC for ; Wed, 29 Nov 2017 00:13:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7559297A8 for ; Wed, 29 Nov 2017 00:13:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBAF7297AB; Wed, 29 Nov 2017 00:13:29 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4DE68297A8 for ; Wed, 29 Nov 2017 00:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wgjjDG6K/6cPrHfTMi/mNZknFSfDRfBuZTAHsptNji8=; b=UiLpNxbepEyAvAypf+lo9mOhL4 uY36ylXZZF8j7pTap9LzkyTgkUhDDy9Gcpihy+mpX/lNuGRu1LNAjpe7Phj+rYs0Huba76dcR03Gb 1A8VQYMirgis3UXgi27p5mnSeUJRyTnnekK91F9jB0Lf055Qb4k1Ep5EbvAFMib1w+tOF0cTHAZ4N tC3EmlDJEhXykl0bz05x7vSd7IcvGtCy501ZDh9Pcc2ww50PxIUoYdnYMlImoiAuepl4ErZyS2sKC cED1ns9H6UMGK6JN/Fjl+6cxkako2/yWxriyvms/+xleA8oLOLVmL0/XMBv8TXMeLCXsQnCALGbw0 FxF1Ic9Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eJq0D-0002Wg-GM; Wed, 29 Nov 2017 00:13:25 +0000 Received: from mail-io0-x241.google.com ([2607:f8b0:4001:c06::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eJpnw-0006Kn-KZ for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 00:00:46 +0000 Received: by mail-io0-x241.google.com with SMTP id d16so1837137iob.4 for ; Tue, 28 Nov 2017 16:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bZzvoLAfnVAaXjPqAoPFIq1X+vSOJpUjR17wwEnMtkI=; b=iNZWsBjPQtvNjcyuQnor+wMPbwyCTSXsUj97l0bZKJGi9Phy36wOVE7HqQv4NUXCc5 SYyzzA0K+LABqaOX+GD+Rtg8G7YgKfk27UmRl4hc9j2404lFQJQFNlMOinAr4f3dR0P+ UlpHXirg2P5jdtdla3iECtILRH7bWy9A0p72215buGeZa3JMIbsGxF+HGGihP/5j6G3+ huuPSzmsEitjFrPrLtF+U09exQbQBGm69VXgzfWpcbIiXBXDn82UKuUXLfvDSATEcCKS KzmouJcnGD1K/oCBbgbo5wIqZFSfOEARN/YzSB7NdcY264PXqstM/LiAtpEtojfUGLTv 7weA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bZzvoLAfnVAaXjPqAoPFIq1X+vSOJpUjR17wwEnMtkI=; b=CnLl4jF2qtb5qUNmj8U6hSHnQHWdL3rmUM11hplt+jNriM+Jjuhu4C7inbhncL2fd0 or54oqiN2SbO8oXnm8f1w1Dk9Q2rPtgBDC+gsMlr44xVmO5esscQqvvpubq3lIqE18W3 fIDcRkBEhwjKrUo2IbKD0Brl6SuRtIqjeeVZxUnbtOtlEfsxpHWE+GQTbfO6DbHyL99X uTHK1lIXCQQTMFjsySuLg5AO6Np9obvdsDa95WOu/EKRvw+3amkLRv0QzirC15Z314Ce c9N723TpdJUV1C/xru3+0RMhWy6EAUSqhrgaIXniqrAeikw0Ys9nDgz7T/7cCLJxqFSU aGkg== X-Gm-Message-State: AJaThX7FsFmT6ZMCryN28M9AKIpwbgqJjzmfgFNW64vYHvTVtRaTdkeQ qIzFAT8ZYBI1IAmxnFJWgi02Cw== X-Google-Smtp-Source: AGs4zMZ/0yG0WXPyMkW38k9G9XokoCjX1dbhr3xjqgqRtsaYFUOozoYONcz5xXHl7+Nz1mUo8zqe5Q== X-Received: by 10.107.135.97 with SMTP id j94mr1166881iod.213.1511913622383; Tue, 28 Nov 2017 16:00:22 -0800 (PST) Received: from samitolvanen.mtv.corp.google.com ([100.98.112.14]) by smtp.gmail.com with ESMTPSA id w68sm204836iow.18.2017.11.28.16.00.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Nov 2017 16:00:21 -0800 (PST) From: Sami Tolvanen To: Alex Matveev , Andi Kleen , Ard Biesheuvel , Greg Hackmann , Kees Cook , linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Rutland , Masahiro Yamada , Maxim Kuvyrkov , Michal Marek , Nick Desaulniers , Yury Norov , Matthias Kaehlcke Subject: [PATCH 1/3] kbuild: add clang-version.sh Date: Tue, 28 Nov 2017 16:00:09 -0800 Message-Id: <20171129000011.55235-2-samitolvanen@google.com> X-Mailer: git-send-email 2.15.0.417.g466bffb3ac-goog In-Reply-To: <20171129000011.55235-1-samitolvanen@google.com> References: <20171129000011.55235-1-samitolvanen@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171128_160044_828281_1CCAA8E3 X-CRM114-Status: GOOD ( 10.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sami Tolvanen MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Based on gcc-version.sh, clang-version.sh prints out the correct version of clang. Signed-off-by: Sami Tolvanen Tested-by: Nick Desaulniers --- scripts/clang-version.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 scripts/clang-version.sh diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh new file mode 100755 index 000000000000..5f14ddc54032 --- /dev/null +++ b/scripts/clang-version.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# clang-version [-p] clang-command +# +# Prints the compiler version of `command' in a canonical 4-digit form +# such as `0500' for clang-5.0 etc. +# +# With the -p option, prints the patchlevel as well, for example `050001' for +# 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" + 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