Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5168685rwb; Tue, 6 Sep 2022 20:46:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR5fHjM85JcNUXuBos8SEKaCa9L+LY24qa2Jw8ZQyRTh05R7NkykWQn3ALQK8fzO5XG7qB5w X-Received: by 2002:a17:902:e80b:b0:176:de36:f5a8 with SMTP id u11-20020a170902e80b00b00176de36f5a8mr1895070plg.127.1662522371143; Tue, 06 Sep 2022 20:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662522371; cv=none; d=google.com; s=arc-20160816; b=RWSjKm4tG4DqtS7DgUY+ZYzy5Pvckcln6M22XrHAX57ozrRYL0bdQ8kjyYAkw0ZgjR DBqmJeqQ3nRUQy+Ow68lc9YHlmpdGbCxNMP2j4SLXiQ6iAmM8V3bgu3C/Z5ZozzUmPXG d2o9z8PIIGSdLurd0wcnmMiSK/P9D5OQ2y6gnrnruWjkGjnGgIAwcqq0NcCV4zQMMdOt V/bOXzdaG0ob/8lleGJaqK5H1eV1yq/BV6D1B/RUt8U2IxAKimmLiLOpoNx8tc/FOath jXZCZY10nqxtjpG3ovmG+g/nSMRLz6HL7eMQld4GkvTVmAwzH0eMpiCK8zJqapndbRos d0ig== 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=aUfdL0h8QoOM6NYh1e5obcpE+RfHCz5rvFmppJngHvA=; b=ouMRnGcCrinuSypGeGl4hAPuyKtRW8VE4agmGs0Pxd2YCH8lysaif89hAYhADayc+0 NOtAoQUL3Yw4sCApnIIa1FE/cdduZ6JIsERozQUkfjcUorYhkO4DYNQY15Y6SewRQFwD 0XzHHzKzfYH2UEPDkdTbbxlW/r4IGCjrw+hax5ClPcPrHQwO7KSNqQH1Z4V2uVzf17dw I0czaqbIpy4cqPE6b0QHTIlySaZlg9z140diWuKtYEeI7Bn7SpsK6ju/uonAQrBxQ4Q/ INVV0N6i/hiMVy289BUVbnQTN4r1Ptwz5ruxemefQOocnIpLrQ/WWOaSAgVpaHJwWfjF 5nmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=KHQsCzY7; 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 j15-20020a170903024f00b0016f1781307csi13132218plh.303.2022.09.06.20.45.58; Tue, 06 Sep 2022 20:46:11 -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=KHQsCzY7; 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 S230032AbiIGDM7 (ORCPT + 99 others); Tue, 6 Sep 2022 23:12:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbiIGDM5 (ORCPT ); Tue, 6 Sep 2022 23:12:57 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AAD0923D3 for ; Tue, 6 Sep 2022 20:12:55 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id e20so18231826wri.13 for ; Tue, 06 Sep 2022 20:12:55 -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:subject:date; bh=aUfdL0h8QoOM6NYh1e5obcpE+RfHCz5rvFmppJngHvA=; b=KHQsCzY7yTO3vvx/cyNUaGgEO5PXwRMVx66LyTgH51awzIcZcZZCOTCsDqttKMNV7Q BPSGYKQV/VrU0WTiCKhJgiIKmf0gqYyc0uQk6UjduBR66cv1eHJZ5pnLUWJNLzsvFnOH 0nOzTtct9mO9njg2xFJHzO7qsjvHEnzUxCTgscZpuhzzCl2r/19Q8HxilmGnb8u15NDC +73+WRsR8Bxs2b8Vn/C8saNGHD0Q8+msyHaGAtqnuProdEZAx2WCKOpAtm2fE1xyJkvK edFQ7z3EFnP8pzcUF9TJCPjZpo2oj/chmIvKa9rLmFdUGBT/KyBERR0ROmpPVgYaHTBt ceIA== 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:subject:date; bh=aUfdL0h8QoOM6NYh1e5obcpE+RfHCz5rvFmppJngHvA=; b=hG61vGhQL97xsXb52+gmEXOKvG3IpAhuOMCXeoS81pfwf3x9UDYbDcvXuOSqwXXOO7 aVcyjl8ZM5ha6XyN2e/K+M9hjc72bhXHirNk3g4lQb3PplvHbtS7sMIZbzRnzYJHk/kN comaK0hJ8bRCZG5g4hQFqQ1asYOFmPmiWp6LtbvB/SAaTIC8lJ+iNq3+L1Yoj8gPabYE 1ETKBtjd79nQvq4Jj1mOjfqLwId+r5AIlCaucrcrQOt+2Oih4JqXhotSfalVbOlwTfHa pnQGCaYnjD4lygNZUsMZR4CG1xso6PaCbNwFZxf3epobQ1YxAOBO1mjQ8g9rqtHWOoGH ZbrA== X-Gm-Message-State: ACgBeo19A/McP9ZWVNFgftGY9QrjQIrRXHPZQELdHlmRvIzwGBGQ5EYx EKLnGlyxjOzclqly9qjsdSc561woUXo+URg7zuf/KA== X-Received: by 2002:a05:6000:10cf:b0:228:df93:a9b1 with SMTP id b15-20020a05600010cf00b00228df93a9b1mr712220wrx.4.1662520373740; Tue, 06 Sep 2022 20:12:53 -0700 (PDT) MIME-Version: 1.0 References: <20220831184408.2778264-1-ndesaulniers@google.com> <20220831184408.2778264-3-ndesaulniers@google.com> In-Reply-To: From: Nick Desaulniers Date: Tue, 6 Sep 2022 20:12:42 -0700 Message-ID: Subject: Re: [PATCH v2 2/5] Makefile.compiler: Use KBUILD_AFLAGS for as-option To: Masahiro Yamada Cc: Nathan Chancellor , 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=-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 Mon, Sep 5, 2022 at 2:11 AM Masahiro Yamada wrote: > > 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. Should I do this for as-instr then as well? In the same patch? > > > 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)) Does your recent patch affect this? https://lore.kernel.org/linux-kbuild/20220905083619.672091-1-masahiroy@kernel.org/ If so, then I should not add -Werror as you suggest above? -- Thanks, ~Nick Desaulniers