2022-03-08 17:52:57 +01:00
|
|
|
From: Aurelien Jarno <aurelien@aurel32.net>
|
|
|
|
Date: Fri, 28 Jan 2022 18:33:46 +0100
|
|
|
|
Subject: Makefile: fix build with binutils 2.38
|
|
|
|
|
|
|
|
Git-commit: 5d53b55aa77ffeefd4012445dfa6ad3535e1ff2c
|
|
|
|
|
|
|
|
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 lib/sbi/sbi_tlb.o
|
|
|
|
<<BUILDDIR>>/lib/sbi/sbi_tlb.c: Assembler messages:
|
|
|
|
<<BUILDDIR>>/lib/sbi/sbi_tlb.c:190: Error: unrecognized opcode `fence.i'
|
|
|
|
make: *** [Makefile:431: <<BUILDDIR>>/build/lib/sbi/sbi_tlb.o] Error 1
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
|
|
|
|
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
|
|
|
|
Tested-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
|
|
|
|
Reviewed-by: Anup Patel <anup@brainfault.org>
|
|
|
|
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
|
|
|
|
---
|
|
|
|
Makefile | 9 ++++++++-
|
|
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/roms/opensbi/Makefile b/roms/opensbi/Makefile
|
2022-07-22 13:50:51 +02:00
|
|
|
index 062883e9695fb4447d2e61d7f282..fc1ea13e519a702e8b09d9006a2c 100644
|
2022-03-08 17:52:57 +01:00
|
|
|
--- a/roms/opensbi/Makefile
|
|
|
|
+++ b/roms/opensbi/Makefile
|
2022-07-22 13:50:51 +02:00
|
|
|
@@ -153,6 +153,9 @@ OPENSBI_LD_PIE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) $(USE_LD_FLAG) -fP
|
|
|
|
# Check whether the compiler supports -m(no-)save-restore
|
|
|
|
CC_SUPPORT_SAVE_RESTORE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -mno-save-restore -x c /dev/null -o /dev/null 2>&1 | grep "\-save\-restore" >/dev/null && echo n || echo y)
|
2022-03-08 17:52:57 +01:00
|
|
|
|
|
|
|
+# Check whether the assembler and the compiler support the Zicsr and Zifencei extensions
|
|
|
|
+CC_SUPPORT_ZICSR_ZIFENCEI := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) -nostdlib -march=rv$(OPENSBI_CC_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep "zicsr\|zifencei" > /dev/null && echo n || echo y)
|
|
|
|
+
|
2022-07-22 13:50:51 +02:00
|
|
|
# Build Info:
|
|
|
|
# OPENSBI_BUILD_TIME_STAMP -- the compilation time stamp
|
|
|
|
# OPENSBI_BUILD_COMPILER_VERSION -- the compiler version info
|
|
|
|
@@ -223,7 +226,11 @@ ifndef PLATFORM_RISCV_ABI
|
2022-03-08 17:52:57 +01:00
|
|
|
endif
|
|
|
|
ifndef PLATFORM_RISCV_ISA
|
|
|
|
ifneq ($(PLATFORM_RISCV_TOOLCHAIN_DEFAULT), 1)
|
|
|
|
- PLATFORM_RISCV_ISA = rv$(PLATFORM_RISCV_XLEN)imafdc
|
|
|
|
+ ifeq ($(CC_SUPPORT_ZICSR_ZIFENCEI), y)
|
|
|
|
+ PLATFORM_RISCV_ISA = rv$(PLATFORM_RISCV_XLEN)imafdc_zicsr_zifencei
|
|
|
|
+ else
|
|
|
|
+ PLATFORM_RISCV_ISA = rv$(PLATFORM_RISCV_XLEN)imafdc
|
|
|
|
+ endif
|
|
|
|
else
|
|
|
|
PLATFORM_RISCV_ISA = $(OPENSBI_CC_ISA)
|
|
|
|
endif
|