Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2194843imm; Thu, 23 Aug 2018 16:14:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZa270WpS7xgyc+ElpToMWZ6x191/iMDw89wDqlexBA4mSzymVLBWJ2F6zClae9pgCANpJ7 X-Received: by 2002:a63:e756:: with SMTP id j22-v6mr2172608pgk.185.1535066046600; Thu, 23 Aug 2018 16:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535066046; cv=none; d=google.com; s=arc-20160816; b=vjvxNbkgZtq5BWvKMU66E6p0bz4vXT/Kq+1A5qsSXXW6ipq84Rf8V9nP8KS8oJoiBE AxZHhgSGnhso/ErF6VY1lEGbprwOPfF5PTqDFL+G9VQe6WFKFyz89DIkfDSOUJnLpX8e uHcHpD3x0AY6N4i1/Il5aWVEEhF3QmrIjDFgFbCQAMF0qLWKc0Wl4nHb6ebVN5mwVu5Z kNdIsMFuzI4DyTT2iRY/sMC6QZwFqKdSGKpW6hjUvcOFlQyYhb/XVXJ11kHxp6DawFfW /XIQSoRbosFSzlg7Bm48y0AjVKZoV0pT5N24JEJoEWdMstbHYTchgZJ/2wMDD0GoLkAx 15bw== 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=oaMROy64wLWtuDbAbGmS28cfrVWXGVZzot4DKaKf5s0=; b=Xt5OUgbOKkc7ivYNnOD4sYxPBj3EbLcRIV43p5KofBLK3B2UUSX2TCzFSIyfIuXIHU fqK9vaGTiywXBL0MEQBkcKTNVYq09GpmwAlNj1jxH0Dny/gP1WXajRrydU2SW7EHGp2s n2DJdTxAVIAcmxrMih2pAwMNt/Af4LkzmZ/znpuCM17iR7st8wf/fGpoFhjEdLAS8sJO Y/Mn5J8FjtKVQ/Xxzd33C295AO5srGrHJyi1KaVjVx1XjiiKB6orBUfUAV4p6ifPCWyT E0GhjQ3L62TwzZ8s1uG+rr2qjIUrlu1n7caG8S7x7exDelFdeU1uXzLGNBA3UE5A9zcH pLwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PeCvqGp0; 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 6-v6si1135468pgl.517.2018.08.23.16.13.50; Thu, 23 Aug 2018 16:14:06 -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=PeCvqGp0; 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 S1726261AbeHXCo0 (ORCPT + 99 others); Thu, 23 Aug 2018 22:44:26 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38558 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbeHXCo0 (ORCPT ); Thu, 23 Aug 2018 22:44:26 -0400 Received: by mail-pl1-f196.google.com with SMTP id u11-v6so231144plq.5 for ; Thu, 23 Aug 2018 16:12:32 -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=oaMROy64wLWtuDbAbGmS28cfrVWXGVZzot4DKaKf5s0=; b=PeCvqGp0W30Ipf+Lrgxw2Pba/8zNp+gcghFbbrl73Vt7NyNwacW9qRd0PhN9WQgUKW zUlK0zl+kugb/cNtiwKgFmatVrTE3Vay8Nr8DuvacY5+GlxH71+3YaEIlJNs8MSqMvsd a2Yp5PcdDuQVEgLs85YLe4v8yTf6L0OXs/ZynbCjsiISm3188hh7Qj3ZlxBvZCs/uJ+f 8DsBa/BMQ0nHqaukK+D27EdPcWSBXnGn0y7lJ6fgor2adYRc7uKjleNJvHfBXW6ovzO3 HvM2IotwCDhXvL+0CXpRtNLAUQ7hcecKkuAo+L3YRfBKOXbw3EIguqmaOmzYBEyxlN9s B2jA== 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=oaMROy64wLWtuDbAbGmS28cfrVWXGVZzot4DKaKf5s0=; b=Mjwmv/IYDuP4wQpQ9c9JikjOGqsm3SYKr7birZSPtcuofx0YEQDyCdpIRjaoYv3Gi5 mawVVw8TfSWoBPQgMVMryb7gxg3rMYScmdZ37oAUcv/bodf4PXtruN+gmRWko5rVOVqP KV0xy0Q3xA9XEic7tG+Hy1MkK9PUtTZQNXqHn3OOzD7voT+WS+r8UEINNibH8s1/QyrX qMo/BO4GuRfGHMS8ZF5Sgf8LjAFgppjP1UP36/qxyYZt+cBBRTY3NXWhie5NHOnkmm2C bS/UPRBuO4OCeBpeI4VrC5IfWPOIOQOZylhU/2hCwPTXETwoIdITgGqwufMVEqIHiL79 4epA== X-Gm-Message-State: AOUpUlGRjwHnliSjjptPAfzH4vsOZgXr8BZ2e5ODJCHh/re8O3EQtAj2 fcLCajtImbkkN9aBmdqStZd4XgWylKG/bKwo+mYoog== X-Received: by 2002:a17:902:b7c3:: with SMTP id v3-v6mr24400687plz.238.1535065951622; Thu, 23 Aug 2018 16:12:31 -0700 (PDT) MIME-Version: 1.0 References: <20180822233724.110454-1-ndesaulniers@google.com> <20180823002508.GA822@nautica> In-Reply-To: From: Nick Desaulniers Date: Thu, 23 Aug 2018 16:12:20 -0700 Message-ID: Subject: Re: [PATCH] include/linux/compiler*.h: make compiler-*.h mutually exclusive To: joe@perches.com Cc: Kees Cook , asmadeus@codewreck.org, Linus Torvalds , Masahiro Yamada , Jonathan Corbet , Arnd Bergmann , dwmw@amazon.co.uk, LKML , Thomas Gleixner , Will Deacon , Geert Uytterhoeven , Ingo Molnar , Andrew Morton , daniel@iogearbox.net, hpa@zytor.com 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 Thu, Aug 23, 2018 at 2:19 PM Joe Perches wrote: > > On Thu, 2018-08-23 at 14:03 -0700, Nick Desaulniers wrote: > > One reply for a bunch of the various threads, to keep the number of emails down: > > > > On Wed, Aug 22, 2018 at 5:20 PM Joe Perches wrote: > > > On Wed, 2018-08-22 at 16:37 -0700, Nick Desaulniers wrote: > > > > +/* Compiler specific macros. */ > > > > #ifdef __clang__ > > > > #include > > > > > > probably better as > > > > > > #if defined(__clang) > > > > > > to match the style of the #elif defined()s below it > > > > Hi Joe, > > Thanks for the feedback. I always appreciate it. If you have some > > cleanups, want to send them to me, and I'll bundle them up for a PR? > > I'm ok with that change. > > > > > > +#ifdef __GNUC_STDC_INLINE__ > > > > +# define __gnu_inline __attribute__((gnu_inline)) > > > > +#else > > > > +# define __gnu_inline > > > > +#endif > > > > > > Perhaps __gnu_inline should be in compiler-gcc and this > > > should use > > > > > > #ifndef __gnu_inline > > > #define __gnu_inline > > > #endif > > > > Not this case; it's how we get gnu89 semantics for `extern inline` is > > not compiler specific (therefor should not go in a compiler specific > > header). > > It's not possible to know that compilers support what > __attribute__(()) and at what version that support > exists unless it is specified somewhere. __has_attribute: https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute The release notes of GCC-5 mention __has_attribute. https://gcc.gnu.org/gcc-5/changes.html The point of feature detection is that it _doesn't matter_ what version that support exists. Either it does and you can use it, or it doesn't and you can decide whether to stop compiling or there's a valid work around. Feature detection should be preferred to explicit version checks except in 2 specific cases: 1. It's not possible to properly perform feature detection. Language features should not be added unless it's possible to safely check for them. 2. A very specific version of a very specific compiler is broken and needs to be explicitly guarded against. > As far as I can tell, gnu_inline is not recognized by clang. > > https://clang.llvm.org/docs/AttributeReference.html If that was the case, I would not have added it in commit d03db2bc26f0 ("compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations"). https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d03db2bc26f0e4a6849ad649a09c9c73fccdc656 Docs can sometimes fall behind, the lone source of truth is the source code. https://github.com/llvm-mirror/clang/search?q=gnu_inline&unscoped_q=gnu_inline Godbolt is also incredibly helpful for testing various compiler versions: https://godbolt.org/z/uMJ-mo https://reviews.llvm.org/D51190 -- Thanks, ~Nick Desaulniers