Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2702741ybe; Sat, 7 Sep 2019 22:32:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBu0hJG9c3EAM0s4zwo5OqBADPuVgs1HZvgrfSBJ8fU3AGXIKLDFJWwTXZ10HRKt/uKIQy X-Received: by 2002:a65:6216:: with SMTP id d22mr14505478pgv.404.1567920737079; Sat, 07 Sep 2019 22:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567920737; cv=none; d=google.com; s=arc-20160816; b=P4OIJt+WVEx9E+RwJzaqZlF6ruaGJOmi5R25MELtUTMJqT/I1PNceRMCOeCCntM4tc 4rpGzUeKq2LdZwFvpZwFD+dLDZJZGkCLJRlSZ+2O0V+RyWAOFk5cCzC1ParYMx+Q6tKD D397poFlrbCKuDzj7HY8iCek0dNOxdsZCRo8jA/YSDK4H/2BwFTXaER3LkzF4UWvUNbW jEzsa09AbykE2g0GH4GP4YHVzFO6Gwuu9nMB1o1MhSLQqgIGo7Az7YJC8hNWjbkMqI4w HXbM6CrpfpSwjzLwbfS3lBEa8emcdIxatz56t9rymT4gLau61xbOwh7GB122k/VfEOsJ h0Zw== 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; bh=xw3RsvJetAvrVEIoF0WjCpgkviQRGLIqU4PyjA3T8xg=; b=EBrDjv18gTfNsDGnEcAaXtB+aI+eCUulsAIUqlA2zlZW7F4NBgk5YxUaJgZ2d84ByG UgFCBaLE32D62oNUK4RACRljSx2CU4a0TERQ5Z/jLd8Lh4ogL4XLgGqi5hgYNRv7UdV2 XG1ng9ESww0yjvcdhzSAreBFkmPSFOeKZJiF0uDqWx7na+As/d0sEB3xDDVJNt7G8r9Y 7i4JUPJGaOifGgQBCdndA+RDDITtjaaYMneogbmwjiv92LP+19Nwbv20MZOdqZJuaTvj Ez6+y13ZRn+Lexpkeq+tUnXCae9wCIn1CkvLgqr3ZsqCm2cqLeex0kZ6xgJf7wdPLEdH OaZQ== 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 u69si9285780pgc.298.2019.09.07.22.32.01; Sat, 07 Sep 2019 22:32:17 -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 S2392036AbfIFWED (ORCPT + 99 others); Fri, 6 Sep 2019 18:04:03 -0400 Received: from gate.crashing.org ([63.228.1.57]:58019 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390045AbfIFWED (ORCPT ); Fri, 6 Sep 2019 18:04:03 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x86M3mnb024175; Fri, 6 Sep 2019 17:03:48 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id x86M3lnA024173; Fri, 6 Sep 2019 17:03:47 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Fri, 6 Sep 2019 17:03:47 -0500 From: Segher Boessenkool To: Nick Desaulniers Cc: Jakub Jelinek , Miguel Ojeda , Rasmus Villemoes , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , LKML , "gcc-patches@gcc.gnu.org" , clang-built-linux Subject: Re: [PATCH v2 4/6] compiler-gcc.h: add asm_inline definition Message-ID: <20190906220347.GD9749@gate.crashing.org> References: <20190830231527.22304-5-linux@rasmusvillemoes.dk> <20190905134535.GP9749@gate.crashing.org> <20190906122349.GZ9749@gate.crashing.org> <20190906163028.GC9749@gate.crashing.org> <20190906163918.GJ2120@tucnak> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 06, 2019 at 11:14:08AM -0700, Nick Desaulniers wrote: > Here's the case that I think is perfect: > https://developers.redhat.com/blog/2016/02/25/new-asm-flags-feature-for-x86-in-gcc-6/ > > Specifically the feature test preprocessor define __GCC_ASM_FLAG_OUTPUTS__. > > See exactly how we handle it in the kernel: > - https://github.com/ClangBuiltLinux/linux/blob/0445971000375859008414f87e7c72fa0d809cf8/arch/x86/include/asm/asm.h#L112-L118 > - https://github.com/ClangBuiltLinux/linux/blob/0445971000375859008414f87e7c72fa0d809cf8/arch/x86/include/asm/rmwcc.h#L14-L30 > > Feature detection of the feature makes it trivial to detect when the > feature is supported, rather than brittle compiler version checks. > Had it been a GCC version check, it wouldn't work for clang out of the > box when clang added support for __GCC_ASM_FLAG_OUTPUTS__. But since > we had the helpful __GCC_ASM_FLAG_OUTPUTS__, and wisely based our use > of the feature on that preprocessor define, the code ***just worked*** > for compilers that didn't support the feature ***and*** compilers when > they did support the feature ***without changing any of the source > code*** being compiled. And if instead you tested whether the actual feature you need works as you need it to, it would even work fine if there was a bug we fixed that breaks things for the kernel. Without needing a new compiler. Or as another example, if we added support for some other flags. (x86 has only a few flags; many other archs have many more, and in some cases newer hardware actually has more flags than older). With the "macro" scheme we would need to add new macros in all these cases. And since those are target-specific macros, that quickly expands beyond reasonable bounds. If you want to know if you can do X in some environment, just try to do X. Segher