From patchwork Thu Nov 30 23:38:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 10085771 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 BB1C4602BC for ; Thu, 30 Nov 2017 23:39:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC2F22A2DC for ; Thu, 30 Nov 2017 23:39:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0D1D2A41F; Thu, 30 Nov 2017 23:39:03 +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 6BBBC2A41E for ; Thu, 30 Nov 2017 23:39:01 +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=XTjslSJz0+waPv9Ws0cMlHfHkToOB/t0a9yV97XnWR8=; b=tF/gMZXq9IZwlvieKs15eeZtrb kQK1QYxBUeU31dViL4XtLL3XtuMzPJ5QIAvpkJsHyleEnF+zrqc95nNIz0vVTMELDbUu6ZLRFxRBd J0uMWgLhako+Aj1dTrMxgCy98uRwh7x/KwmOqDIVY3VtTtkiq2gd1ytbJnliCiFk4ZD38PqBZC2RH 17z4qsNmXKwCohLRkANi/dosgVMJ2awLigx3oK4EqsAR/pZlDQJGmaKALDvAYeX1dTX0lOEhSlnpu f/rO88Bf4I3GLCbBp5HurZEXR4ujuvl2OtMcJWyMQ3aB24IORkJZwDlGgaIO21+xjJiCID3DpwC/p 0zv9Yk/Q==; 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 1eKYPz-0000nq-6u; Thu, 30 Nov 2017 23:38:59 +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 1eKYPv-0000ag-Bl for linux-arm-kernel@lists.infradead.org; Thu, 30 Nov 2017 23:38:57 +0000 Received: by mail-io0-x241.google.com with SMTP id d16so9415740iob.4 for ; Thu, 30 Nov 2017 15:38:36 -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=Rt9bZ4SxsZn6iY9F5PkW0PO8ROaIDRa0XO1z6ejeEGc=; b=L4q+H34BQ17csoiVo/0zuP0lYRiEljaMU7GaVYGeaMkcZGmyZbGIeR5KAABbyV5Ubt ISsKoP3IjmayDDcB5Qz8NVBPGVQAGuMCAA7gTs3KpZAkR9KZ2m0YR1KTLQ7leU6+pu4x e0opbHewwT+Q4+dFCRkwHzf7uDsldZh/v0mMyuvEvzQFmzjLgrzMepkkqcNINdD0z+55 lXFSLjxfaNEcNs2amjX3T0wqr99QuDUf1Yick2MMtDk/BFLpNwH0v0yuDnbssmroupAl 29VmB7uPwGPO93HRY0eG5a3Yx4tELH+Rkg1ocJfMaUlzD4Xgz94WLI3mSOc6zjTtyA4x 5BLw== 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=Rt9bZ4SxsZn6iY9F5PkW0PO8ROaIDRa0XO1z6ejeEGc=; b=gEbxufUAyxRKLK21O+32+B2zGoNM0oFTrkLwikkfT91ZK1miEya86y9FcMMMEFrVyR +YH1Yy/Nk1DECwUrv6o5TxL9kBUUknBgYMwotFxEJUyH0DvDFAVTtW9o2pU54SYoUgiW Ru74MUDe7dqKhD+DVcIq8e+IXnEoSB5Fjv1hBha/MDB38d8SqdFri+7lPf9/ROagMKpY 5jjxp5KnKDAg/N5Vj0CpUlimAkDKblm2Grn7KE+Z1zUPhlN1q/Kl58AFGoKGEpENe+YC eONw9kmkulp9/LTGxcgMRMjJpeYen1xCY2Z//IfYJx/b35g8iLuyu9qD7cQxP+GcnshZ UjDQ== X-Gm-Message-State: AJaThX5LibNzGAaZ/SQGoK0BJ7RTeayrIQn2/TaCVpvtqa6QzszPxK5l 78aB2dTq4YVOQ5OSrIeDxoCC9A== X-Google-Smtp-Source: AGs4zMaNJA4e2tCXrSmIWHdF3x3qwWrKh75KRZVUT+mb9tvMftUEGj/g1kQ2niVm0MAB0EU2ED2GhA== X-Received: by 10.107.202.130 with SMTP id a124mr10356478iog.293.1512085115446; Thu, 30 Nov 2017 15:38:35 -0800 (PST) Received: from samitolvanen.mtv.corp.google.com ([100.98.112.14]) by smtp.gmail.com with ESMTPSA id y21sm2494714ioi.14.2017.11.30.15.38.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Nov 2017 15:38:34 -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 , Nicholas Piggin Subject: [PATCH v2 1/2] kbuild: add clang-version.sh Date: Thu, 30 Nov 2017 15:38:26 -0800 Message-Id: <20171130233827.130069-2-samitolvanen@google.com> X-Mailer: git-send-email 2.15.0.531.g2ccb3012c9-goog In-Reply-To: <20171130233827.130069-1-samitolvanen@google.com> References: <20171129000011.55235-1-samitolvanen@google.com> <20171130233827.130069-1-samitolvanen@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171130_153855_480564_83EA31A6 X-CRM114-Status: UNSURE ( 9.61 ) X-CRM114-Notice: Please train this message. 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..9780efa56980 --- /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 `clang-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