Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2523395imm; Thu, 7 Jun 2018 12:05:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIR4uQGqMiBWWYTiE+RzuhIK9YprbfLJLl0feJqkwAFzT2CuURNmD109kTmitWpzdoOOCQq X-Received: by 2002:a62:8b0a:: with SMTP id j10-v6mr2909954pfe.28.1528398330285; Thu, 07 Jun 2018 12:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528398330; cv=none; d=google.com; s=arc-20160816; b=P3SZFjpQC6Lgwhnvizo1c/DfJ6dG4kx02YenqblPaKaOGdmizqmLjZs7Ny5e73lTe3 ph6mtVA3YTCOrdFNWyrhGfpXZJ4zbR8F55A7wvTGHYzdKo5aGYMdZnLpqDHkBNmjLnzg 4A3+maUF8AhHPUuRWf/myKvw0rO10xb0xzU5ScWmGon7mSNcYbFtlSA5Pj/1IVyLnYCN kqF3r/OviAyaXGbk/LO9vpVfeeyQztP2tpt6P9jt50nQTfuIQyT/qtfAwB50BSgemq+8 HNu/lwOq4zIARzO4mIQ5mQT39aRJxlqP912Iv8ncM6ut0Bsg13g0a+R1vN1njVWDAGYY VnVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=p3l3SarRkUZt1ZR2hf6cCyxlYIBmDr+5VTqDQHa4DQ8=; b=fG611+cGOJHHvd2u9tNlT9UnSmURkiOXTHdJf6s6zfT4J67C17pSkOIqwxMVy/eHrf CmM0C5Xgm6TRh6/wjwIlRJZa3eGGw4gfAyuX1tjJXx8av5b7DMsF0d3RH/Gln1IMu5fv QgxlU9PsRYD8V0JxNK9r0oiQeFRTJJxUVku8MLq0xlXwfD6Uzm5JNb7DMTv7Bun42dl5 11MDA9upiOfxvje6BVnYR9/F7pVEhTEg4MznMyn0Oq1Ul0mrz+UAaQkVanvze2isKqI9 0ZituLonNmTaiuDqNGjJBBBjGgl07pvEfBu+bbJW9P3cCBNWSDAU7+DaBDspO7M/NH00 VWSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ERFrJs+j; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8-v6si40047171pgv.169.2018.06.07.12.05.16; Thu, 07 Jun 2018 12:05:30 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=ERFrJs+j; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933793AbeFGR0b (ORCPT + 99 others); Thu, 7 Jun 2018 13:26:31 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:39881 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933668AbeFGR0Z (ORCPT ); Thu, 7 Jun 2018 13:26:25 -0400 Received: by mail-pl0-f65.google.com with SMTP id f1-v6so6556017plt.6 for ; Thu, 07 Jun 2018 10:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=p3l3SarRkUZt1ZR2hf6cCyxlYIBmDr+5VTqDQHa4DQ8=; b=ERFrJs+jLTtAd1I5lDOeLNeIV5ZkRM/aw+ovTtM5PrwGkYo1bbp8eIcsxVKOdMUDVH Jb/yqOrF3WKGWo96IlzJfEsMKEgG3+Ci2ez/YqcY3HXJaapTZdQXE6to8LKjOwdGbfbl MqAJR+psKVR3dx4pi0iQkE5/EM7RFmqf5cNxbCUJO7hUK6Rsksrn/wTdv2RvPZQ50awJ setMsRW/L7ecj9DcKPPcbwcWadu0rkvYrgLDQMM4Ki/JckWPgCpVZnMYHkTTSKhXsMky eqtqlTFviCfPH90Fu3qqETVxFPynbwhzk7XGYbvXJD2WOoUr+bV8dfmcIY3j2LZtwZ3d +Myw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=p3l3SarRkUZt1ZR2hf6cCyxlYIBmDr+5VTqDQHa4DQ8=; b=mn9aqM0qqPGOnfqCzNHQxOTvA1w7+OPMe1cV2jIzu4IoROLUI/2huYYQLNmmJCfe0I 1CJI9M+nbjTJtrCLB6CuhVO09ycYwl28jljywXk0nBM9W11xCLnR4qsoEz4yxv6kwWnd XzcY36a/S3+5V3VWRWVgSBOsymP5AbuzHsxKZHmf5ozfcxbUamWhzgRWHtAI5uPi8MfT valF4Q1++4Riym4Bhs+nPhqp9O3iCYFuJO7E1oOEk8kwf4QrK3auXhcP1lSfvlmppgl9 Yqh0nv4NH1wS11L+Xo0Z9ZUZiFWI/j+hdVVEk4IYR+SRcudyogu+5NDJWQIIiTjoqvL8 L+5A== X-Gm-Message-State: APt69E31royx47pQb7ZYA1N2pnmEyrYQlETpwgwTFRQWGU2V845LlrS9 yfDNKlH1LuxAKrVm61TQZT0YqOnbgT1orXSZYkfvMg== X-Received: by 2002:a17:902:1347:: with SMTP id r7-v6mr2916432ple.62.1528392383587; Thu, 07 Jun 2018 10:26:23 -0700 (PDT) MIME-Version: 1.0 References: <20180605170532.170361-1-ndesaulniers@google.com> <20180605170532.170361-2-ndesaulniers@google.com> <202492204c2d5bd5ca27307cbca5e44673b739ed.camel@perches.com> In-Reply-To: <202492204c2d5bd5ca27307cbca5e44673b739ed.camel@perches.com> From: Nick Desaulniers Date: Thu, 7 Jun 2018 10:26:10 -0700 Message-ID: Subject: Re: [PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations To: joe@perches.com Cc: Andrew Morton , Ard Biesheuvel , Andrey Ryabinin , akataria@vmware.com, boris.ostrovsky@oracle.com, brijesh.singh@amd.com, Cao jin , Greg KH , hpa@zytor.com, "J. Kiszka" , jarkko.sakkinen@linux.intel.com, jgross@suse.com, Josh Poimboeuf , kirill.shutemov@linux.intel.com, mingo@redhat.com, mjg59@google.com, Matthias Kaehlcke , Philippe Ombredanne , rostedt@goodmis.org, Thomas Gleixner , thomas.lendacky@amd.com, Thiebaud Weksteen , linux-efi@vger.kernel.org, LKML , x86@kernel.org, virtualization@lists.linux-foundation.org, Alistair Strachan , Manoj Gupta , Greg Hackmann , sedat.dilek@gmail.com, tstellar@redhat.com, Kees Cook , Masahiro Yamada , Michal Marek , Linux Kbuild mailing list , geert@linux-m68k.org, Will Deacon , mawilcox@microsoft.com, Arnd Bergmann , David Rientjes Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 5, 2018 at 10:23 AM Joe Perches wrote: > > On Tue, 2018-06-05 at 10:05 -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,24 @@ > > * -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__ __attribute__((always_inline, unused, gnu_inline)) notrace > > +#define __inline \ > > + __inline __attribute__((always_inline, unused, gnu_inline)) notrace > > Perhaps these are simpler as > > #define __inline__ inline > #define __inline inline Working on this now, going to push v3 soon. I was wondering more about these definitions of inline. Probably want: #define __inline__ __inline__ inline #define __inline __inline inline These are the only references I found to: __inline__: https://gcc.gnu.org/onlinedocs/gcc/Inline.html __inline: http://www.keil.com/support/man/docs/armcc/armcc_chr1359124967692.htm The commit that introduced them was: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a1365647022eb05a5993f270a78e9bef3bf554eb which was an interesting read. I get the feeling that the use of __inline__ or __inline (vs inline) in the kernel may be wrong and their use should be eradicated in the follow up patch set, but it would be cool if others have additional insight. This code in Clang seems to treat them all as the same: https://github.com/llvm-mirror/clang/blob/1a597eeed3579b4320b62ff55150195482545992/lib/Lex/PPDirectives.cpp#L2285 -- Thanks, ~Nick Desaulniers