Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2708324pxa; Tue, 25 Aug 2020 00:32:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO2W0xgtnG6KgHSls5EIdgdvaAVsI25Athdi76vZiHejiW5uF7tYkN56ZdVKGrEWEGDS5Y X-Received: by 2002:a05:6402:b26:: with SMTP id bo6mr9054997edb.104.1598340750819; Tue, 25 Aug 2020 00:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598340750; cv=none; d=google.com; s=arc-20160816; b=NogWhjMgf3CY/d8piOoqJQ1avaGWzgwaVV/qE9xS3r8pF4Twu1c97k3Inb7R15i3Ve DY0ZIapKjildsWbJmzzH2szSezDA1Sj3CCRrB78zUl/eX4xfMYE/ZUyGL4+6QUm9QZu3 R+M99L/LqiL5JqyfNRGeRUpgh0fmQs5SJvbKRZQEFF3rMkQrBoORJY3KtJpej3+WzQSd /a8vLWxRMhv1lnLyB/pMoywY158ZwV5K1Ovpp6PxHkpWvtV48gRfjle7SyEqVqkJeReH OOlKKN2fBcNSvwDFjF9R3vnDmtUVGv+q1WWAZfr+C/BMPbRWMsD+o3pqmYnjn/oVmz0X ZpjA== 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; bh=m7ch7awO6dQw6oGepnCr0LIwMq/ocai7485X8Nfpk3A=; b=cregHLdO/NeVOXTU4rGtHdHdgAaYbafTCOsanINRzzIOIEiEzd1Iq0cOH1q4vSwKa4 1EYdRkVwkpVM5SnhP5P4oiDV8ILOCTCSy1g7tFR8arhyJqmDem0tnpFFP05Gj8zZEYQV q6Nu59Vy2sXm7pbQcaoLIeRcnsnmQdw12Q1PFI+Q7tSUtRZC86vcUGEekVkLbblDUSz9 RYRpbTeyPs3dIGufMe1EcO3BWsNwzNr7e6q3LCy+zQ41Tvn6e74J+b0VFHYsNpKRiBKg gxE4nRarTM+YQF5R4FNuHNgEtAJuH40fJIFco0eMgOZ/vJ9EVuSouT+BKvy5lvFmuqYT MT9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sjOzCSRV; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lz20si4066320ejb.179.2020.08.25.00.32.07; Tue, 25 Aug 2020 00:32:30 -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=@google.com header.s=20161025 header.b=sjOzCSRV; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729415AbgHYHbd (ORCPT + 99 others); Tue, 25 Aug 2020 03:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729194AbgHYHbc (ORCPT ); Tue, 25 Aug 2020 03:31:32 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0874EC061574 for ; Tue, 25 Aug 2020 00:31:30 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id l191so4111386pgd.5 for ; Tue, 25 Aug 2020 00:31:30 -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=m7ch7awO6dQw6oGepnCr0LIwMq/ocai7485X8Nfpk3A=; b=sjOzCSRVvG1BQ9lfblTNWFud2sOL4Z8FoPVLLR2PV/do9wx1dr4Z4Y689ZhRA/v0rY q7pmrtRQPDdQoYCsmHvS4g5iPRU+uFKFKsau302IkCsImMeSerTUn6CxGksc6llIvewO oKXxq3B5dvx40WPTaY7rdYOrfM6QQUFjKMDdcfMbBmseNYJbYc3D8RL00BGtau8VFU7J Vx8KeOuhxOkA7KmNU+W4EpZOZvzXprk9Pku2b0eAOFKHBSi7dN+reeBtCqdu8VKo09iN Cyu6nNg7qs5GoBPqsXrpDun8rD+8Q7rSGKEq6jLFtLAtumZ4VyxrpKjmSzkkG345bhCk TDsw== 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=m7ch7awO6dQw6oGepnCr0LIwMq/ocai7485X8Nfpk3A=; b=tK4eQxhrt/lm+hQgRbXkJkGa0qw1OXQpiF9tJ0LUVhwlpd7qsNsfcolztRQyvIt/yb 8+0Zlgy7ozcAR5xPv14bqiV9JR/sPI8VvwA7jfHn6UYWe7EEXhucg3i84qWR+EwdY+Xj NQ/drq+qIN9uZJX0RNVPHM/4SKEgS7zZHwbaSBuoSubNr1PCJAI2XNAgwWEOGP2aA/LJ iTRxu7dMoVCtNG9d2gYlvVoCp3w4brzwr/YGunzWn4d4M6eHxy/jxNGUByZ1ALRBFgS8 VFDudWMn4P+mLRLGUmXP5UAJjmYUXS6Y7gFHOPmQGIv3uzxLvYbe/gGrK+JZQyNJVlTj MZ+Q== X-Gm-Message-State: AOAM532oHJfXknjdTNGmj5a5RRvAwDprNfn+9CK5OgAgsr9+Wo+ypp83 10rg2L/WbOa2+CcUELsmXH0qV97LD0ChuEupuyJGgA== X-Received: by 2002:a62:7845:: with SMTP id t66mr6315514pfc.238.1598340690018; Tue, 25 Aug 2020 00:31:30 -0700 (PDT) MIME-Version: 1.0 References: <20200817220212.338670-1-ndesaulniers@google.com> <76071c24-ec6f-7f7a-4172-082bd574d581@zytor.com> <20200818202407.GA3143683@rani.riverdale.lan> <20200818214146.GA3196105@rani.riverdale.lan> <20200824173450.GA4157679@rani.riverdale.lan> In-Reply-To: From: Nick Desaulniers Date: Tue, 25 Aug 2020 00:31:18 -0700 Message-ID: Subject: Re: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches To: Masahiro Yamada Cc: =?UTF-8?B?RMOhdmlkIEJvbHZhbnNrw70=?= , Eli Friedman , Linus Torvalds , "H. Peter Anvin" , 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 , 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 , Arvind Sankar 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 Tue, Aug 25, 2020 at 12:10 AM Nick Desaulniers wrote: > > On Mon, Aug 24, 2020 at 10:34 AM Arvind Sankar wrote: > > > > On Tue, Aug 25, 2020 at 12:57:22AM +0900, Masahiro Yamada wrote: > > > > > > > > > To prevent transformation from foo() into bar(), > > > there are two ways in Clang to do that; > > > -fno-builtin-foo, and -fno-builtin-bar. > > > There is only one in GCC; -fno-buitin-foo. > > > > > > Is this correct? > > > > > > > It looked that way from previous experimentation, but... > > > > > > > > > > > I just played the optimization > > > from printf("helloworld\n") to puts("helloworld"). > > > > > > https://godbolt.org/z/5s4ded > > > > > > > > > -fno-builtin-puts cannot prevent clang > > > from emitting puts. > > > Is it because clang does not support > > > -fno-builtin-puts? > > > > Ugh. clang doesn't have __builtin_puts() but it optimizes printf() into > > puts(). It doesn't have __builtin_putchar() but will optimize > > printf("c") into putchar('c'). > > Bah, merely a flesh > woundcompiler bugrather > long TODO in the compiler. > https://github.com/llvm/llvm-project/blob/be2bc7d4cef2edd66c7fb74b70adf62fc68754db/clang/include/clang/Basic/Builtins.def#L943 > > Anyways, give me a week and I'll hack through the rest of them > https://reviews.llvm.org/D86508. Certainly made HPA's point hit home, > that's a lot of functionality to implement or disable in an > environment. > > Masahiro, are you implying that we shouldn't take the > -fno-builtin-stpcpy patch, because Clang is inconsistent? (That can be > fixed.) Even though -fno-builtin-stpcpy works here as intended? > https://lore.kernel.org/lkml/20200817220212.338670-2-ndesaulniers@google.com/ Sorry, the above link ^ should be this hunk (beyond tired, getting up in 4.5hrs for plumbers): diff --git a/Makefile b/Makefile index c4470a4e131f..6a08cdfa58ae 100644 --- a/Makefile +++ b/Makefile @@ -577,6 +577,7 @@ ifneq ($(LLVM_IAS),1) CLANG_FLAGS += -no-integrated-as endif CLANG_FLAGS += -Werror=unknown-warning-option +CLANG_FLAGS += -fno-builtin-stpcpy KBUILD_CFLAGS += $(CLANG_FLAGS) KBUILD_AFLAGS += $(CLANG_FLAGS) export CLANG_FLAGS > > Otherwise we need to provide an implementation of this symbol in the kernel. > https://lore.kernel.org/lkml/20200815020946.1538085-1-ndesaulniers@google.com/ > > Please, pick your poison. > -- > Thanks, > ~Nick Desaulniers -- Thanks, ~Nick Desaulniers