From: Sami Tolvanen <samitolvanen@google.com>
To: Alex Matveev <alxmtvv@gmail.com>, Andi Kleen <ak@linux.intel.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Greg Hackmann <ghackmann@google.com>,
Kees Cook <keescook@chromium.org>,
linux-arm-kernel@lists.infradead.org,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>,
Michal Marek <michal.lkml@markovi.net>,
Nick Desaulniers <ndesaulniers@google.com>,
Yury Norov <ynorov@caviumnetworks.com>,
Matthias Kaehlcke <mka@chromium.org>
Cc: Sami Tolvanen <samitolvanen@google.com>
Subject: [PATCH 1/3] kbuild: add clang-version.sh
Date: Tue, 28 Nov 2017 16:00:09 -0800 [thread overview]
Message-ID: <20171129000011.55235-2-samitolvanen@google.com> (raw)
In-Reply-To: <20171129000011.55235-1-samitolvanen@google.com>
Based on gcc-version.sh, clang-version.sh prints out the correct
version of clang.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
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 <clang-command>\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
--
2.15.0.417.g466bffb3ac-goog
next prev parent reply other threads:[~2017-11-29 0:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 0:00 [PATCH 0/3] Add version macros for clang and fix arm64 for clang <6.0 Sami Tolvanen
2017-11-29 0:00 ` Sami Tolvanen [this message]
2017-11-29 17:39 ` [PATCH 1/3] kbuild: add clang-version.sh Nick Desaulniers
2017-11-30 12:09 ` Masahiro Yamada
2017-11-29 0:00 ` [PATCH 2/3] kbuild: add cc-if-name-version and compiler-specific variants Sami Tolvanen
2017-11-29 17:19 ` Nick Desaulniers
2017-11-30 12:21 ` Masahiro Yamada
2017-11-30 17:34 ` Sami Tolvanen
2017-11-29 0:00 ` [PATCH 3/3] arm64: use -mno-implicit-float instead of -mgeneral-regs-only Sami Tolvanen
2017-11-29 12:15 ` Ard Biesheuvel
2017-11-29 16:22 ` Sami Tolvanen
2017-11-29 17:26 ` Nick Desaulniers
2017-11-30 23:38 ` [PATCH v2 0/2] Add version macros for clang Sami Tolvanen
2017-11-30 23:38 ` [PATCH v2 1/2] kbuild: add clang-version.sh Sami Tolvanen
2017-11-30 23:38 ` [PATCH v2 2/2] kbuild: add __cc-ifversion and compiler-specific variants Sami Tolvanen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171129000011.55235-2-samitolvanen@google.com \
--to=samitolvanen@google.com \
--cc=ak@linux.intel.com \
--cc=alxmtvv@gmail.com \
--cc=ard.biesheuvel@linaro.org \
--cc=ghackmann@google.com \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maxim.kuvyrkov@linaro.org \
--cc=michal.lkml@markovi.net \
--cc=mka@chromium.org \
--cc=ndesaulniers@google.com \
--cc=yamada.masahiro@socionext.com \
--cc=ynorov@caviumnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox