Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2530117imm; Thu, 7 Jun 2018 12:12:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI01iPnmnNwj/OSMcFav9fYi4T3rwlzrF+gkHO55PpR0gBfgLnGDRql2F8QGMNcYWK/gWwd X-Received: by 2002:a17:902:14cb:: with SMTP id y11-v6mr3182162plg.229.1528398722294; Thu, 07 Jun 2018 12:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528398722; cv=none; d=google.com; s=arc-20160816; b=fwIoquosADMFhwwyNzvR/Lahe7rXgQNBykMegMQTrvGKO4eD4g0e0Vi+S2ZGP3P0CE 2U83jdk8mrPwh7TMOy7V7TAo2kWzXAaJfaaHdaUV3bQVVKMdrEt5u5KQ77EbQi+ShQyQ 89VB8Jj7ACT+o6oIXVa8ldraTMo+yV95i2LUMKsduMHQVCD9wCUQAtj8pBVneZbk1E1G foJnj4TFXCgcYpvZCxHBkR/PLy9TqD6zw3mq2JcqgABs9MMW58fH5KlHHfJfBtnRnvts LoacSZ2IWthGYfvgsX5fzS7TPtfkh/AkisX+A4IgMqEhd0QrChqHMfHNX/MQB6wQyDvi QvSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=pvFY0ZGUXB4qqC4Ew7ZSEsm72BiOdaW7coU0HDx1pVI=; b=Agmzq03HQGf4xMP5aPyZ4IfKVp2y2aDxZK9Zl+IZoDBVMiDrzFxvc+cbMqs8typck8 +GvY15jnlcNfpChdb05rJpNNRwK+aq42RelROPD0ouwxUdJe1CEBaK3VCoZAp8S+NfB5 jtvJOmUEkApVWHzoxzTohUaA3v5dUMu2wP3/efDJVU58ropdf4xCiCoyp7M7/zK9As4H zPcw1KUq3nwx8B31wG16UqEtKzO29HGm4ms1xqqP+sucLmfl88yFZbIUneywq7hZ3h98 j758qu4rCT200ACRzbcMDGJh+/tEWxFIO8v1D7Wg+6VbNWrXdPH0e7R9SV0vWZyAJN6v IUeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x63-v6si54136396pfi.162.2018.06.07.12.11.47; Thu, 07 Jun 2018 12:12:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935148AbeFGSoK (ORCPT + 99 others); Thu, 7 Jun 2018 14:44:10 -0400 Received: from smtprelay0119.hostedemail.com ([216.40.44.119]:55350 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933108AbeFGSoI (ORCPT ); Thu, 7 Jun 2018 14:44:08 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id B7F54100E806B; Thu, 7 Jun 2018 18:44:06 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: X-HE-Tag: badge66_5d81958f3f2f X-Filterd-Recvd-Size: 4608 Received: from XPS-9350.home (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf10.hostedemail.com (Postfix) with ESMTPA; Thu, 7 Jun 2018 18:44:00 +0000 (UTC) Message-ID: Subject: Re: [PATCH v3 1/3] compiler-gcc.h: add gnu_inline to all inline declarations From: Joe Perches To: Nick Desaulniers , akpm@linux-foundation.org, hpa@zytor.com, mingo@redhat.com, tglx@linutronix.de Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux-foundation.org, astrachan@google.com, manojgupta@google.com, ghackmann@google.com, sedat.dilek@gmail.com, tstellar@redhat.com, keescook@google.com, yamada.masahiro@socionext.com, michal.lkml@markovi.net, linux-kbuild@vger.kernel.org, geert@linux-m68k.org, will.deacon@arm.com, mawilcox@microsoft.com, arnd@arndb.de, rientjes@google.com, acme@redhat.com, pombredanne@nexb.com, aryabinin@virtuozzo.com, kstewart@linuxfoundation.org, boris.ostrovsky@oracle.com, jan.kiszka@siemens.com, rostedt@goodmis.org, kirill.shutemov@linux.intel.com, ard.biesheuvel@linaro.org, akataria@vmware.com, brijesh.singh@amd.com, caoj.fnst@cn.fujitsu.com, gregkh@linuxfoundation.org, jarkko.sakkinen@linux.intel.com, jgross@suse.com, jpoimboe@redhat.com, mka@chromium.org, thomas.lendacky@amd.com, tweek@google.com, mjg59@google.com Date: Thu, 07 Jun 2018 11:43:58 -0700 In-Reply-To: <20180607183219.192973-2-ndesaulniers@google.com> References: <20180607183219.192973-1-ndesaulniers@google.com> <20180607183219.192973-2-ndesaulniers@google.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2018-06-07 at 11:32 -0700, Nick Desaulniers wrote: > 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. [] > diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h [] > @@ -72,17 +72,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. > */ > #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, gnu_inline)) notrace > +#define __inline__ inline > +#define __inline 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, gnu_inline)) notrace > +#define __inline__ inline > +#define __inline inline > #endif Perhaps move these last 2 defines below the #endif as they are common to both cases #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4) #define inline inline __attribute__((always_inline, unused, gnu_inline)) notrace #else /* A lot of inline functions can cause havoc with function tracing */ #define inline inline __attribute__((unused, gnu_inline)) notrace #endif #define __inline__ inline #define __inline inline #define __always_inline inline __attribute__((always_inline))