[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180720121417.271717768@linuxfoundation.org>
Date: Fri, 20 Jul 2018 14:13:05 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Arnd Bergmann <arnd@...db.de>,
"H. Peter Anvin" <hpa@...or.com>, Joe Perches <joe@...ches.com>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Juergen Gross <jgross@...e.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>, acme@...hat.com,
akataria@...are.com, akpm@...ux-foundation.org,
andrea.parri@...rulasolutions.com, ard.biesheuvel@...aro.org,
aryabinin@...tuozzo.com, astrachan@...gle.com,
boris.ostrovsky@...cle.com, brijesh.singh@....com,
caoj.fnst@...fujitsu.com, geert@...ux-m68k.org,
ghackmann@...gle.com, jan.kiszka@...mens.com,
jarkko.sakkinen@...ux.intel.com, jpoimboe@...hat.com,
keescook@...gle.com, kirill.shutemov@...ux.intel.com,
kstewart@...uxfoundation.org, linux-efi@...r.kernel.org,
linux-kbuild@...r.kernel.org, manojgupta@...gle.com,
mawilcox@...rosoft.com, michal.lkml@...kovi.net, mjg59@...gle.com,
mka@...omium.org, pombredanne@...b.com, rientjes@...gle.com,
rostedt@...dmis.org, sedat.dilek@...il.com,
thomas.lendacky@....com, tstellar@...hat.com, tweek@...gle.com,
virtualization@...ts.linux-foundation.org, will.deacon@....com,
yamada.masahiro@...ionext.com, Ingo Molnar <mingo@...nel.org>
Subject: [PATCH 4.14 01/92] compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations
4.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nick Desaulniers <ndesaulniers@...gle.com>
commit d03db2bc26f0e4a6849ad649a09c9c73fccdc656 upstream.
Functions marked extern inline do not emit an externally visible
function when the gnu89 C standard is used. Some KBUILD Makefiles
overwrite KBUILD_CFLAGS. This is an issue for GCC 5.1+ users as without
an explicit C standard specified, the default is gnu11. Since c99, the
semantics of extern inline have changed such that an externally visible
function is always emitted. This can lead to multiple definition errors
of extern inline functions at link time of compilation units whose build
files have removed an explicit C standard compiler flag for users of GCC
5.1+ or Clang.
Suggested-by: Arnd Bergmann <arnd@...db.de>
Suggested-by: H. Peter Anvin <hpa@...or.com>
Suggested-by: Joe Perches <joe@...ches.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@...gle.com>
Acked-by: Juergen Gross <jgross@...e.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: acme@...hat.com
Cc: akataria@...are.com
Cc: akpm@...ux-foundation.org
Cc: andrea.parri@...rulasolutions.com
Cc: ard.biesheuvel@...aro.org
Cc: aryabinin@...tuozzo.com
Cc: astrachan@...gle.com
Cc: boris.ostrovsky@...cle.com
Cc: brijesh.singh@....com
Cc: caoj.fnst@...fujitsu.com
Cc: geert@...ux-m68k.org
Cc: ghackmann@...gle.com
Cc: gregkh@...uxfoundation.org
Cc: jan.kiszka@...mens.com
Cc: jarkko.sakkinen@...ux.intel.com
Cc: jpoimboe@...hat.com
Cc: keescook@...gle.com
Cc: kirill.shutemov@...ux.intel.com
Cc: kstewart@...uxfoundation.org
Cc: linux-efi@...r.kernel.org
Cc: linux-kbuild@...r.kernel.org
Cc: manojgupta@...gle.com
Cc: mawilcox@...rosoft.com
Cc: michal.lkml@...kovi.net
Cc: mjg59@...gle.com
Cc: mka@...omium.org
Cc: pombredanne@...b.com
Cc: rientjes@...gle.com
Cc: rostedt@...dmis.org
Cc: sedat.dilek@...il.com
Cc: thomas.lendacky@....com
Cc: tstellar@...hat.com
Cc: tweek@...gle.com
Cc: virtualization@...ts.linux-foundation.org
Cc: will.deacon@....com
Cc: yamada.masahiro@...ionext.com
Link: http://lkml.kernel.org/r/20180621162324.36656-2-ndesaulniers@google.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
include/linux/compiler-gcc.h | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -66,25 +66,40 @@
#endif
/*
+ * Feature detection for gnu_inline (gnu89 extern inline semantics). Either
+ * __GNUC_STDC_INLINE__ is defined (not using gnu89 extern inline semantics,
+ * and we opt in to the gnu89 semantics), or __GNUC_STDC_INLINE__ is not
+ * defined so the gnu89 semantics are the default.
+ */
+#ifdef __GNUC_STDC_INLINE__
+# define __gnu_inline __attribute__((gnu_inline))
+#else
+# define __gnu_inline
+#endif
+
+/*
* Force always-inline if the user requests it so via the .config,
* or if gcc is too old.
* GCC does not warn about unused static inline functions for
* -Wunused-function. This turns out to avoid the need for complex #ifdef
* directives. Suppress the warning in clang as well by using "unused"
* function attribute, which is redundant but not harmful for gcc.
+ * Prefer gnu_inline, so that extern inline functions do not emit an
+ * externally visible function. This makes extern inline behave as per gnu89
+ * semantics rather than c99. This prevents multiple symbol definition errors
+ * of extern inline functions at link time.
+ * A lot of inline functions can cause havoc with function tracing.
*/
#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
!defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
-#define inline inline __attribute__((always_inline,unused)) notrace
-#define __inline__ __inline__ __attribute__((always_inline,unused)) notrace
-#define __inline __inline __attribute__((always_inline,unused)) notrace
+#define inline \
+ inline __attribute__((always_inline, unused)) notrace __gnu_inline
#else
-/* A lot of inline functions can cause havoc with function tracing */
-#define inline inline __attribute__((unused)) notrace
-#define __inline__ __inline__ __attribute__((unused)) notrace
-#define __inline __inline __attribute__((unused)) notrace
+#define inline inline __attribute__((unused)) notrace __gnu_inline
#endif
+#define __inline__ inline
+#define __inline inline
#define __always_inline inline __attribute__((always_inline))
#define noinline __attribute__((noinline))
Powered by blists - more mailing lists