From: Khem Raj <raj.khem@gmail.com>
To: u-boot@lists.denx.de
Cc: Khem Raj <raj.khem@gmail.com>, Rick Chen <rick@andestech.com>,
Leo <ycliang@andestech.com>
Subject: [PATCH] riscv: fix build with binutils 2.38
Date: Sun, 13 Feb 2022 21:28:45 -0800 [thread overview]
Message-ID: <20220214052845.40610-1-raj.khem@gmail.com> (raw)
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
next reply other threads:[~2022-02-14 13:57 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 5:28 Khem Raj [this message]
2022-02-17 9:34 ` [PATCH] riscv: fix build with binutils 2.38 Leo Liang
-- strict thread matches above, loose matches on Subject: below --
2022-02-14 5:33 Khem Raj
2022-02-14 5:31 Khem Raj
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
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=20220214052845.40610-1-raj.khem@gmail.com \
--to=raj.khem@gmail.com \
--cc=rick@andestech.com \
--cc=u-boot@lists.denx.de \
--cc=ycliang@andestech.com \
/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 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.