Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2880511rwb; Mon, 5 Sep 2022 03:05:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR4lcOaSaqzjO6TQ/2MgIxd5+mQtpLS2uDvW7fRzZ3tmqBMmWdJtPwAeA3x6DFpnPxbeEo9C X-Received: by 2002:a17:90b:4a06:b0:200:8997:c292 with SMTP id kk6-20020a17090b4a0600b002008997c292mr767451pjb.145.1662372336677; Mon, 05 Sep 2022 03:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662372336; cv=none; d=google.com; s=arc-20160816; b=Q8oSAUC8m1Z7oCorFW2orPOSCoPBw2IjYnw0BBNklMRvBJn0FRutGWdP1GmbP24BtW r2j3uImOJjw4IKcVklkvUs6wNzGtwQkgXWo2TrSnxzE+oHg2DAqVlAwWTcQHjGibTKVp fb8uNSuVJ/9ePQRxuWtcdOse3f1YGC/F7Unim8qav9nOvMCCQvv5WICIseB6ogJonx9o yGOd12xYw6mLIlQ/6qEKk6Qy4+0fP46DntslUskm1F7IG1J4En9DmGMp29ROm+EYexoJ lB3zTCb+b64d3/kCn8GfLFeuRZYuF0t2rxxODPRu+RoUWXQrtBFjYdu326bZ4f2/Hbls Nlkg== 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:dkim-filter; bh=4BbPbSzeFLnJFI+hMdkPwj9aQwOKx7JySs0IWqZPQ0E=; b=jd6RstFrf3PEPGQrjEXfMMRtCZJhIv1GPxZiDFPkm1yUwoG67X0NNh5w+RLMcMhPTt 9jtV9+L4sYB7XlQ/cWlm/akJT2EuHkC1Oof6IHvS/P/OZpungME+5xQABJcHG1xR27VI y/yV0gq/gMv3ancBLUNFItbaM42E2n3jjmEd2W2uzoX5D8POCes+B5Ih9a5zWYvkRNX3 EnoHo0Q2S27tlJl+fMf/bv1R24yjWfaL63hUmda0X1cZSVsDvKc8OomDDtrk9prjSfCN PtfkWic1JsUTQcs+x5tTL2N7YiccqdYsNimSVrn9qljLlf0AmFFTIu0Fjgam7F738foc S/RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="K/mdEeMR"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o21-20020a17090aac1500b002008429d42bsi743420pjq.119.2022.09.05.03.05.25; Mon, 05 Sep 2022 03:05:36 -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=@nifty.com header.s=dec2015msa header.b="K/mdEeMR"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237697AbiIEJK0 (ORCPT + 99 others); Mon, 5 Sep 2022 05:10:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237161AbiIEJKX (ORCPT ); Mon, 5 Sep 2022 05:10:23 -0400 Received: from conssluserg-04.nifty.com (conssluserg-04.nifty.com [210.131.2.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CF8B2529E; Mon, 5 Sep 2022 02:10:20 -0700 (PDT) Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (authenticated) by conssluserg-04.nifty.com with ESMTP id 2859A5GC022169; Mon, 5 Sep 2022 18:10:06 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com 2859A5GC022169 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1662369006; bh=4BbPbSzeFLnJFI+hMdkPwj9aQwOKx7JySs0IWqZPQ0E=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=K/mdEeMRVWUJ43uBAY659SEzldpJrYqmzDMddLj0aB0c56GoecW80PmlDDWYOBpfL 9bHh6vsGCFA/d53NC+q3BwVLoFvzDrUKtMgyA3z5iGlNJBpLEaIcyQ0Of/foUdMafK zUOic0nRiESCOt98VhDySaaAXwmn4LntcT8541AJv/6pNJrCT6OZinJjDcgbCVlaNR okCu1UQFRXhzxW4aTnxWqabtQZrmYjiMBpjnShwT8s7LKypx4NZE24sUBg2m2v+Ip7 IDLxZ4oZmMkjpIUx3qQ9CZsDLW2VJES/duDlV3G+bE/05uV9/obzK5bLWM5Uuq4Mxx A1L8Hj+SAmV0w== X-Nifty-SrcIP: [209.85.161.52] Received: by mail-oo1-f52.google.com with SMTP id n11-20020a4aa7cb000000b0044b3583d373so1400849oom.2; Mon, 05 Sep 2022 02:10:06 -0700 (PDT) X-Gm-Message-State: ACgBeo115IqWZ9mykR52DDHBrO/JPysEI0nBwxkvP5uKVTKQNwQRiLIx mvrJpqamLlada7KVhSKKuOZ2J1mdtyNFf/WG/xA= X-Received: by 2002:a4a:9789:0:b0:451:437b:cc58 with SMTP id w9-20020a4a9789000000b00451437bcc58mr6570173ooi.96.1662369004999; Mon, 05 Sep 2022 02:10:04 -0700 (PDT) MIME-Version: 1.0 References: <20220831184408.2778264-1-ndesaulniers@google.com> <20220831184408.2778264-3-ndesaulniers@google.com> In-Reply-To: From: Masahiro Yamada Date: Mon, 5 Sep 2022 18:09:28 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/5] Makefile.compiler: Use KBUILD_AFLAGS for as-option To: Nathan Chancellor Cc: Nick Desaulniers , Michal Marek , Tom Rix , Linux Kbuild mailing list , Linux Kernel Mailing List , clang-built-linux , X86 ML , Dmitrii Bundin , Fangrui Song , Alexey Alexandrov , Bill Wendling , Greg Thelen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL, T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, Sep 1, 2022 at 4:53 AM Nathan Chancellor wrote: > > On Wed, Aug 31, 2022 at 11:44:05AM -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. > > Now that I am looking closer at it, where does that '-Werror' come from? The related commit is c3f0d0bc5b01ad90c45276952802455750444b4f The previous discussion with Arnd is https://lore.kernel.org/linux-kbuild/20170314213724.3836900-1-arnd@arndb.de/ > For cc-option, we add it to elevate clang's warnings about unused '-f', > '-m', and '-W' flags to errors so that we do not add those flags. > However, I do not see '-Werror' in as-option. I am going to assume it > came from CONFIG_WERROR, as I believe Android has that turned on by > default. CONFIG_WERROR is added to CFLAGS. But, I guess it is more correct to do likewise for others. (https://patchwork.kernel.org/project/linux-kbuild/patch/20220905083619.672091-1-masahiroy@kernel.org/) > I think that is the real problem: without '-Werror', the only > error that should come from as-option is when an option isn't supported > by the assembler, as clang will still warn but those will not be fatal > but with '-Werror', those warnings turn fatal, causing all subsequent > as-option calls to fail. Presumably, it is correct to add -Werror to as-option as well. We have no reason to add it to cc-option, but not to as-option. I also believe '-x assembler' should be changed to '-x assembler-with-cpp'. As I mentioned somewhere before, our assembly code (*.S) is always preprocessed. There is no *.s file in the kernel source tree. So, '-x assembler-with-cpp' matches the real situation. One interesting thing is, clang does not warn [-Wunused-command-line-argument] for *.S files. $ clang -fomit-frame-pointer -c -x assembler /dev/null -o /dev/null clang: warning: argument unused during compilation: '-fomit-frame-pointer' [-Wunused-command-line-argument] $ clang -fomit-frame-pointer -c -x assembler-with-cpp /dev/null -o /dev/null The root cause is we are using '-x assembler', which never happens in the kernel tree. To sum up, the code I think correct is: as-option = $(call try-run,\ $(CC) -Werror $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /dev/null -o "$$TMP",$(1),$(2)) > Do not get me wrong, I still believe this is the correct fix but I think > it would be good to describe exactly under which conditions this is a > real issue in case we ever have to revisit this. > > > 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 > > Regardless of changes to the commit message: > > Reviewed-by: Nathan Chancellor > > > --- > > Changes v1 -> v2: > > * Split off changes to arch/x86/boot/compressed/Makefile into parent > > patch, as per Masahiro. > > > > scripts/Makefile.compiler | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > 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 > > -- Best Regards Masahiro Yamada