[PATCH] compiler, clang: check before defining inline

From: Alexander Alemayhu
Date: Sat Jun 10 2017 - 20:00:52 EST


Fixes the compiler warning below introduced in abb2ea7dfd82 (compiler, clang:
suppress warning for unused static inline functions, 2017-06-06)

./include/linux/compiler-gcc.h:78:9: note: previous definition is here
^
1 warning generated.
clang -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h \
-D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
-Wno-compare-distinct-pointer-types \
-Wno-gnu-variable-sized-type-not-at-end \
-Wno-address-of-packed-member -Wno-tautological-compare \
-Wno-unknown-warning-option \
-O2 -emit-llvm -c /home/vagrant/kernels/net-next/samples/bpf/test_map_in_map_kern.c -o -| llc -march=bpf -filetype=obj -o /home/vagrant/kernels/net-next/samples/bpf/test_map_in_map_kern.o
In file included from /home/vagrant/kernels/net-next/samples/bpf/test_map_in_map_kern.c:9:
In file included from ./include/linux/ptrace.h:4:
In file included from ./include/linux/compiler.h:82:
./include/linux/compiler-clang.h:24:9: warning: 'inline' macro redefined [-Wmacro-redefined]
^
./include/linux/compiler-gcc.h:78:9: note: previous definition is here
^
1 warning generated.
make[1]: Leaving directory '/home/vagrant/kernels/net-next'

$ clang --version
clang version 3.9.1 (tags/RELEASE_391/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ gcc --version
gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Fixes: abb2ea7dfd82 ("compiler, clang: suppress warning for unused static inline functions")
Signed-off-by: Alexander Alemayhu <alexander@xxxxxxxxxxxx>
---

This is causing an error on out of tree builds for example using the
prototype-kernel repository. Should this be sent to Linus?

Thanks

include/linux/compiler-clang.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index ea9126006a69..7cb55de2703c 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -21,4 +21,6 @@
* -Wunused-function. This turns out to avoid the need for complex #ifdef
* directives. Suppress the warning in clang as well.
*/
+#ifndef inline
#define inline inline __attribute__((unused))
+#endif
--
2.7.4