From: Nathan Chancellor <natechancellor@gmail.com>
To: Russell King <linux@armlinux.org.uk>
Cc: Nicolas Pitre <nico@fluxnic.net>, Stefan Agner <stefan@agner.ch>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
clang-built-linux@googlegroups.com,
Nathan Chancellor <natechancellor@gmail.com>,
Nick Desaulniers <ndesaulniers@google.com>
Subject: [PATCH] ARM: xor-neon: Replace __GNUC__ checks with CONFIG_CC_IS_GCC
Date: Tue, 28 May 2019 16:57:42 -0700 [thread overview]
Message-ID: <20190528235742.105510-1-natechancellor@gmail.com> (raw)
Currently, when compiling this code with clang, the following warning is
emitted:
CC arch/arm/lib/xor-neon.o
arch/arm/lib/xor-neon.c:33:2: warning: This code requires at least
version 4.6 of GCC [-W#warnings]
This is because clang poses as GCC 4.2.1 with its __GNUC__ conditionals
for glibc compatibility[1]:
$ echo | clang -dM -E -x c /dev/null | grep GNUC | awk '{print $2" "$3}'
__GNUC_MINOR__ 2
__GNUC_PATCHLEVEL__ 1
__GNUC_STDC_INLINE__ 1
__GNUC__ 4
As pointed out by Ard Biesheuvel and Arnd Bergmann in an earlier
thread[2], the oldest version of GCC that is currently supported is gcc
4.6 after commit cafa0010cd51 ("Raise the minimum required gcc version
to 4.6") so we do not need to check for anything older anymore.
However, just removing the version check is not enough to silence clang
because it does not recognize '#pragma GCC optimize':
arch/arm/lib/xor-neon.c:25:13: warning: unknown pragma ignored
[-Wunknown-pragmas]
#pragma GCC optimize "tree-vectorize"
Looking into it further, -ftree-vectorize (which '#pragma GCC optimize
"tree-vectorize"' enables) is an alias in clang for -fvectorize[3],
which according to the documentation is on by default[4] (at least at
-O2 or -Os).
Just add the pragma when compiling with GCC so that clang does not
unnecessarily warn.
[1]: https://reviews.llvm.org/D51011#1206981
[2]: https://lore.kernel.org/lkml/CAK8P3a3NjTCgFd2dQ9KbHP8DpXf6s-ULfeU6acAYC4SDi+2qvw@mail.gmail.com/
[3]: https://github.com/llvm/llvm-project/blob/eafe8ef6f2b44ba/clang/include/clang/Driver/Options.td#L1729
[4]: https://llvm.org/docs/Vectorizers.html#usage
Link: https://github.com/ClangBuiltLinux/linux/issues/496
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
arch/arm/lib/xor-neon.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/arch/arm/lib/xor-neon.c b/arch/arm/lib/xor-neon.c
index c691b901092f..d532bc072ee4 100644
--- a/arch/arm/lib/xor-neon.c
+++ b/arch/arm/lib/xor-neon.c
@@ -22,15 +22,8 @@ MODULE_LICENSE("GPL");
* -ftree-vectorize) to attempt to exploit implicit parallelism and emit
* NEON instructions.
*/
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#ifdef CONFIG_CC_IS_GCC
#pragma GCC optimize "tree-vectorize"
-#else
-/*
- * While older versions of GCC do not generate incorrect code, they fail to
- * recognize the parallel nature of these functions, and emit plain ARM code,
- * which is known to be slower than the optimized ARM code in asm-arm/xor.h.
- */
-#warning This code requires at least version 4.6 of GCC
#endif
#pragma GCC diagnostic ignored "-Wunused-variable"
--
2.22.0.rc1
WARNING: multiple messages have this Message-ID
From: Nathan Chancellor <natechancellor@gmail.com>
To: Russell King <linux@armlinux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Nicolas Pitre <nico@fluxnic.net>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-kernel@vger.kernel.org, Stefan Agner <stefan@agner.ch>,
clang-built-linux@googlegroups.com,
Nathan Chancellor <natechancellor@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: xor-neon: Replace __GNUC__ checks with CONFIG_CC_IS_GCC
Date: Tue, 28 May 2019 16:57:42 -0700 [thread overview]
Message-ID: <20190528235742.105510-1-natechancellor@gmail.com> (raw)
Currently, when compiling this code with clang, the following warning is
emitted:
CC arch/arm/lib/xor-neon.o
arch/arm/lib/xor-neon.c:33:2: warning: This code requires at least
version 4.6 of GCC [-W#warnings]
This is because clang poses as GCC 4.2.1 with its __GNUC__ conditionals
for glibc compatibility[1]:
$ echo | clang -dM -E -x c /dev/null | grep GNUC | awk '{print $2" "$3}'
__GNUC_MINOR__ 2
__GNUC_PATCHLEVEL__ 1
__GNUC_STDC_INLINE__ 1
__GNUC__ 4
As pointed out by Ard Biesheuvel and Arnd Bergmann in an earlier
thread[2], the oldest version of GCC that is currently supported is gcc
4.6 after commit cafa0010cd51 ("Raise the minimum required gcc version
to 4.6") so we do not need to check for anything older anymore.
However, just removing the version check is not enough to silence clang
because it does not recognize '#pragma GCC optimize':
arch/arm/lib/xor-neon.c:25:13: warning: unknown pragma ignored
[-Wunknown-pragmas]
#pragma GCC optimize "tree-vectorize"
Looking into it further, -ftree-vectorize (which '#pragma GCC optimize
"tree-vectorize"' enables) is an alias in clang for -fvectorize[3],
which according to the documentation is on by default[4] (at least at
-O2 or -Os).
Just add the pragma when compiling with GCC so that clang does not
unnecessarily warn.
[1]: https://reviews.llvm.org/D51011#1206981
[2]: https://lore.kernel.org/lkml/CAK8P3a3NjTCgFd2dQ9KbHP8DpXf6s-ULfeU6acAYC4SDi+2qvw@mail.gmail.com/
[3]: https://github.com/llvm/llvm-project/blob/eafe8ef6f2b44ba/clang/include/clang/Driver/Options.td#L1729
[4]: https://llvm.org/docs/Vectorizers.html#usage
Link: https://github.com/ClangBuiltLinux/linux/issues/496
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
arch/arm/lib/xor-neon.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/arch/arm/lib/xor-neon.c b/arch/arm/lib/xor-neon.c
index c691b901092f..d532bc072ee4 100644
--- a/arch/arm/lib/xor-neon.c
+++ b/arch/arm/lib/xor-neon.c
@@ -22,15 +22,8 @@ MODULE_LICENSE("GPL");
* -ftree-vectorize) to attempt to exploit implicit parallelism and emit
* NEON instructions.
*/
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#ifdef CONFIG_CC_IS_GCC
#pragma GCC optimize "tree-vectorize"
-#else
-/*
- * While older versions of GCC do not generate incorrect code, they fail to
- * recognize the parallel nature of these functions, and emit plain ARM code,
- * which is known to be slower than the optimized ARM code in asm-arm/xor.h.
- */
-#warning This code requires at least version 4.6 of GCC
#endif
#pragma GCC diagnostic ignored "-Wunused-variable"
--
2.22.0.rc1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2019-05-28 23:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 23:57 Nathan Chancellor [this message]
2019-05-28 23:57 ` [PATCH] ARM: xor-neon: Replace __GNUC__ checks with CONFIG_CC_IS_GCC Nathan Chancellor
2019-05-30 23:00 ` Nick Desaulniers
2019-05-30 23:00 ` Nick Desaulniers
2019-05-31 8:05 ` Arnd Bergmann
2019-05-31 8:05 ` Arnd Bergmann
2019-05-31 18:32 ` Nathan Chancellor
2019-05-31 18:32 ` Nathan Chancellor
2019-05-31 19:21 ` Arnd Bergmann
2019-05-31 19:21 ` Arnd Bergmann
2019-05-31 20:06 ` Nick Desaulniers
2019-05-31 20:06 ` Nick Desaulniers
2019-05-31 20:26 ` Nathan Chancellor
2019-05-31 20:26 ` Nathan Chancellor
2019-05-31 21:03 ` Arnd Bergmann
2019-05-31 21:03 ` Arnd Bergmann
2019-06-01 0:28 ` Nathan Chancellor
2019-06-01 0:28 ` Nathan Chancellor
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=20190528235742.105510-1-natechancellor@gmail.com \
--to=natechancellor@gmail.com \
--cc=ard.biesheuvel@linaro.org \
--cc=arnd@arndb.de \
--cc=clang-built-linux@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=ndesaulniers@google.com \
--cc=nico@fluxnic.net \
--cc=stefan@agner.ch \
/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 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.