From patchwork Thu Jan 25 17:32:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13531480 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23D34C48286 for ; Thu, 25 Jan 2024 17:32:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=s5gE9Dx8q02di10H9Z+j21qHfFYyY8I45LfK4UhgY3E=; b=vAv1vSAUuOx81S r3QwAtdcSJG2ZFj/iH4jiS7UU7RciEj7xFgtMPUS9AVkJYpSzPk5cOmqCzeR0PJ4DGMjxK8DMzTth /srWOpZbByKyHqaP3/kX4g9ZzIu1MKlG9DP8ZvmZQ2i5LiTcl7a/KvXpctCj/eg4lwnQGQSHRc6ls nYnIWUhQMbH4zkjsPQbCO3IcMNpWEfP0PX/h5FT7pR/hLl/KhmOFcD4d1CM//1MCKvhjepuwBsVWP OL7OtTZ+c673VaKoZA8h5PW6QRtMn9GoK8dk/s4+x7tNgzs1E7PFMw75NJqVNxBuZIYSttRXSkRUC 1IhXx0f1H9tFeMKvUKrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT3aT-00000001AHb-1AiC; Thu, 25 Jan 2024 17:32:25 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT3aO-00000001AF1-24a2 for linux-riscv@lists.infradead.org; Thu, 25 Jan 2024 17:32:22 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 987E3CE347C; Thu, 25 Jan 2024 17:32:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28BBAC433C7; Thu, 25 Jan 2024 17:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706203937; bh=IDSSBzPhxzI+ZK3MxpGpT7LOXd777sA7SwQ1ZR2C1s4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XFn3NOYndZhJ2KFChTNTUAi9PV1wJbswY7JOjNIj4+XEgp8qCtCZYARLiv5YNm2fv Xfr9vt36bv9KIMKzMShzfACzod4M/vOm64cRl4AGF37q97uQq2Q4KeX0OXxzS22D7g MgiA0Ib1ifvakVI2o8EoEkfHyybf0eaTsKKhzRClTi0Cp4gIrdlxXXPpbMX6e6zbSd LvAWmBiw+1LAPf0bXTHIJm1oCj9I8nua8nuzgphr1KVLDYrDJHg9yVbRHwIKum1qj3 +SKvxxWteyxCeAvilAUGM/FQ9pTj6H4gv/8S7kAv9IuXsNDZ3Rw1d1o3Pmvq2xFzrM NC5V/djg1TtVA== From: Nathan Chancellor Date: Thu, 25 Jan 2024 10:32:11 -0700 Subject: [PATCH 1/2] kbuild: Add -Wa,--fatal-warnings to as-instr invocation MIME-Version: 1.0 Message-Id: <20240125-fix-riscv-option-arch-llvm-18-v1-1-390ac9cc3cd0@kernel.org> References: <20240125-fix-riscv-option-arch-llvm-18-v1-0-390ac9cc3cd0@kernel.org> In-Reply-To: <20240125-fix-riscv-option-arch-llvm-18-v1-0-390ac9cc3cd0@kernel.org> To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, masahiroy@kernel.org Cc: nicolas@fjasle.eu, andy.chiu@sifive.com, conor.dooley@microchip.com, linux-riscv@lists.infradead.org, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, stable@vger.kernel.org, Eric Biggers , Nathan Chancellor X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2280; i=nathan@kernel.org; h=from:subject:message-id; bh=IDSSBzPhxzI+ZK3MxpGpT7LOXd777sA7SwQ1ZR2C1s4=; b=owGbwMvMwCUmm602sfCA1DTG02pJDKmbZsu7K6zaXpv59fmm4t4LfcbtCm9jLi6ssZYLLWOee vmvbhJnRykLgxgXg6yYIkv1Y9XjhoZzzjLeODUJZg4rE8gQBi5OAZhIkRDD//B3jdx17xQfM9iZ pRb/+3snLFAuM/FoKZPe0zvH17zUN2L4zaZcGrX4yv84AfeJ3nziev6BfF/4DA599lxStzMjqDC KDQA= X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240125_093220_947132_D13770B7 X-CRM114-Status: GOOD ( 11.34 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Certain assembler instruction tests may only induce warnings from the assembler on an unsupported instruction or option, which causes as-instr to succeed when it was expected to fail. Some tests workaround this limitation by additionally testing that invalid input fails as expected. However, this is fragile if the assembler is changed to accept the invalid input, as it will cause the instruction/option to be unavailable like it was unsupported even when it is. Use '-Wa,--fatal-warnings' in the as-instr macro to turn these warnings into hard errors, which avoids this fragility and makes tests more robust and well formed. Cc: stable@vger.kernel.org Suggested-by: Eric Biggers Signed-off-by: Nathan Chancellor --- scripts/Kconfig.include | 2 +- scripts/Makefile.compiler | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index 5a84b6443875..3ee8ecfb8c04 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-with-cpp -o /dev/null -) +as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -Wa$(comma)--fatal-warnings -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 8fcb427405a6..92be0c9a13ee 100644 --- a/scripts/Makefile.compiler +++ b/scripts/Makefile.compiler @@ -38,7 +38,7 @@ as-option = $(call try-run,\ # Usage: aflags-y += $(call as-instr,instr,option1,option2) as-instr = $(call try-run,\ - printf "%b\n" "$(1)" | $(CC) -Werror $(CLANG_FLAGS) $(KBUILD_AFLAGS) -c -x assembler-with-cpp -o "$$TMP" -,$(2),$(3)) + printf "%b\n" "$(1)" | $(CC) -Werror $(CLANG_FLAGS) $(KBUILD_AFLAGS) -Wa$(comma)--fatal-warnings -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) From patchwork Thu Jan 25 17:32:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13531478 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0121FC47422 for ; Thu, 25 Jan 2024 17:32:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DXjylwpuXpIiRjkfd+0zm2T4RdetGFDQ8f4Q2QFgCEY=; b=qVFaig6cysgjW0 z5iqDSWdBkARWubqU3Ie7OTpWAaZhdvlSSst8Hu+iNkm2hGotK+rzMvIKD0g9Um0b52Rxw2IYwhSi rJhQeMquK8b1NnQye4LvZHhP6l0e8pI1sPxEqXqQTo48npAPaejX2/SQErozRFo3gCrUvu0D3QrLc JtDSmqQZGDrKVUH5spYU6RSmrYZlvwM8RYGPfsQAXOcsCU4kq4BQf4P10M1/e2LLQUNquCPnu832E KDWmUX1Ev1PPE+oR4YSfWD3XVEHQlDal8VHXatVOJ7ceNyu/gez4blHh9E1HQxXsga9X1GtLhlCzC 6Hcb2jlj6dK0LUUd53SA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT3aS-00000001AGi-0GVp; Thu, 25 Jan 2024 17:32:24 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rT3aN-00000001AF2-21VK for linux-riscv@lists.infradead.org; Thu, 25 Jan 2024 17:32:21 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0086C6229C; Thu, 25 Jan 2024 17:32:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 128E4C43399; Thu, 25 Jan 2024 17:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706203938; bh=lICtxkQ3NvVShAwZIuLeByavdbgR2qlvf8P4owRHXS0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=W6W/YgzMa+vfIWb5fX28wPCUuhezAVgqad/dW1hojJysx+W3zkJX2JeLMuTN1Czdw XYIVjy3QPgiNiEEPG45JgquTNPbEuET9cRyjDlSBUjX5Cb2fXoGJJ/MPsG2VCYPGNN ct+R1QRzVTmlvTNUj5FzmzMQUa4Gl8JpUZli4axBg0lolr38mgqahfUMkf9J8RnLjf kFTJiLqFD2HFiaW6S+3Q+lLJtjaSv08qHf/qTj6CYeVL+U4HZCMNFegfhGyP/ndg3J WJT95mKdfiUVF3wLoGMQJj4HjbSByQMlf3m6ikTWHr9oo5RRNFmyL2cYwDbiAsHi+E PLKymFEVtVD7Q== From: Nathan Chancellor Date: Thu, 25 Jan 2024 10:32:12 -0700 Subject: [PATCH 2/2] RISC-V: Drop invalid test from CONFIG_AS_HAS_OPTION_ARCH MIME-Version: 1.0 Message-Id: <20240125-fix-riscv-option-arch-llvm-18-v1-2-390ac9cc3cd0@kernel.org> References: <20240125-fix-riscv-option-arch-llvm-18-v1-0-390ac9cc3cd0@kernel.org> In-Reply-To: <20240125-fix-riscv-option-arch-llvm-18-v1-0-390ac9cc3cd0@kernel.org> To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, masahiroy@kernel.org Cc: nicolas@fjasle.eu, andy.chiu@sifive.com, conor.dooley@microchip.com, linux-riscv@lists.infradead.org, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, stable@vger.kernel.org, Eric Biggers , Nathan Chancellor X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2365; i=nathan@kernel.org; h=from:subject:message-id; bh=lICtxkQ3NvVShAwZIuLeByavdbgR2qlvf8P4owRHXS0=; b=owGbwMvMwCUmm602sfCA1DTG02pJDKmbZissneNvc+U8g8IkiV2P1y8V+vnuj1eFVfVy31c+S sc4V1/d31HKwiDGxSArpshS/Vj1uKHhnLOMN05NgpnDygQyhIGLUwAmsi6L4X9Wx9n0S4s2cUzV q/lYfnDKWrdt3qvWLPzFHJgzVbXZdIcYI8P/j63TYrYsVLNiNKmSnDiZx/TBt7jCBDb+hNe6wUx mFUwA X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240125_093219_656383_963F3038 X-CRM114-Status: GOOD ( 10.57 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Commit e4bb020f3dbb ("riscv: detect assembler support for .option arch") added two tests, one for a valid value to '.option arch' that should succeed and one for an invalid value that is expected to fail to make sure that support for '.option arch' is properly detected because Clang does not error when '.option arch' is not supported: $ clang --target=riscv64-linux-gnu -Werror -x assembler -c -o /dev/null <(echo '.option arch, +m') /dev/fd/63:1:9: warning: unknown option, expected 'push', 'pop', 'rvc', 'norvc', 'relax' or 'norelax' .option arch, +m ^ $ echo $? 0 Unfortunately, the invalid test started being accepted by Clang after the linked llvm-project change, which causes CONFIG_AS_HAS_OPTION_ARCH and configurations that depend on it to be silently disabled, even though those versions do support '.option arch'. The invalid test can be avoided altogether by using '-Wa,--fatal-warnings', which will turn all assembler warnings into errors, like '-Werror' does for the compiler: $ clang --target=riscv64-linux-gnu -Werror -Wa,--fatal-warnings -x assembler -c -o /dev/null <(echo '.option arch, +m') /dev/fd/63:1:9: error: unknown option, expected 'push', 'pop', 'rvc', 'norvc', 'relax' or 'norelax' .option arch, +m ^ $ echo $? 1 The as-instr macros have been updated to make use of this flag, so remove the invalid test, which allows CONFIG_AS_HAS_OPTION_ARCH to work for all compiler versions. Cc: stable@vger.kernel.org Fixes: e4bb020f3dbb ("riscv: detect assembler support for .option arch") Link: https://github.com/llvm/llvm-project/commit/3ac9fe69f70a2b3541266daedbaaa7dc9c007a2a Reported-by: Eric Biggers Closes: https://lore.kernel.org/r/20240121011341.GA97368@sol.localdomain/ Signed-off-by: Nathan Chancellor --- arch/riscv/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index bffbd869a068..e3142ce531a0 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -315,7 +315,6 @@ config AS_HAS_OPTION_ARCH # https://reviews.llvm.org/D123515 def_bool y depends on $(as-instr, .option arch$(comma) +m) - depends on !$(as-instr, .option arch$(comma) -i) source "arch/riscv/Kconfig.socs" source "arch/riscv/Kconfig.errata"