Makefile: fix build with binutils 2.38
PATCH 1/1 Makefile: 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 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.
--- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
Changes v1 -> v2 following the review from Bin Men (thanks)!
- Fix typos
- Use grep to detect missing extensions for consistency with CC_SUPPORT_SAVE_RESTORE
Makefile +8 -1
@@ -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) +# 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$(PLATFORM_RISCV_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep "zicsr\|zifencei" > /dev/null && echo n || echo y) + # 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 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
Signature · 1 line
2.34.1
PATCH 1/1 Makefile: fix build with binutils 2.38
Quoted 16 lines · Aurelien Jarno
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
Iextension, 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 1The fix is to specify those extensions explicitly in -march. However as older binutils version do not support this, we first need to detect that.
Quoted 9 lines
Signed-off-by Aurelien Jarno <[email protected]>--- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)Changes v1 -> v2 following the review from Bin Men (thanks)!
- Fix typos
- Use grep to detect missing extensions for consistency withCC_SUPPORT_SAVE_RESTORE
PATCH 1/1 Makefile: fix build with binutils 2.38
In reply to Aurelien Jarno? 2022-01-28???? 18:33 +0100?Aurelien Jarno???
Quoted 6 lines
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
Iextension, become two standalone
extensions: Zicsr and Zifencei. As the kernel uses those instruction, this causes the following build failure:
The latest version of GNU binutils is 2.37. 2.38 should not be released yet, are there any new patch references for these changes?
Regards,
Xiang W
Quoted 62 lines
?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 1The 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 <[email protected]>---
?Makefile | 9 ++++++++-
?1 file changed, 8 insertions(+), 1 deletion(-)Changes v1 -> v2 following the review from Bin Men (thanks)!
- Fix typos
- Use grep to detect missing extensions for consistency withCC_SUPPORT_SAVE_RESTOREMakefile +0
-0@@ -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/null2>&1 | grep "\-save\-restore" >/dev/null && echo n || echo y) ?
+# 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$(PLATFORM_RISCV_XLEN)imafd_zicsr_zifencei -x c/dev/null-o/dev/null2>&1 | grep "zicsr\|zifencei" >/dev/null&& echo n || echo
y)
+
?# Build Info:
?#OPENSBI_BUILD_TIME_STAMP-- the compilation time stamp ?#OPENSBI_BUILD_COMPILER_VERSION-- the compiler version infoMakefile +0
-0@@ -223,7 +226,11 @@ ifndef PLATFORM_RISCV_ABI?endif
?ifndefPLATFORM_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)
?? endifSignature · 1 line
2.34.1
PATCH 1/1 Makefile: fix build with binutils 2.38
Quoted 10 lines · Xiang W
? 2022-01-28???? 18:33 +0100?Aurelien Jarno???
Quoted 6 lines
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
Iextension, become two standalone
extensions: Zicsr and Zifencei. As the kernel uses those instruction, this causes the following build failure:The latest version of GNU binutils is 2.37. 2.38 should not be released yet, are there any new patch references for these changes?
Correct, however there is already a 2.38 branch and the release should happen in the next weeks.
The default ISA spec change is due to this commit:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien at aurel32.net http://www.aurel32.net
PATCH 1/1 Makefile: fix build with binutils 2.38
? 2022-01-29???? 14:05 +0100?Aurelien Jarno???
Quoted 16 lines · Xiang W
Quoted 10 lines
? 2022-01-28???? 18:33 +0100?Aurelien Jarno???
Quoted 9 lines
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 theIextension, become two standalone
extensions: Zicsr and Zifencei. As the kernel uses those instruction,
this causes the following build failure:Quoted 4 lines
The latest version of GNU binutils is 2.37. 2.38 should not be released
yet, are there any new patch references for these changes?
Quoted 6 lines
Correct, however there is already a 2.38 branch and the release should happen in the next weeks.
The default ISA spec change is due to this commit:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc
thanks a lot.
PATCH 1/1 Makefile: fix build with binutils 2.38
In reply to Aurelien JarnoHi Aur?lien,
Quoted 41 lines · Aurelien Jarno
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 theIextension, 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 1The 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 <[email protected]>--- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)Changes v1 -> v2 following the review from Bin Men (thanks)!
- Fix typos
- Use grep to detect missing extensions for consistency withCC_SUPPORT_SAVE_RESTOREMakefile +3
-0@@ -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) +# 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$(PLATFORM_RISCV_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep "zicsr\|zifencei" > /dev/null && echo n || echo y) + # 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 endif ifndef PLATFORM_RISCV_ISA
Makefile ifndef PLATFORM_RISCV_ABI · line 236
Quoted 10 lines
Makefile +5
-1ifneq ($(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
You can add:
Thanks again for taking care of that,
Alex
PATCH 1/1 Makefile: fix build with binutils 2.38
In reply to Aurelien JarnoQuoted 12 lines · Aurelien Jarno
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
Iextension, 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
Quoted 5 lines
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 <[email protected]>
Looks good to me.
We will have to update docs/platform_requirements.md as well but this can be a separate patch.
Regards,
Anup
Quoted 43 lines
--- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)Changes v1 -> v2 following the review from Bin Men (thanks)!
- Fix typos
- Use grep to detect missing extensions for consistency withCC_SUPPORT_SAVE_RESTOREMakefile +8
-2@@ -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) +# 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$(PLATFORM_RISCV_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep "zicsr\|zifencei" > /dev/null && echo n || echo y) + # 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 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 --2.34.1
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
Anup Patel
AppliedPATCH 1/1 Makefile: fix build with binutils 2.38
In reply to Aurelien JarnoQuoted 30 lines · Aurelien Jarno
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
Iextension, 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 1The 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 <[email protected]>--- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)Changes v1 -> v2 following the review from Bin Men (thanks)!
- Fix typos
- Use grep to detect missing extensions for consistency withCC_SUPPORT_SAVE_RESTOREMakefile +0
-0
Makefile OPENSBI_LD_PIE := $(shell $(CC) $(CLANG_TARGET) $(RELAX_FLAG) $(USE_LD_FLAG) -fP · line 157
Quoted 5 lines
Makefile +2
-0@@ -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) +# 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$(PLATFORM_RISCV_XLEN)imafd_zicsr_zifencei -x c /dev/null -o /dev/null 2>&1 | grep "zicsr\|zifencei" > /dev/null && echo n || echo y)
If we are using a multilib RV64 toolchain to compile for RV32 then CC_SUPPORT_ZICSR_ZIFENCEI gets an incorrect value. We can fix this by using OPENSBI_CC_XLEN instead of PLATFORM_RISCV_XLEN in the command. I have taken care of it at the time of merging this patch.
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 25 lines
Makefile +6
-2+ # 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 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 --2.34.1
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi