From mboxrd@z Thu Jan 1 00:00:00 1970 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 9962EEB64DB for ; Wed, 14 Jun 2023 18:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238969AbjFNSFV (ORCPT ); Wed, 14 Jun 2023 14:05:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235455AbjFNSEq (ORCPT ); Wed, 14 Jun 2023 14:04:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9230E2117 for ; Wed, 14 Jun 2023 11:04:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C5AF063805 for ; Wed, 14 Jun 2023 18:04:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F381C433BF; Wed, 14 Jun 2023 18:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686765883; bh=eD43QHpsk15A4pO5TpffxTwJIE9JOTt4JZ4NFLKhj3U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DHYZQFCy3c5tlhhbjoRXv4FwgDDKRcOrYkLGDSM/byz0NJWoJF1q31zoO4/k1OaMh aehjqOvKYJbF/x1VpXirfdr7c09yRjGXNVBHHzjoiZmfcE5EOjMIXt6FQ9KX4x5uGZ 1mE4BYUh776p2bVAlRPWFO/xsltIOH33+U+06/WhUjZA/PAiYosiiy/PGAxXTI8dy/ ZWcOmqqwVm3jBlbVxyW+wABWh32N2M8TCHoMbnSvDoYYCo4Xo7tT00QRF2OfMTvdk7 5py0Pecq8ENWfuS+Yox2lqehnyws7Auwi0dhxlqJYyYkkgfmyb4BQzwIzcKkbd1u8/ jGNmp9tW43v4A== From: Nathan Chancellor Date: Wed, 14 Jun 2023 11:04:38 -0700 Subject: [PATCH 6.1 4/4] kbuild: Update assembler calls to use proper flags and language target MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230612-6-1-asssembler-target-llvm-17-v1-4-75605d553401@kernel.org> References: <20230612-6-1-asssembler-target-llvm-17-v1-0-75605d553401@kernel.org> In-Reply-To: <20230612-6-1-asssembler-target-llvm-17-v1-0-75605d553401@kernel.org> To: gregkh@linuxfoundation.org, sashal@kernel.org, ndesaulniers@google.com Cc: naresh.kamboju@linaro.org, stable@vger.kernel.org, llvm@lists.linux.dev, Masahiro Yamada , Nathan Chancellor , Linux Kernel Functional Testing , Anders Roxell X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3978; i=nathan@kernel.org; h=from:subject:message-id; bh=P6OQWYzETz4C5iIyDA0p8vZZJnpeR67V/X1TfW2vqWA=; b=owGbwMvMwCEmm602sfCA1DTG02pJDCldjGaOzvb+vXmr8382TTx6bE/08+raGiOe1e77dnd+j P3kG3qxo5SFQYyDQVZMkaX6sepxQ8M5ZxlvnJoEM4eVCWQIAxenAEykW5eRYVPVhabVew/P0Ula 5LTCee7KazcZD3rxBYs8X7Gv9ZS3hBEjw674a6F+fJaJl9eohwTm6+V6ed29tuT50smn1ZRCzpx t5AcA X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Nick Desaulniers commit d5c8d6e0fa61401a729e9eb6a9c7077b2d3aebb0 upstream. 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 in KBUILD_CFLAGS for assembler sources. Callers of as-option and as-instr should be adding flags to KBUILD_AFLAGS / aflags-y, not KBUILD_CFLAGS / cflags-y. Use KBUILD_AFLAGS in all macros to clear up the initial problem. Unfortunately, -Wunused-command-line-argument can still be triggered with clang by the presence of warning flags or macro definitions because '-x assembler' is used, instead of '-x assembler-with-cpp', which will consume these flags. Switch to '-x assembler-with-cpp' in places where '-x assembler' is used, as the compiler is always used as the driver for out of line assembler sources in the kernel. Finally, add -Werror to these macros so that they behave consistently whether or not CONFIG_WERROR is set. [nathan: Reworded and expanded on problems in commit message Use '-x assembler-with-cpp' in a couple more places] Link: https://github.com/ClangBuiltLinux/linux/issues/1699 Suggested-by: Masahiro Yamada Signed-off-by: Nick Desaulniers Signed-off-by: Nathan Chancellor Tested-by: Linux Kernel Functional Testing Tested-by: Anders Roxell Signed-off-by: Masahiro Yamada Signed-off-by: Nathan Chancellor --- scripts/Kconfig.include | 2 +- scripts/Makefile.compiler | 8 ++++---- scripts/as-version.sh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index 274125307ebd..5a84b6443875 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include @@ -33,7 +33,7 @@ ld-option = $(success,$(LD) -v $(1)) # $(as-instr,) # Return y if the assembler supports , n otherwise -as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler -o /dev/null -) +as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler-with-cpp -o /dev/null -) # check if $(CC) and $(LD) exist $(error-if,$(failure,command -v $(CC)),C compiler '$(CC)' not found) diff --git a/scripts/Makefile.compiler b/scripts/Makefile.compiler index 20d353dcabfb..158c57f2acfd 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) diff --git a/scripts/as-version.sh b/scripts/as-version.sh index 1a21495e9ff0..af717476152d 100755 --- a/scripts/as-version.sh +++ b/scripts/as-version.sh @@ -45,7 +45,7 @@ orig_args="$@" # Get the first line of the --version output. IFS=' ' -set -- $(LC_ALL=C "$@" -Wa,--version -c -x assembler /dev/null -o /dev/null 2>/dev/null) +set -- $(LC_ALL=C "$@" -Wa,--version -c -x assembler-with-cpp /dev/null -o /dev/null 2>/dev/null) # Split the line on spaces. IFS=' ' -- 2.41.0