All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Nick Desaulniers <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: ndesaulniers@google.com, torvalds@linux-foundation.org,
	tglx@linutronix.de, joe@perches.com,
	linux-kernel@vger.kernel.org, hpa@zytor.com, jgross@suse.com,
	mingo@kernel.org, peterz@infradead.org, arnd@arndb.de
Subject: [tip:x86/urgent] compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations
Date: Tue, 3 Jul 2018 08:59:08 -0700	[thread overview]
Message-ID: <tip-d03db2bc26f0e4a6849ad649a09c9c73fccdc656@git.kernel.org> (raw)
In-Reply-To: <20180621162324.36656-2-ndesaulniers@google.com>

Commit-ID:  d03db2bc26f0e4a6849ad649a09c9c73fccdc656
Gitweb:     https://git.kernel.org/tip/d03db2bc26f0e4a6849ad649a09c9c73fccdc656
Author:     Nick Desaulniers <ndesaulniers@google.com>
AuthorDate: Thu, 21 Jun 2018 09:23:22 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 3 Jul 2018 10:56:27 +0200

compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations

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@arndb.de>
Suggested-by: H. Peter Anvin <hpa@zytor.com>
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: acme@redhat.com
Cc: akataria@vmware.com
Cc: akpm@linux-foundation.org
Cc: andrea.parri@amarulasolutions.com
Cc: ard.biesheuvel@linaro.org
Cc: aryabinin@virtuozzo.com
Cc: astrachan@google.com
Cc: boris.ostrovsky@oracle.com
Cc: brijesh.singh@amd.com
Cc: caoj.fnst@cn.fujitsu.com
Cc: geert@linux-m68k.org
Cc: ghackmann@google.com
Cc: gregkh@linuxfoundation.org
Cc: jan.kiszka@siemens.com
Cc: jarkko.sakkinen@linux.intel.com
Cc: jpoimboe@redhat.com
Cc: keescook@google.com
Cc: kirill.shutemov@linux.intel.com
Cc: kstewart@linuxfoundation.org
Cc: linux-efi@vger.kernel.org
Cc: linux-kbuild@vger.kernel.org
Cc: manojgupta@google.com
Cc: mawilcox@microsoft.com
Cc: michal.lkml@markovi.net
Cc: mjg59@google.com
Cc: mka@chromium.org
Cc: pombredanne@nexb.com
Cc: rientjes@google.com
Cc: rostedt@goodmis.org
Cc: sedat.dilek@gmail.com
Cc: thomas.lendacky@amd.com
Cc: tstellar@redhat.com
Cc: tweek@google.com
Cc: virtualization@lists.linux-foundation.org
Cc: will.deacon@arm.com
Cc: yamada.masahiro@socionext.com
Link: http://lkml.kernel.org/r/20180621162324.36656-2-ndesaulniers@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/compiler-gcc.h | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index fd282c7d3e5e..573f5a7d42d4 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -65,6 +65,18 @@
 #define __must_be_array(a)	BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
 #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.
@@ -72,19 +84,22 @@
  * -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))
 

  reply	other threads:[~2018-07-03 15:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21 16:23 [PATCH v6 0/3] extern inline native_save_fl for paravirt Nick Desaulniers
2018-06-21 16:23 ` Nick Desaulniers
2018-06-21 16:23 ` [PATCH v6 1/3] compiler-gcc.h: add gnu_inline to all inline declarations Nick Desaulniers
2018-06-21 16:23   ` Nick Desaulniers
2018-07-03 15:59   ` tip-bot for Nick Desaulniers [this message]
2018-06-21 16:23 ` [PATCH v6 2/3] x86/asm: add _ASM_ARG* constants for argument registers to <asm/asm.h> Nick Desaulniers
2018-06-21 16:23   ` Nick Desaulniers
2018-07-03 15:59   ` [tip:x86/urgent] x86/asm: Add " tip-bot for H. Peter Anvin
2018-06-21 16:23 ` [PATCH v6 3/3] x86: paravirt: make native_save_fl extern inline Nick Desaulniers
2018-06-21 16:23   ` Nick Desaulniers
2018-06-22  2:24   ` Ingo Molnar
2018-06-22  2:24     ` Ingo Molnar
2018-06-22 17:10     ` Nick Desaulniers
2018-06-22 17:10       ` Nick Desaulniers
2018-06-26  7:13       ` Ingo Molnar
2018-06-26  7:13         ` Ingo Molnar
2018-06-26 16:22         ` Nick Desaulniers
2018-06-26 16:22           ` Nick Desaulniers
2018-07-03  7:21           ` Juergen Gross
2018-07-03  7:21             ` Juergen Gross
2018-07-03 16:00   ` [tip:x86/urgent] x86/paravirt: Make native_save_fl() " tip-bot for Nick Desaulniers
2018-07-13 10:16   ` [PATCH v6 3/3] x86: paravirt: make native_save_fl " David Laight
2018-07-16 17:27     ` Nick Desaulniers
2018-07-16 17:27       ` Nick Desaulniers
2018-07-17  8:44       ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-d03db2bc26f0e4a6849ad649a09c9c73fccdc656@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=arnd@arndb.de \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.