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+2...@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 <ndesaulni...@google.com> Signed-off-by: Nathan Chancellor <natechancel...@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