Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp688853rwe; Fri, 26 Aug 2022 12:21:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR5POEz2a63SEQZN2rHPhsa4w8qHLz5odIQ2zhUDKYkaTJbOTVnRsWHAPDmCfs4bl2yLxozZ X-Received: by 2002:a63:4512:0:b0:427:bc0c:4d5a with SMTP id s18-20020a634512000000b00427bc0c4d5amr4514153pga.114.1661541668726; Fri, 26 Aug 2022 12:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661541668; cv=none; d=google.com; s=arc-20160816; b=SvMnjWbn4TWvKUTM9cTR6EYWL0/Y9c6FvuaHYFk/sqLt6CCcOC31ZgEDdf555Evu7o 0smmvVfoms96ubNsB/v5W/pA1F39ZY7SZUZ+hcCOVn3wvdZB940LurezNuRBhBfrA+Tw 8OYQLr4saTALV3icOWOkWWuKY2JPJiUZ2AhT0v5mXGAuSlxRutXSpOHNSNPc8Y6Z4/Oy PyJelmGv4Nggvnv1B+UL1IBbwQIf/F7ktstFJ8k/E26qpZm4ywdxU/fU3c20GVZ2KjSf fF0oxd2xp52U1gV63fmLiI4bCOKHL8iXys1z4cwLfl/ms+xNUgT5Y1diRB9FyS9EJ/0r 43/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4aLkJX7cunHtM95EA9sb2bQZzhjKdoxn0b8NHuPsFR0=; b=v30G2kHXdJ5/SMJXUMruLP4fnYXxbOinrwbyB7kEjJoX0qMOizN3I/uyZhwsyu4LAj JdYIoOQ5pTKo4ObIf3c/0MfCQkOLK+7fdStxq8la6FVxuQSkeKMKwIujN5TqtB4wSCDH qFvZmcXMBspV3HzOdASiHP8NCz0vpw6RTzR8XYnzRPEulUDslsJ9DBYNTQe/R74FGK6/ s8hWwFcK6ATbOmGDWCBbeT2xXMhrnkcIggcvJ3xaXPwkszSVM3H9EBfms4e7S4kpmlWo IT10ZuiXU5YW8JLz+nFv5qEs/914IlmgaYPair8kYaUMmIe3DJl/SPDnBU8ujI1PUj86 ew3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="L0/i8Wip"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v189-20020a6389c6000000b0042b8282023esi1301869pgd.274.2022.08.26.12.20.52; Fri, 26 Aug 2022 12:21:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="L0/i8Wip"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1345217AbiHZSi0 (ORCPT + 99 others); Fri, 26 Aug 2022 14:38:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345169AbiHZSiA (ORCPT ); Fri, 26 Aug 2022 14:38:00 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66D7D6113C for ; Fri, 26 Aug 2022 11:35:04 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id s6so3042394lfo.11 for ; Fri, 26 Aug 2022 11:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=4aLkJX7cunHtM95EA9sb2bQZzhjKdoxn0b8NHuPsFR0=; b=L0/i8Wip3YLAM3uYJCwNd1DWXNAdOUnJwUT2dG612DDLpJ+3YZhuHltz7xznpTH9U2 GWC8IwUPt+IApjCrjxi2jZNwH98Lvma8HMhMNrc4H+dCpbsZpvutNVa79X9n2Gjx0LT0 b9WD+ih6oaaJiQnXQs2aB0H0fqGnIxPuvpdhlqQR3pevS9RC0wnHyoo85R5qWNg2v7NY zC88PKdPO+k2QY668NzdEmAt3F+bnrn+UXJQpL/GYHjMFMxw/uiy0TXVflSclJagtiq8 ir16es+xHOWCet/uE2FskJ34y0RKe+jT78jbM8rU0o4AZCc7AdmblmHv196v25iKCG2K /Btg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=4aLkJX7cunHtM95EA9sb2bQZzhjKdoxn0b8NHuPsFR0=; b=5ZgIkKyjb+afYpJUdBIjkyWznuU1+IoyKSoYmt4t/Xql1ICEb78zySreD3jImuJaKn r3Pv8tRmmAB80d4/6MGoVrb2N9hXFbvy9ZPCSKw2yuQq7P36scXZw2H5Ex4eWvKn3Pvw QrIoXFz29S3I+uFN47xQ0s1/2qdIF2E1xZqpwJNEJ7upsIg0uMyQKOQ0Y7W9lJkRIQNq Q2RjQBYl5UZriHG42AbinSTfEIPvosYFDuomxtnzO/Zat3pWdsj3jsBzWbmckYcscrHb IIWSSJ5GxxtZrE5AsYRenbQtPQ8a1wfvmnlYtnHY6ja+rRS/bqeLGfpE9SYjKQj03+5X gzoQ== X-Gm-Message-State: ACgBeo1EBIh5853O/p54vPtav4H3LJnfxNTBDRmMdO0THdBo085UNOtW etDboCB3IADdoyhlnpLPWcFYF1A3vsPyn48+hmUdRw== X-Received: by 2002:ac2:4f03:0:b0:48a:6061:bd8e with SMTP id k3-20020ac24f03000000b0048a6061bd8emr3230009lfr.647.1661538901687; Fri, 26 Aug 2022 11:35:01 -0700 (PDT) MIME-Version: 1.0 References: <20220826181035.859042-1-ndesaulniers@google.com> <20220826181035.859042-2-ndesaulniers@google.com> In-Reply-To: From: Nick Desaulniers Date: Fri, 26 Aug 2022 11:34:50 -0700 Message-ID: Subject: Re: [PATCH 1/3] Makefile.compiler: s/KBUILD_CFLAGS/KBUILD_AFLAGS/ for as-option To: Nathan Chancellor Cc: Masahiro Yamada , Michal Marek , Tom Rix , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, x86@kernel.org, Dmitrii Bundin , Fangrui Song , Alexey Alexandrov , Bill Wendling , Greg Thelen , Arvind Sankar Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 26, 2022 at 11:21 AM Nathan Chancellor wrote: > > Hi Nick, > > I think the title would be a little more readable if it was: > > Makefile.compiler: Use KBUILD_AFLAGS for as-option Thanks, yeah that looks better; I expect a v2 of this series will be necessary. > > On Fri, Aug 26, 2022 at 11:10:33AM -0700, Nick Desaulniers wrote: > > as-instr uses KBUILD_AFLAGS, but as-option uses KBUILD_CFLAGS. This can > > cause as-option to fail unexpectedly because clang will emit > > -Werror,-Wunused-command-line-argument for various -m and -f flags for > > assembler sources. > > > > Callers of as-option (and as-instr) likely want to be adding flags to > > KBUILD_AFLAGS/aflags-y, not KBUILD_CFLAGS/cflags-y. > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1699 > > Signed-off-by: Nick Desaulniers > > --- > > arch/x86/boot/compressed/Makefile | 5 +++-- > > scripts/Makefile.compiler | 6 +++--- > > 2 files changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile > > index 35ce1a64068b..fb3db714a028 100644 > > --- a/arch/x86/boot/compressed/Makefile > > +++ b/arch/x86/boot/compressed/Makefile > > @@ -48,8 +48,6 @@ KBUILD_CFLAGS += -Wno-pointer-sign > > KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) > > KBUILD_CFLAGS += -fno-asynchronous-unwind-tables > > KBUILD_CFLAGS += -D__DISABLE_EXPORTS > > -# Disable relocation relaxation in case the link is not PIE. > > -KBUILD_CFLAGS += $(call as-option,-Wa$(comma)-mrelax-relocations=no) > > KBUILD_CFLAGS += -include $(srctree)/include/linux/hidden.h > > > > # sev.c indirectly inludes inat-table.h which is generated during > > @@ -58,6 +56,9 @@ KBUILD_CFLAGS += -include $(srctree)/include/linux/hidden.h > > CFLAGS_sev.o += -I$(objtree)/arch/x86/lib/ > > > > KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ > > +# Disable relocation relaxation in case the link is not PIE. > > +KBUILD_AFLAGS += $(call as-option,-Wa$(comma)-mrelax-relocations=no) > > + > > Commit 09e43968db40 ("x86/boot/compressed: Disable relocation > relaxation") added this to address > https://github.com/ClangBuiltLinux/linux/issues/1121, is it correct to > move it to only being used for the .S files in arch/x86/boot/compressed? + Arvind Hmm...that makes me think we might need two different as-option flags; one that does use KBUILD_CFLAGS, and whose result is meant to be added to cflags-y, then another that uses KBUILD_AFLAGS and is added to aflagsy-y. (My patch 2/3 in the series would use the latter) Let's see what thoughts Masahiro has. > > > GCOV_PROFILE := n > > UBSAN_SANITIZE :=n > > > > diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler > > index 94d0d40cddb3..d1739f0d3ce3 100644 > > --- a/scripts/Makefile.compiler > > +++ b/scripts/Makefile.compiler > > @@ -29,13 +29,13 @@ try-run = $(shell set -e; \ > > fi) > > > > # as-option > > -# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) > > +# Usage: aflags-y += $(call as-option,-Wa$(comma)-isa=foo,) > > > > as-option = $(call try-run,\ > > - $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) > > + $(CC) $(KBUILD_AFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) > > > > # as-instr > > -# Usage: cflags-y += $(call as-instr,instr,option1,option2) > > +# Usage: aflags-y += $(call as-instr,instr,option1,option2) > > > > as-instr = $(call try-run,\ > > printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) > > -- > > 2.37.2.672.g94769d06f0-goog > > -- Thanks, ~Nick Desaulniers