From patchwork Tue Jun 5 17:05:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 10448827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E816960375 for ; Tue, 5 Jun 2018 17:16:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5EA129A77 for ; Tue, 5 Jun 2018 17:16:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C878F29AA5; Tue, 5 Jun 2018 17:16:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6973629A77 for ; Tue, 5 Jun 2018 17:16:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752021AbeFERQn (ORCPT ); Tue, 5 Jun 2018 13:16:43 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:32867 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753369AbeFERFo (ORCPT ); Tue, 5 Jun 2018 13:05:44 -0400 Received: by mail-pf0-f194.google.com with SMTP id b17-v6so1626257pfi.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=VTP0fTxL9Ry86moTmZvsE+kMHDnYFhgWi7RqwBsp74FxCPTiKuVUTEk271NCsSFT5T yaboA1DlXuFBMfTSYXegumHTdsOcdoD2r86AZQGfupREIJjn6aNi8DKc1nd7Q1yQhIJ+ FUTu/YMFOk5Q5w5Nncambmnm5VVO1lg/AKjha3oWKEHbMY+irkcduMypmT8/REsTS2PZ hiVtzn82CPyAaEeqCd93xiaxOY9xzKXv5RTRQzNSXCu9AyD6Q1ssO9tYs3F3dlmIkS/A oEIUT4+n4yTDSfYUHPJ6wRtZILggn4j9hpoqJitMgZDb66dj9Ul9ts2OO5gAmwTyUF5N NFEw== X-Gm-Message-State: ALKqPwf63HLUSFC43QZpQajXgdK0NZwp+rHxDagvmAKs5USzESfHayH9 o2BAHtwOJFvw9tJePHLmynAjjw== X-Google-Smtp-Source: ADUXVKJb645u/RnwjCpBuBwjDAqk335UHJfrKKWqloMMCslEU5uWU+zNL9hz4cOdDa0mNonGb9t6oA== 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-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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))