All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: fix build with binutils 2.38
@ 2022-02-14  5:31 Khem Raj
  0 siblings, 0 replies; 30+ messages in thread
From: Khem Raj @ 2022-02-14  5:31 UTC (permalink / raw)
  To: u-boot; +Cc: Khem Raj, Rick Chen, Leo

From version 2.38, binutils default to ISA spec version 20191213. This
means that the csr read/write (csrr*/csrw*) instructions and fence.i
instruction has separated from the `I` extension, become two standalone
extensions: Zicsr and Zifencei.

The fix is to specify those extensions explicitly in -march. However as
older binutils version do not support this, we first need to detect
that.

Fixes
arch/riscv/lib/cache.c: Assembler messages:
arch/riscv/lib/cache.c:12: Error: unrecognized opcode `fence.i'

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Rick Chen <rick@andestech.com>
Cc: Leo <ycliang@andestech.com>
---
 arch/riscv/Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0b80eb8d86..e6fe1fc02b 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -24,7 +24,12 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y)
 	CMODEL = medany
 endif
 
-ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C) -mabi=$(ABI) \
+# Newer binutils versions default to ISA spec version 20191213 which moves some
+# instructions from the I extension to the Zicsr and Zifencei extensions.
+toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C)_zicsr_zifencei)
+zicsr_zifencei-$(toolchain-need-zicsr-zifencei) := _zicsr_zifencei
+
+ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C)$(zicsr_zifencei-y) -mabi=$(ABI) \
 	     -mcmodel=$(CMODEL)
 
 PLATFORM_CPPFLAGS	+= $(ARCH_FLAGS)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [PATCH] riscv: fix build with binutils 2.38
@ 2022-02-14  5:33 Khem Raj
  0 siblings, 0 replies; 30+ messages in thread
From: Khem Raj @ 2022-02-14  5:33 UTC (permalink / raw)
  To: u-boot; +Cc: Khem Raj, Rick Chen, Leo

From version 2.38, binutils default to ISA spec version 20191213. This
means that the csr read/write (csrr*/csrw*) instructions and fence.i
instruction has separated from the `I` extension, become two standalone
extensions: Zicsr and Zifencei.

The fix is to specify those extensions explicitly in -march. However as
older binutils version do not support this, we first need to detect
that.

Fixes
arch/riscv/lib/cache.c: Assembler messages:
arch/riscv/lib/cache.c:12: Error: unrecognized opcode `fence.i'

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Rick Chen <rick@andestech.com>
Cc: Leo <ycliang@andestech.com>
---
 arch/riscv/Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0b80eb8d86..e6fe1fc02b 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -24,7 +24,12 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y)
 	CMODEL = medany
 endif
 
-ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C) -mabi=$(ABI) \
+# Newer binutils versions default to ISA spec version 20191213 which moves some
+# instructions from the I extension to the Zicsr and Zifencei extensions.
+toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C)_zicsr_zifencei)
+zicsr_zifencei-$(toolchain-need-zicsr-zifencei) := _zicsr_zifencei
+
+ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C)$(zicsr_zifencei-y) -mabi=$(ABI) \
 	     -mcmodel=$(CMODEL)
 
 PLATFORM_CPPFLAGS	+= $(ARCH_FLAGS)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [PATCH] riscv: fix build with binutils 2.38
@ 2022-02-14  5:28 Khem Raj
  2022-02-17  9:34 ` Leo Liang
  0 siblings, 1 reply; 30+ messages in thread
From: Khem Raj @ 2022-02-14  5:28 UTC (permalink / raw)
  To: u-boot; +Cc: Khem Raj, Rick Chen, Leo

From version 2.38, binutils default to ISA spec version 20191213. This
means that the csr read/write (csrr*/csrw*) instructions and fence.i
instruction has separated from the `I` extension, become two standalone
extensions: Zicsr and Zifencei.

The fix is to specify those extensions explicitly in -march. However as
older binutils version do not support this, we first need to detect
that.

Fixes
arch/riscv/lib/cache.c: Assembler messages:
arch/riscv/lib/cache.c:12: Error: unrecognized opcode `fence.i'

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Rick Chen <rick@andestech.com>
Cc: Leo <ycliang@andestech.com>
---
 arch/riscv/Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0b80eb8d86..e6fe1fc02b 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -24,7 +24,12 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y)
 	CMODEL = medany
 endif
 
-ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C) -mabi=$(ABI) \
+# Newer binutils versions default to ISA spec version 20191213 which moves some
+# instructions from the I extension to the Zicsr and Zifencei extensions.
+toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C)_zicsr_zifencei)
+zicsr_zifencei-$(toolchain-need-zicsr-zifencei) := _zicsr_zifencei
+
+ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C)$(zicsr_zifencei-y) -mabi=$(ABI) \
 	     -mcmodel=$(CMODEL)
 
 PLATFORM_CPPFLAGS	+= $(ARCH_FLAGS)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [PATCH] riscv: fix build with binutils 2.38
@ 2022-01-26 17:14 ` Aurelien Jarno
  0 siblings, 0 replies; 30+ messages in thread
From: Aurelien Jarno @ 2022-01-26 17:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Aurelien Jarno, stable, Kito Cheng, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, open list:RISC-V ARCHITECTURE

From version 2.38, binutils default to ISA spec version 20191213. This
means that the csr read/write (csrr*/csrw*) instructions and fence.i
instruction has separated from the `I` extension, become two standalone
extensions: Zicsr and Zifencei. As the kernel uses those instruction,
this causes the following build failure:

  CC      arch/riscv/kernel/vdso/vgettimeofday.o
  <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h: Assembler messages:
  <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
  <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
  <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'
  <<BUILDDIR>>/arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01'

The fix is to specify those extensions explicitely in -march. However as
older binutils version do not support this, we first need to detect
that.

Cc: stable@vger.kernel.org # 4.15+
Cc: Kito Cheng <kito.cheng@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 arch/riscv/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 8a107ed18b0d..7d81102cffd4 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -50,6 +50,12 @@ riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32ima
 riscv-march-$(CONFIG_ARCH_RV64I)	:= rv64ima
 riscv-march-$(CONFIG_FPU)		:= $(riscv-march-y)fd
 riscv-march-$(CONFIG_RISCV_ISA_C)	:= $(riscv-march-y)c
+
+# Newer binutils versions default to ISA spec version 20191213 which moves some
+# instructions from the I extension to the Zicsr and Zifencei extensions.
+toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zicsr_zifencei)
+riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei
+
 KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
 KBUILD_AFLAGS += -march=$(riscv-march-y)
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2022-04-01 17:55 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14  5:31 [PATCH] riscv: fix build with binutils 2.38 Khem Raj
  -- strict thread matches above, loose matches on Subject: below --
2022-02-14  5:33 Khem Raj
2022-02-14  5:28 Khem Raj
2022-02-17  9:34 ` Leo Liang
2022-01-26 17:14 Aurelien Jarno
2022-01-26 17:14 ` Aurelien Jarno
2022-01-28 10:05 ` Alexandre Ghiti
2022-01-28 10:05   ` Alexandre Ghiti
2022-02-10 17:40 ` Palmer Dabbelt
2022-02-10 17:40   ` Palmer Dabbelt
2022-02-10 17:56   ` Greg KH
2022-02-10 17:56     ` Greg KH
2022-03-31 10:32 ` Marc Kleine-Budde
2022-03-31 10:32   ` Marc Kleine-Budde
2022-03-31 10:39   ` Marc Kleine-Budde
2022-03-31 10:39     ` Marc Kleine-Budde
2022-03-31 10:51     ` Marc Kleine-Budde
2022-03-31 10:51       ` Marc Kleine-Budde
2022-03-31 17:05       ` Aurelien Jarno
2022-03-31 17:05         ` Aurelien Jarno
2022-03-31 18:16       ` Linus Torvalds
2022-03-31 18:16         ` Linus Torvalds
2022-03-31 19:42         ` Palmer Dabbelt
2022-03-31 19:42           ` Palmer Dabbelt
2022-04-01  6:53         ` Marc Kleine-Budde
2022-04-01  6:53           ` Marc Kleine-Budde
2022-04-01 17:14           ` Linus Torvalds
2022-04-01 17:14             ` Linus Torvalds
2022-04-01 17:55             ` Palmer Dabbelt
2022-04-01 17:55               ` Palmer Dabbelt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.