Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1182697imm; Tue, 5 Jun 2018 10:17:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKdhahVJRtyWlPZmoN1dkuMRE9v5h9H5ev6I1Li5Dvye6TZKgk1Peg4kgfpMnJdUNIvubad X-Received: by 2002:a63:3e83:: with SMTP id l125-v6mr22203866pga.355.1528219040554; Tue, 05 Jun 2018 10:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528219040; cv=none; d=google.com; s=arc-20160816; b=GUBYBX/zKHm85IArB3HNM2+g1z1l8NzZTdqLVECqXsTS1dE5I3akZoq1N8O1gRqSHg WZSR4+ndAR8OiJro7hPMFs20nJgjXk7Lzftd4lxs6jk0RPYdCJ2+EfpqpkY52I4iLhmf 7twXCGMChGPED0ko6aWFdC5z18Gmalx6kOMJ0L80gIgXUM27g+eGLxuCkAMa7sbupntn JhCZnLT98d1oPJ9bFKaKIk5c4aAg3tHP8YNNbpQ01jzZmJg6OLUyKEEvgBm4SsHgCZdZ 3Eyybu60zdAtuti7ncMi831OdypgtcCSbrKPkICAMaVcktJHdP648Fa1ggdrRjDft45J RcxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=bQhJ95+7QRtQAIkdPM9qpken7/LdoUb1ruX9prBXNSE=; b=KI+77rs4erLMxXRnOUoaUPB0sa/lDcCyDfhfiRRNH0bOPmGTNbc0qqUqfBsQDBCbeq FkmzbLu0vaK97zxcOH6nn3RROTp9MrRpFri2Y/mSAlDKuRZERO7Bwsf+mPHJ2irD2SwB 2xGBvfa2JL1U+LnHTkS6oyxRkp3M+PrslA32CxA5S7KbgB2lEolPRsDjbu2XLIGBe0xK S1WSAZ4xi44P8QES9TFRm/RFEgXF7H7OEzadJXJ/OAuHG5hr5bophoS3/HkjsBMIF7os fJ4rgXaB+uuhZGj6bPAYv21nN7TDM31HwGNnGI3vYzcpGDQA+VqlJrA5rhrjMkKt0lA2 VNHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dZ0a9Cf3; 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 u22-v6si26157339pfg.62.2018.06.05.10.17.06; Tue, 05 Jun 2018 10:17:20 -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=dZ0a9Cf3; 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 S1753305AbeFERQo (ORCPT + 99 others); Tue, 5 Jun 2018 13:16:44 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:32866 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753366AbeFERFo (ORCPT ); Tue, 5 Jun 2018 13:05:44 -0400 Received: by mail-pf0-f193.google.com with SMTP id b17-v6so1626254pfi.0 for ; Tue, 05 Jun 2018 10:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bQhJ95+7QRtQAIkdPM9qpken7/LdoUb1ruX9prBXNSE=; b=dZ0a9Cf36OnBjbbUpqurLxeUms5BAAhKd+256t9Ck5rSvj4CYp3bnXlKcZTAzN9mYV Dt7JcceTi2icB/8zK2QYONnJEcWkkd2N23PHGxfCkF0jJdK8jmg1amhmR+U+ItuHxk4v IaQ7+1iX9xGLonaZ4neO0tTqRiXxbHox3SveXGGAD2V3dGEwcw/isHY0trzrufvAGIS4 05YRbSiufHbCi5wh0DxJc1SQkgbgiWWvNfAd/fPzxnT4MDYzn7jM4SDnF9+f/LNiUjHN omhuW9hE5+ZJOheAmBeRUoE5oWXyejL0hLeqNjuG2jC+FaQSnP+v3DHZa99pz9Kx9vTn 5N1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bQhJ95+7QRtQAIkdPM9qpken7/LdoUb1ruX9prBXNSE=; b=H59z2J6Wnoa6sSHB4lbJaMXmUJ0EdnLiltx6Rn75twA5p3giNSpRd2XxwcoLunJ2gF +s35hpjSYHglXMAFuwJUIyLocd6RmxBhvZXbGXEemKYMsqYFO1P/CvIRWnVqhRkNr+J4 2sDyE5Ssl62aqn4/u5LmCVEQiVU+b42ebj4F4kVyPjRcNQXsXp0YmlbnvKhRpoagAJ2l 42em1r+osu8NkkSDvkJgUAGfUHzwoy+usJQGp1GFysmeQlHBoA5OqHlp6kJaxSwAVN6A YQmu59veeaA+oeSshHLsVq2OoOUt+0T9sSoIf2OUtR04MjCesr1MhZ6heqm0ENL/iBWv ZXsQ== X-Gm-Message-State: ALKqPwc/aHcllNgDzpfeM3OpeidUnv1Z1C0Fp10MHb28xnS1Ted0Vark xxp/oMN6lZkCFV4T7MDAtyOirA== X-Received: by 2002:a65:6031:: with SMTP id p17-v6mr21989984pgu.311.1528218343402; Tue, 05 Jun 2018 10:05:43 -0700 (PDT) Received: from ndesaulniers0.svl.corp.google.com ([2620:15c:2a3:1:d33:166f:5b79:14b3]) by smtp.gmail.com with ESMTPSA id r27-v6sm27280090pfg.94.2018.06.05.10.05.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jun 2018 10:05:42 -0700 (PDT) From: Nick Desaulniers To: akpm@linux-foundation.org, ard.biesheuvel@linaro.org, aryabinin@virtuozzo.com, akataria@vmware.com, boris.ostrovsky@oracle.com, brijesh.singh@amd.com, caoj.fnst@cn.fujitsu.com, gregkh@linuxfoundation.org, hpa@zytor.com, jan.kiszka@siemens.com, jarkko.sakkinen@linux.intel.com, jgross@suse.com, jpoimboe@redhat.com, kirill.shutemov@linux.intel.com, mingo@redhat.com, mjg59@google.com, mka@chromium.org, ndesaulniers@google.com, pombredanne@nexb.com, rostedt@goodmis.org, tglx@linutronix.de, thomas.lendacky@amd.com, tweek@google.com 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 Subject: [PATCH v2 1/2] compiler-gcc.h: add gnu_inline to all inline declarations Date: Tue, 5 Jun 2018 10:05:31 -0700 Message-Id: <20180605170532.170361-2-ndesaulniers@google.com> X-Mailer: git-send-email 2.17.1.1185.g55be947832-goog In-Reply-To: <20180605170532.170361-1-ndesaulniers@google.com> References: <20180605170532.170361-1-ndesaulniers@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Nick Desaulniers Suggested-by: H. Peter Anvin Tested-by: Sedat Dilek --- include/linux/compiler-gcc.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index b4bf73f5e38f..7827bdf0e5e9 100644 --- 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 #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__ __attribute__((unused, gnu_inline)) notrace +#define __inline __inline __attribute__((unused, gnu_inline)) notrace #endif #define __always_inline inline __attribute__((always_inline)) -- 2.17.1.1185.g55be947832-goog