Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751523AbdFGF7y (ORCPT ); Wed, 7 Jun 2017 01:59:54 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:33634 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbdFGF7w (ORCPT ); Wed, 7 Jun 2017 01:59:52 -0400 Date: Tue, 6 Jun 2017 22:59:50 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Linus Torvalds , Matthias Kaehlcke cc: Arnd Bergmann , Linux Kernel Mailing List , Andrew Morton , Greg Kroah-Hartman , Ingo Molnar , Thomas Gleixner , Christoph Hellwig , Jens Axboe , Steven Rostedt , Douglas Anderson , Guenter Roeck , Mark Brown , David Miller Subject: Re: [RFC] clang: 'unused-function' warning on static inline functions In-Reply-To: <20170607002840.GA141096@google.com> Message-ID: References: <20170530181306.GV141096@google.com> <20170531235519.GX141096@google.com> <20170606212354.GZ141096@google.com> <20170607002840.GA141096@google.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1677 Lines: 41 On Tue, 6 Jun 2017, Matthias Kaehlcke wrote: > Unfortunately as is the patch doesn't work: > > include/linux/compiler-clang.h:20:9: error: 'inline' macro redefined [-Werror,-Wmacro-redefined] > #define inline inline __attribute__((unused)) > ^ > include/linux/compiler-gcc.h:78:9: note: previous definition is here > #define inline inline notrace > > Another version of David's patch (https://lkml.org/lkml/2017/5/24/878) > first undefines 'inline' before redefining it: > > #ifdef inline > #undef inline > #define inline inline __attribute__((unused)) > #endif > > This works at least in the sense of not causing compiler errors. I > couldn't validate if it actually still indicates the compiler to > inline a function, since in any case 'inline' is only a > recommendation. In the few experiments I did without the patch clang > didn't make a difference between static inline and non-inline > functions. > > The redefinition above could be used to fix the build error, however > it would imply to lose the extra attributes from compiler-gcc.h. > I've followed up with a patch that handles this behavior in compiler-gcc.h since clang defines __GNUC__ as well, so clang gets both compiler-gcc.h and compiler-clang.h behavior. I've tested it, but please feel free to add your Tested-by for more confidence in the change. Linus, who currently maintains include/linux/compiler*.h changes? I see only an entry for a sparse maintainer. I'd happily manage a cross compiler setup if it would be helpful to prevent this type of issue in the future. First question would be if there is a minimum gcc major version intended to be supported?