Re: [PATCH v2] riscv: Handle zicsr/zifencei issue between gcc and binutils

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 26, 2023 at 08:41:55PM +0100, Conor Dooley wrote:
> On Thu, Jul 27, 2023 at 03:34:16AM +0800, Mingzheng Xing wrote:
> > On 7/27/23 02:02, Conor Dooley wrote:
> 
> > > This is still broken for:
> > > CONFIG_CLANG_VERSION=0
> > > CONFIG_AS_IS_GNU=y
> > > CONFIG_AS_VERSION=23500
> > > CONFIG_LD_IS_BFD=y
> > > CONFIG_LD_VERSION=23500
> > 
> > Do you mean that these CONFIG_* will cause kernel
> > compilation errors when paired with certain versions of GCC?
> > Or perhaps I misunderstood your meaning.
> 
> No, this section is generated by kconfig, although I messed up my
> trimming of the list & accidentally removed the gcc version, rather
> than the clang version. Here's the full thing:
> 
> CONFIG_CC_VERSION_TEXT="riscv64-unknown-linux-gnu-gcc (g2ee5e430018) 12.2.0"
> CONFIG_CC_IS_GCC=y
> CONFIG_GCC_VERSION=120200
> CONFIG_CLANG_VERSION=0
> CONFIG_AS_IS_GNU=y
> CONFIG_AS_VERSION=23500
> CONFIG_LD_IS_BFD=y
> CONFIG_LD_VERSION=23500
> CONFIG_LLD_VERSION=0
> CONFIG_CC_CAN_LINK=y
> CONFIG_CC_CAN_LINK_STATIC=y
> CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y
> CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT=y
> CONFIG_CC_HAS_ASM_INLINE=y
> CONFIG_CC_HAS_NO_PROFILE_FN_ATTR=y
> CONFIG_PAHOLE_VERSION=0
> CONFIG_CONSTRUCTORS=y
> CONFIG_IRQ_WORK=y
> CONFIG_BUILDTIME_TABLE_SORT=y

I think this should sort things out for the even-older binutils case. I
took the opportunity to fix some grammatical issues that seem to have
snuck into the help text in your patch & to drop the \, since the
depends on fits in one line.

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index e1b66ee88323..2d0d89213c97 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -571,25 +571,27 @@ config TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
 	def_bool y
 	# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc
 	# https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=98416dbb0a62579d4a7a4a76bab51b5b52fec2cd
-	depends on GCC_VERSION >= 120100 || (AS_IS_GNU && AS_VERSION >= 23800)
+	depends on AS_IS_GNU
+	depends on (GCC_VERSION >= 120100 && AS_VERSION >= 23600) || AS_VERSION >= 23800
 	help
-	  Binutils-2.38 and GCC-12.1.0 bump default ISA spec to newer version
+	  Binutils-2.38 and GCC-12.1.0 bump the default ISA spec to version
 	  20191213 which moves some instructions from the I extension to the
-	  Zicsr and Zifencei extensions.
+	  Zicsr and Zifencei extensions. On the other hand, Binutils prior to
+	  2.35 does not understand these arguments and will error if they are
+	  passed.
 
 config TOOLCHAIN_NEEDS_OLD_ISA_SPEC
 	def_bool y
 	depends on TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
 	# https://github.com/llvm/llvm-project/commit/22e199e6afb1263c943c0c0d4498694e15bf8a16
 	# https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b03be74bad08c382da47e048007a78fa3fb4ef49
-	depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || \
-		   (CC_IS_GCC && GCC_VERSION < 110100)
+	depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || (CC_IS_GCC && GCC_VERSION < 110100)
 	help
-	  Certain versions of clang (or GCC) do not support zicsr and zifencei via
+	  Certain versions of clang and GCC do not support zicsr and zifencei via
 	  -march but newer versions of binutils require it for the reasons noted
 	  in the help text of CONFIG_TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI. This
 	  option causes an older ISA spec compatible with these older versions
-	  of clang (or GCC) to be passed to GAS, which has the same result as
+	  of clang and GCC to be passed to GAS, which has the same result as
 	  passing zicsr and zifencei to -march.
 
 config FPU

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux