gregkh at linuxfoundation.org
2018-Jul-18 09:34 UTC
Patch "compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations" has been added to the 4.4-stable tree
This is a note to let you know that I've just added the patch titled compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations to the 4.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: compiler-gcc.h-add-__attribute__-gnu_inline-to-all-inline-declarations.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable at vger.kernel.org> know about it.>From d03db2bc26f0e4a6849ad649a09c9c73fccdc656 Mon Sep 17 00:00:00 2001From: Nick Desaulniers <ndesaulniers at google.com> Date: Thu, 21 Jun 2018 09:23:22 -0700 Subject: compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations From: Nick Desaulniers <ndesaulniers at google.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 at arndb.de> Suggested-by: H. Peter Anvin <hpa at zytor.com> Suggested-by: Joe Perches <joe at perches.com> Signed-off-by: Nick Desaulniers <ndesaulniers at google.com> Acked-by: Juergen Gross <jgross at suse.com> Cc: Linus Torvalds <torvalds at linux-foundation.org> Cc: Peter Zijlstra <peterz at infradead.org> Cc: Thomas Gleixner <tglx at linutronix.de> Cc: acme at redhat.com Cc: akataria at vmware.com Cc: akpm at linux-foundation.org Cc: andrea.parri at amarulasolutions.com Cc: ard.biesheuvel at linaro.org Cc: aryabinin at virtuozzo.com Cc: astrachan at google.com Cc: boris.ostrovsky at oracle.com Cc: brijesh.singh at amd.com Cc: caoj.fnst at cn.fujitsu.com Cc: geert at linux-m68k.org Cc: ghackmann at google.com Cc: gregkh at linuxfoundation.org Cc: jan.kiszka at siemens.com Cc: jarkko.sakkinen at linux.intel.com Cc: jpoimboe at redhat.com Cc: keescook at google.com Cc: kirill.shutemov at linux.intel.com Cc: kstewart at linuxfoundation.org Cc: linux-efi at vger.kernel.org Cc: linux-kbuild at vger.kernel.org Cc: manojgupta at google.com Cc: mawilcox at microsoft.com Cc: michal.lkml at markovi.net Cc: mjg59 at google.com Cc: mka at chromium.org Cc: pombredanne at nexb.com Cc: rientjes at google.com Cc: rostedt at goodmis.org Cc: sedat.dilek at gmail.com Cc: thomas.lendacky at amd.com Cc: tstellar at redhat.com Cc: tweek at google.com Cc: virtualization at lists.linux-foundation.org Cc: will.deacon at arm.com Cc: yamada.masahiro at socionext.com Link: http://lkml.kernel.org/r/20180621162324.36656-2-ndesaulniers at google.com Signed-off-by: Ingo Molnar <mingo at kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.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 @@ -65,25 +65,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)) Patches currently in stable-queue which might be from ndesaulniers at google.com are queue-4.4/x86-asm-add-_asm_arg-constants-for-argument-registers-to-asm-asm.h.patch queue-4.4/compiler-gcc.h-add-__attribute__-gnu_inline-to-all-inline-declarations.patch
Apparently Analagous Threads
- Patch "compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations" has been added to the 4.14-stable tree
- Patch "compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations" has been added to the 4.17-stable tree
- Patch "compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations" has been added to the 4.9-stable tree
- [PATCH 4.4 04/31] compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations
- [PATCH 4.9 05/66] compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations