Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3321599pxa; Tue, 18 Aug 2020 12:07:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoTkH1LIRiCv/jUVYtovAhbU3JpFUCQD3hbxceIFZU8GxSEly5/meQ6a5WB2BoPVfnrMI4 X-Received: by 2002:a17:906:fcdb:: with SMTP id qx27mr21241622ejb.421.1597777653119; Tue, 18 Aug 2020 12:07:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597777653; cv=none; d=google.com; s=arc-20160816; b=d5UBl4PaZT0PAnTFRmDoF9OJOVjE4e20tDyWCDzbqp3ZEuALZt2vyXqyHrs8pm30as wbA9H3mUUkmRybrbmqfFH4vPEFJ0gGV9KRw/ku/4CDiFbB5pb4QCK7gjXAce9rRTl6iB S914l2sCZb5/YbF0NXQvBz6/QOOyXv1QNiXgCKoLGr5m3UScueHsnS97V9V9ozDSILQL zvvwd719hkuabI4F1HXKRtGLHL3O6x7frcLB+gzmxKdSqGWZgVBGsEiimA4GVZlG7rXQ +FoISIUVixZLjJ5PyesMB1/sGBb0OmTNETVpaax/Otm80CbK3n2wewM+PkheWbW8w86S UViA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature:dkim-filter; bh=cfOAXIuv0d1n/p0ol2GZ1qiMxIvr2XSR2TAgYuI9r3w=; b=mFqcPJU5PK33Ehl38yUuvxoYOU7h5G+Erdtu0cSP1qRB8dUo+CBp6VESHzvFiTjq/D NWFQrQ8knWhXAzg10Iuj9ZZB82ugsxCdLZuZc2eprdwO2lMLhZTzMiul3yVznxC3I/jL 3QWtMbPDifGwekypwCMzn4KPrNlwcGkQBs1pzV7acMv3xpzWbrazYzz0yY4ItVEzaT/H YO8ZrAXxzs8Bbvw0TXLw5M5w93X6ambtY6p5/JUXUKh7ymD569aULTCIl21NCdz2ALnI jmnWN9lUTHg0ohH0gd+KttyygV+QMKDO2S+2ngjKJ1deOhwIxOPI6QfqZV3CiL0eDh0d brJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2020072401 header.b=z6FSMv10; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w15si17196461edl.118.2020.08.18.12.07.08; Tue, 18 Aug 2020 12:07:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2020072401 header.b=z6FSMv10; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbgHRTDx (ORCPT + 99 others); Tue, 18 Aug 2020 15:03:53 -0400 Received: from terminus.zytor.com ([198.137.202.136]:36623 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgHRTDx (ORCPT ); Tue, 18 Aug 2020 15:03:53 -0400 Received: from carbon-x1.hos.anvin.org ([IPv6:2601:646:8600:3280:61e8:d401:1991:f3df]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id 07IJ2bvX2888434 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Tue, 18 Aug 2020 12:02:38 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 07IJ2bvX2888434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2020072401; t=1597777361; bh=cfOAXIuv0d1n/p0ol2GZ1qiMxIvr2XSR2TAgYuI9r3w=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=z6FSMv10XGVilhbjjXXiM0AVWKbJ7Fhzt0md6cIgU1Ohsv04ugdthB2lXdOawFp4G /yIHdNmPHZoJCDgNTXPnJTtAPUBICrzszid60D+pV/4UicZbTfZbrRU0+BZ8RM9wQ7 35+zOHMSIK0jpi7uLcUHBcJWVVBeZ5kJHzSii4DCkNNkgF64tjR5yM5SQnJO97g4e0 TLtVUzXQFjyCrQUlr1DheafRH0JBDtqIMF2aHk+22UqWXF1TCLjag5KLD7muJd8VV/ HrTaRZAfyaXM5tK2841JwFpFsQImabhN3BWsuyiGhtf+WNri0flORDI4/EZYE6HGwH 89XyyKW8H1m/w== Subject: Re: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches To: Nick Desaulniers Cc: Masahiro Yamada , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Michal Marek , Linux Kbuild mailing list , LKML , Kees Cook , Tony Luck , Dmitry Vyukov , Michael Ellerman , Joe Perches , Joel Fernandes , Daniel Axtens , Arvind Sankar , Andy Shevchenko , Alexandru Ardelean , Yury Norov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Ard Biesheuvel , "Paul E . McKenney" , Daniel Kiper , Bruce Ashfield , Marco Elver , Vamshi K Sthambamkadi , Andi Kleen , Linus Torvalds , =?UTF-8?B?RMOhdmlkIEJvbHZhbnNrw70=?= , Eli Friedman References: <20200817220212.338670-1-ndesaulniers@google.com> From: "H. Peter Anvin" Message-ID: <76071c24-ec6f-7f7a-4172-082bd574d581@zytor.com> Date: Tue, 18 Aug 2020 12:02:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-08-18 10:56, Nick Desaulniers wrote: >> >> The problem here is twofold: >> >> 1. The user would be expected to know what kind of the optimizations the >> compiler can do on what function, which is private knowledge to the >> compiler. >> >> 2. The only way to override -fno-builtin is by a header file with macros >> overriding the function names with __builtin, but that doesn't tell the >> compiler proper anything about the execution environment. >> >> So the Right Thing is for the compiler authors to change the way >> -ffreestanding works. > > Sir, this is an Arby's > > There are things all across the compilation landscape that make we > want to pontificate or even throw a tantrum in an Arby's. Would I? > Well, no, I'm just trying to flip burgers or shovel the elephant > sh...or w/e they do at Arby's (I've never actually been; I detest > roast beef). > > Would it be interesting to have a way of opting in, as you describe, > such that your compiler knew exactly what kind of embedded environment > it was targeting? Maybe, but I'd argue that opting out is just the > other side of the same coin. Heads, I win; tails, you lose. That the > opt in or opt out list is shorter for a given project is not > particularly interesting. Should we change the semantics of a fairly > commonly used compiler flag that multiple toolchains are in agreement > of, then fix all of the breakage in all of the code that relied on > those semantics? I'm afraid that ship may have already > sailed...probably 20 or 30 years ago. > >> -ffreestanding means, by definition, that there >> are no library calls (other than libgcc or whatever else is supplied >> with the compiler) that the compiler can call. That is currently an >> all-or-nothing choice, or at least one choice per C standard implemented. > > Yes? > I'm not saying "change the semantics", nor am I saying that playing whack-a-mole *for a limited time* is unreasonable. But I would like to go back to the compiler authors and get them to implement such a #pragma: "this freestanding implementation *does* support *this specific library function*, and you are free to call it." The only way we can get what we really need from the compilers is by speaking up and requesting it, and we have done so very successfully recently; further back we tended to get a lot of language-lawyering, but these days both the gcc and the clang teams have been wonderfully responsive. -hpa