Makefile: fix build with binutils 2.38
authorAurelien Jarno <aurelien@aurel32.net>
Fri, 28 Jan 2022 17:33:46 +0000 (18:33 +0100)
committerAnup Patel <anup@brainfault.org>
Fri, 4 Feb 2022 05:17:24 +0000 (10:47 +0530)
commit5d53b55aa77ffeefd4012445dfa6ad3535e1ff2c
tree4bc0fd8cb6c2e4896762945e42abc67a1f7bda8b
parenta26dc609df04ca4704873b683ac03855f20b056e
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.

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>
Makefile