From patchwork Wed Sep 7 04:59:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Desaulniers X-Patchwork-Id: 12968438 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBE03C6FA82 for ; Wed, 7 Sep 2022 04:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbiIGE7m (ORCPT ); Wed, 7 Sep 2022 00:59:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbiIGE7a (ORCPT ); Wed, 7 Sep 2022 00:59:30 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0108226FF for ; Tue, 6 Sep 2022 21:59:28 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-3456e0bcd5aso42305037b3.20 for ; Tue, 06 Sep 2022 21:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=OAxiGU2+Zm5TGJDmYfJLZJYOpFooL4QHZIWYZiKDaNI=; b=UzsWkCGsn6TQFhqSZYOpR99wDWCEXyZ5MMKliAg92jQS0AYBHwEF9zjvATBGutup0p NO4wYpNhStcU1J2cjuQ9GbbOxS0zgurgoKVwHDsFvcRp3qp+1FwJWk9aGuyQbd+ASbse iV3thzcFMTbZumH8eFJ/+YP8y1KiQsIPJKUs8IhaiUZOb43fNEAzNxjiZYFDNQPUG37S YBaAhRCr92G4fwx7c3G1Ptk9p0+T0o/DqhaN7oWXfr5m8Ga95DnhZNA9Q15IBNaTbnp2 gNSGwfBi+FAib0O60VIP4ATtHiqMscBaDINfd3MnenIeo3QSkPkQcshNYHMvheD3+gFv eKoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=OAxiGU2+Zm5TGJDmYfJLZJYOpFooL4QHZIWYZiKDaNI=; b=LJ1oBfb85rsUcaziTbe2XlpQDwSm1p/31VXK9ZhKWh5OHxdTfQJuzagnwPF6HjB1Jh B6ralkL+dd7Jj6f/oNeathGpWjrLyf/19pV6jam8Qjy4I/247po5CgQbE27mI/i6fROO 8qlDZEQxrGcgFHmWHLa4u59gRRnE4BRuqM9ZjxSzBBPgXoo++0nJ8w+VsrvIKNyKXo4j DFQgdgcCYMXE2ZL4ejs/88vcwivUM5a/CGrdJ3KSgs5ExCCHHpnhtXM7EtR3pRbQq5nI Dll0J37UJzRAsluOjvwFSHwnA4nJYar5CQk0SxUXMZYQqt5uVVfg8TTkKJudSLc4NfSz GNlw== X-Gm-Message-State: ACgBeo0kyR8xYYRpbTzw9462RdREUNNLgWYn/AAYSsTU/ionjONDvpdM gL66mHn7WJWDOFWa/CmTtn5hcdP7nnp0tq+xmR4= X-Google-Smtp-Source: AA6agR7THdtxfPlLHDj0ifMy7DcCylYYagRl6nsfCC9Vw9Lgt7j1YooO+zDIu58BxyQMjhmKLfZwaRD9tKprzZQX4dk= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:0:100e:712:9755:c523:9dcb:2228]) (user=ndesaulniers job=sendgmr) by 2002:a05:6902:192:b0:695:7e89:ed5b with SMTP id t18-20020a056902019200b006957e89ed5bmr1546228ybh.226.1662526768328; Tue, 06 Sep 2022 21:59:28 -0700 (PDT) Date: Tue, 6 Sep 2022 21:59:04 -0700 In-Reply-To: <20220907045907.484043-1-ndesaulniers@google.com> Mime-Version: 1.0 References: <20220907045907.484043-1-ndesaulniers@google.com> X-Developer-Key: i=ndesaulniers@google.com; a=ed25519; pk=lvO/pmg+aaCb6dPhyGC1GyOCvPueDrrc8Zeso5CaGKE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1662526746; l=2233; i=ndesaulniers@google.com; s=20211004; h=from:subject; bh=M5avwGZxXNJVxI+Cw3zYKb1tkFDlYgC1vraaiWNDNLE=; b=PMS5H0clISr6OeQLTZXXnl/Hs9ioLuh2rFA+ahRsD1VUjLrQCJQtmQXeyAUyMdzSLZZtrtXNSCWV 8GhYxzD9DiNFAxz0fymoGHRZtV2fWVqD5vlKD/7fvZ87O2xKqe1o X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220907045907.484043-3-ndesaulniers@google.com> Subject: [PATCH v3 2/5] Makefile.compiler: Use KBUILD_AFLAGS for as-option From: Nick Desaulniers To: Masahiro Yamada Cc: Michal Marek , Nathan Chancellor , 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 , Nick Desaulniers Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org as-instr uses KBUILD_AFLAGS, but as-option uses KBUILD_CFLAGS. This can cause as-option to fail unexpectedly when CONFIG_WERROR is set, 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. Also, change as-option and as-instr to use -x assembler-with-cpp since kernel sources are .S files that use the compiler as the driver. And then add -Werror as well. Link: https://github.com/ClangBuiltLinux/linux/issues/1699 Suggested-by: Masahiro Yamada Reviewed-by: Nathan Chancellor Signed-off-by: Nick Desaulniers --- Changes v2 -> v1: * Add -x assembler-with-cpp -Werror to both as-option and (new) as-instr, as per Masahiro. * Add Masahiro's SB tag. Changes v1 -> v2: * Split off changes to arch/x86/boot/compressed/Makefile into parent patch, as per Masahiro. scripts/Makefile.compiler | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler index 94d0d40cddb3..a66638b5f4a5 100644 --- a/scripts/Makefile.compiler +++ b/scripts/Makefile.compiler @@ -29,16 +29,16 @@ 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) -Werror $(KBUILD_AFLAGS) $(1) -c -x assembler-with-cpp /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)) + printf "%b\n" "$(1)" | $(CC) -Werror $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) # __cc-option # Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586)