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 2/3] kbuild: add cc-if-name-version and compiler-specific variants Date: Tue, 28 Nov 2017 16:00:10 -0800 [thread overview] Message-ID: <20171129000011.55235-3-samitolvanen@google.com> (raw) In-Reply-To: <20171129000011.55235-1-samitolvanen@google.com> This change adds macros for testing both compiler name and version. Current cc-version, cc-ifversion etc. macros that test gcc version are left unchanged to prevent compatibility issues with existing tests. Signed-off-by: Sami Tolvanen <samitolvanen@google.com> --- scripts/Kbuild.include | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 065324a8046f..b6d7d347b203 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -215,6 +215,37 @@ cc-disable-warning = $(call try-run-cached,\ # Expands to either gcc or clang cc-name = $(call shell-cached,$(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) +# __cc-version +# Returns compiler version +__cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/$(cc-name)-version.sh $(CC)) + +# __cc-fullversion +# Returns full compiler version +__cc-fullversion = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/$(cc-name)-version.sh -p $(CC)) + +# cc-if-name-version +# Matches compiler name and version +# Usage: EXTRA_CFLAGS += $(call cc-if-name-version, gcc, -lt, 0402, -O1) +cc-if-name-version = $(shell [ $(cc-name) == $(1) ] && [ $(__cc-version) $(2) $(3) ] && echo $(4) || echo $(5)) + +# cc-if-name-fullversion +# Matches compiler name and full version +# Usage: EXTRA_CFLAGS += $(call cc-if-name-fullversion, gcc, -lt, 040502, -O1) +cc-if-name-fullversion = $(shell [ $(cc-name) == $(1) ] && [ $(__cc-fullversion) $(2) $(3) ] && echo $(4) || echo $(5)) + +# gcc-ifversion +gcc-ifversion = $(call cc-if-name-version, gcc, $(1), $(2), $(3), $(4)) + +# gcc-if-fullversion +gcc-if-fullversion = (call cc-if-name-fullversion, gcc, $(1), $(2), $(3), $(4)) + +# clang-ifversion +clang-ifversion = $(call cc-if-name-version, clang, $(1), $(2), $(3), $(4)) + +# clang-if-fullversion +clang-if-fullversion = (call cc-if-name-fullversion, clang, $(1), $(2), $(3), $(4)) + # cc-version cc-version = $(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) -- 2.15.0.417.g466bffb3ac-goog
WARNING: multiple messages have this Message-ID (diff)
From: samitolvanen@google.com (Sami Tolvanen) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] kbuild: add cc-if-name-version and compiler-specific variants Date: Tue, 28 Nov 2017 16:00:10 -0800 [thread overview] Message-ID: <20171129000011.55235-3-samitolvanen@google.com> (raw) In-Reply-To: <20171129000011.55235-1-samitolvanen@google.com> This change adds macros for testing both compiler name and version. Current cc-version, cc-ifversion etc. macros that test gcc version are left unchanged to prevent compatibility issues with existing tests. Signed-off-by: Sami Tolvanen <samitolvanen@google.com> --- scripts/Kbuild.include | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 065324a8046f..b6d7d347b203 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -215,6 +215,37 @@ cc-disable-warning = $(call try-run-cached,\ # Expands to either gcc or clang cc-name = $(call shell-cached,$(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) +# __cc-version +# Returns compiler version +__cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/$(cc-name)-version.sh $(CC)) + +# __cc-fullversion +# Returns full compiler version +__cc-fullversion = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/$(cc-name)-version.sh -p $(CC)) + +# cc-if-name-version +# Matches compiler name and version +# Usage: EXTRA_CFLAGS += $(call cc-if-name-version, gcc, -lt, 0402, -O1) +cc-if-name-version = $(shell [ $(cc-name) == $(1) ] && [ $(__cc-version) $(2) $(3) ] && echo $(4) || echo $(5)) + +# cc-if-name-fullversion +# Matches compiler name and full version +# Usage: EXTRA_CFLAGS += $(call cc-if-name-fullversion, gcc, -lt, 040502, -O1) +cc-if-name-fullversion = $(shell [ $(cc-name) == $(1) ] && [ $(__cc-fullversion) $(2) $(3) ] && echo $(4) || echo $(5)) + +# gcc-ifversion +gcc-ifversion = $(call cc-if-name-version, gcc, $(1), $(2), $(3), $(4)) + +# gcc-if-fullversion +gcc-if-fullversion = (call cc-if-name-fullversion, gcc, $(1), $(2), $(3), $(4)) + +# clang-ifversion +clang-ifversion = $(call cc-if-name-version, clang, $(1), $(2), $(3), $(4)) + +# clang-if-fullversion +clang-if-fullversion = (call cc-if-name-fullversion, clang, $(1), $(2), $(3), $(4)) + # cc-version cc-version = $(call shell-cached,$(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) -- 2.15.0.417.g466bffb3ac-goog
next prev parent reply other threads:[~2017-11-29 0:00 UTC|newest] Thread overview: 33+ 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 2017-11-29 0:00 ` [PATCH 1/3] kbuild: add clang-version.sh Sami Tolvanen 2017-11-29 0:00 ` Sami Tolvanen 2017-11-29 17:39 ` Nick Desaulniers 2017-11-29 17:39 ` Nick Desaulniers 2017-11-30 12:09 ` Masahiro Yamada 2017-11-30 12:09 ` Masahiro Yamada 2017-11-29 0:00 ` Sami Tolvanen [this message] 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-29 17:19 ` Nick Desaulniers 2017-11-30 12:21 ` Masahiro Yamada 2017-11-30 12:21 ` Masahiro Yamada 2017-11-30 17:34 ` Sami Tolvanen 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 0:00 ` Sami Tolvanen 2017-11-29 12:15 ` Ard Biesheuvel 2017-11-29 12:15 ` Ard Biesheuvel 2017-11-29 12:15 ` Ard Biesheuvel 2017-11-29 16:22 ` Sami Tolvanen 2017-11-29 16:22 ` Sami Tolvanen 2017-11-29 16:22 ` Sami Tolvanen 2017-11-29 17:26 ` Nick Desaulniers 2017-11-29 17:26 ` Nick Desaulniers 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 ` Sami Tolvanen 2017-11-30 23:38 ` [PATCH v2 1/2] kbuild: add clang-version.sh Sami Tolvanen 2017-11-30 23:38 ` Sami Tolvanen 2017-11-30 23:38 ` [PATCH v2 2/2] kbuild: add __cc-ifversion and compiler-specific variants Sami Tolvanen 2017-11-30 23:38 ` 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-3-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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.