mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] RISC-V: Makefile: fix build with binutils 2.38
Date: Thu,  2 Feb 2023 14:26:12 +0100	[thread overview]
Message-ID: <20230202132612.691206-3-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20230202132612.691206-1-m.felsch@pengutronix.de>

With binutils >= 2.38 the default risc-v ISA spec version has been
bumped to 20191213, so we now need to specify the extension for csr and
fence.i as well. Do it the kernel way and port commit

  | commit 6df2a016c0c8a3d0933ef33dd192ea6606b115e3
  | Author: Aurelien Jarno <aurelien@aurel32.net>
  | Date:   Wed Jan 26 18:14:42 2022 +0100
  |
  |     riscv: fix build with binutils 2.38
  |
  |     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.
  |
  |     Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
  |     Tested-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
  |     Cc: stable@vger.kernel.org
  |     Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 arch/riscv/Makefile | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index d1b689b493..1371f17e7c 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -16,6 +16,10 @@ endif
 riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32im
 riscv-march-$(CONFIG_ARCH_RV64I)	:= rv64im
 
+# 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_CPPFLAGS += -march=$(riscv-march-y)
 KBUILD_CPPFLAGS += -Wstrict-prototypes -mcmodel=medany -fpic
-- 
2.39.1




  parent reply	other threads:[~2023-02-02 13:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 13:26 [PATCH 1/3] RISC-V: Makefile: cleanup layout Marco Felsch
2023-02-02 13:26 ` [PATCH 2/3] RISC-V: Makefile: align the isa string setting with the kernel Marco Felsch
2023-02-02 13:26 ` Marco Felsch [this message]
2023-02-03  8:04 ` [PATCH 1/3] RISC-V: Makefile: cleanup layout Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230202132612.691206-3-m.felsch@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox