aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/compiler-gcc.h
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2017-07-06 18:35:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-06 19:24:29 -0400
commit9a04dbcfb33b4012d0ce8c0282f1e3ca694675b1 (patch)
treeec802cb076b875d2e8259de087d8cd186cfce70f /include/linux/compiler-gcc.h
parent9ced560b82606b35adb33a27012a148d418a4c1f (diff)
compiler, clang: always inline when CONFIG_OPTIMIZE_INLINING is disabled
The motivation for commit abb2ea7dfd82 ("compiler, clang: suppress warning for unused static inline functions") was to suppress clang's warnings about unused static inline functions. For configs without CONFIG_OPTIMIZE_INLINING enabled, such as any non-x86 architecture, `inline' in the kernel implies that __attribute__((always_inline)) is used. Some code depends on that behavior, see https://lkml.org/lkml/2017/6/13/918: net/built-in.o: In function `__xchg_mb': arch/arm64/include/asm/cmpxchg.h:99: undefined reference to `__compiletime_assert_99' arch/arm64/include/asm/cmpxchg.h:99: undefined reference to `__compiletime_assert_99 The full fix would be to identify these breakages and annotate the functions with __always_inline instead of `inline'. But since we are late in the 4.12-rc cycle, simply carry forward the forced inlining behavior and work toward moving arm64, and other architectures, toward CONFIG_OPTIMIZE_INLINING behavior. Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1706261552200.1075@chino.kir.corp.google.com Signed-off-by: David Rientjes <rientjes@google.com> Reported-by: Sodagudi Prasad <psodagud@codeaurora.org> Tested-by: Sodagudi Prasad <psodagud@codeaurora.org> Tested-by: Matthias Kaehlcke <mka@chromium.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/compiler-gcc.h')
-rw-r--r--include/linux/compiler-gcc.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 7deaae3dc87d..cd4bbe8242bd 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -66,18 +66,22 @@
66 66
67/* 67/*
68 * Force always-inline if the user requests it so via the .config, 68 * Force always-inline if the user requests it so via the .config,
69 * or if gcc is too old: 69 * or if gcc is too old.
70 * GCC does not warn about unused static inline functions for
71 * -Wunused-function. This turns out to avoid the need for complex #ifdef
72 * directives. Suppress the warning in clang as well by using "unused"
73 * function attribute, which is redundant but not harmful for gcc.
70 */ 74 */
71#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ 75#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
72 !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4) 76 !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
73#define inline inline __attribute__((always_inline)) notrace 77#define inline inline __attribute__((always_inline,unused)) notrace
74#define __inline__ __inline__ __attribute__((always_inline)) notrace 78#define __inline__ __inline__ __attribute__((always_inline,unused)) notrace
75#define __inline __inline __attribute__((always_inline)) notrace 79#define __inline __inline __attribute__((always_inline,unused)) notrace
76#else 80#else
77/* A lot of inline functions can cause havoc with function tracing */ 81/* A lot of inline functions can cause havoc with function tracing */
78#define inline inline notrace 82#define inline inline __attribute__((unused)) notrace
79#define __inline__ __inline__ notrace 83#define __inline__ __inline__ __attribute__((unused)) notrace
80#define __inline __inline notrace 84#define __inline __inline __attribute__((unused)) notrace
81#endif 85#endif
82 86
83#define __always_inline inline __attribute__((always_inline)) 87#define __always_inline inline __attribute__((always_inline))