Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp426416imm; Sat, 1 Sep 2018 07:20:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZUUVv8m4kpyEsrpv1TlrjCxyUzoZiwvtUWH6c6l/qoytjKqBewDOhp7bIHqcdISM6LGPkQ X-Received: by 2002:a63:1823:: with SMTP id y35-v6mr18984797pgl.438.1535811613893; Sat, 01 Sep 2018 07:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535811613; cv=none; d=google.com; s=arc-20160816; b=i+u4TR72tUDMhD4kywLtV5S/4W+LRYh2clYXnU5MTV/pU0N5TUteeDWg9kFZ6Jjool bT3nHfVDgq+PD+Wt+6hVnlMtnVHRjvua2Vp7+M2AlcXkmB47UEtPGh1uRluLanjO3tVO /q/EaHXR4v7Gif8Qkb17djgK54nIb/6KAmgbgg2eS2/9akJnC6NABoZ/YlKuwMlr/o22 mSab8GaPjqlekZso+R+4lCNpJ7sWHKgk2zGv6S6b72y8Kvsv019GMA7ZBqv0S4NCU9bG 2CE8WYMzM1M530ESn9vZ7/ywRoTDPk8uZ8Nn3TozFNz0CbSD6RcN9lPugF+yoVhvP8JV DRQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=rdkGWhenenpL93Q3hr+uDmrfzy5XveNoLiYV/UlRbxI=; b=b8DugCfvdNGbuLrBkIRMjES8+S2W7Ho0aY0/GeIDXNR8SYcDnvAXqKBo0dLFvRR55V BdzA7prOuyQmPGTbpkf3xW2ypyNaWKg7yHaaNT1mQv9dg3auB6llQjvLIH61jRHKCaDG 5NGcoYO9hf6As790aSqKXjrhzZmBiwpQjP3sd4q0g7Hz9wHiBUYQMc382AEFqsmi2eR5 yacmUfnldZeffr3v36bWvhrU+9eEAynHhaDGn3Y+bJ4HqrfcJ5M5w4GUxrklB/aGODc/ o0VGlALfIFgeMC+pRz2ZvetRbbtCWolF2IfWvYmgt7kO3mv9gVBU+lJIzFJrYTFPhGZT cTgA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d31-v6si12916132pla.479.2018.09.01.07.19.53; Sat, 01 Sep 2018 07:20:13 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727286AbeIASaT (ORCPT + 99 others); Sat, 1 Sep 2018 14:30:19 -0400 Received: from nautica.notk.org ([91.121.71.147]:55304 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727057AbeIASaS (ORCPT ); Sat, 1 Sep 2018 14:30:18 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id BCB5EC009; Sat, 1 Sep 2018 16:18:02 +0200 (CEST) Date: Sat, 1 Sep 2018 16:17:47 +0200 From: Dominique Martinet To: Miguel Ojeda Cc: Linus Torvalds , linux-kernel , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Nick Desaulniers Subject: Re: [PATCH 7/7] Compiler Attributes: use feature checks instead of version checks Message-ID: <20180901141747.GA20900@nautica> References: <20180831170514.24665-1-miguel.ojeda.sandonis@gmail.com> <20180831170514.24665-7-miguel.ojeda.sandonis@gmail.com> <20180901101430.GA21877@nautica> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Miguel Ojeda wrote on Sat, Sep 01, 2018: >>> +/* >>> + * To check for optional attributes, we use __has_attribute, which is supported >>> + * on gcc >= 5, clang >= 2.9 and icc >= 17. In the meantime, to support >>> + * 4.6 <= gcc < 5, we implement __has_attribute by hand. >>> + */ >>> +#ifndef __has_attribute >>> +#define __has_attribute(x) __GCC4_has_attribute_##x >>> +#define __GCC4_has_attribute_externally_visible 1 >>> +#define __GCC4_has_attribute_noclone 1 >>> +#define __GCC4_has_attribute_optimize 1 >>> +#if __GNUC_MINOR__ >= 8 >>> +#define __GCC4_has_attribute_no_sanitize_address 1 >>> +#endif >>> +#if __GNUC_MINOR__ >= 9 >>> +#define __GCC4_has_attribute_assume_aligned 1 >>> +#endif >>> +#endif >> >> Hmm, if this is in this file and not compiler-gcc, I am not sure about >> using GNUC_MINOR without checking the major -- I have no idea what kind >> of versions e.g. icc will use (or what attributes ancients version of >> clang or old icc support, actually) > > The idea here is that all non-gcc recent compilers that we may care > about support __has_attribute,so if we are inside the #ifndef, we > *have* to be gcc < 5 (see https://godbolt.org/z/NQFdsK). That really makes me want to have these in compiler-gcc though :) But I guess I can also understand wanting to include this file as early as possible, although I do not think any of the compiler-specific headers use any of this they could eventually want to override something from it at some point... Leaving it as an open question, feel free to do as you prefer here. > By the way, do you know if there are some public docs on the > attributes supported by icc that we can link to? I couldn't find > anything in a quick search, both in google and in the icc's > "Compatibility" pages... I'm honestly not using icc much, I just have access to machines where it is installed... Actually, now I'm looking there is some html documentation installed along with icc, but it does not seem complete; instead it points to software.intel.com ... which has _some_ documentation on attributes, but is missing a _lot_ of them, see : https://software.intel.com/en-us/cpp-compiler-18.0-developer-guide-and-reference-attributes I saw that a lot of these attributes were defined as #pragma first for icc and had hoped to see something like 'alternative forms' in the pragma documentations but there does not seem to be anything there either... Afraid I won't be of much help there. (from another reply) > Because of that logic, I tried to simplify as much as possible all > existing things (e.g. assume_aligned by removing __CHECKER__) so that > they could be moved to compiler_attributes.h. In a way, > compiler_attributes.h defines some extensions to the C language that > all code could use anywhere (actually whether we can move them out of > __KERNEL__ etc. is another question) (very good question, though! Figuring out how to share these with the tools/include/linux/compiler* instead of having an old copy would be a good start... For another patchset though) -- Dominique