[2/2] toolchain-buildroot: add support for RISC-V Instruction Set Architecture

Message ID 6386450f-5970-4998-0840-1552401ea5fb@aries-embedded.de
State New
Headers show
Series
  • support for RISC-V architecture
Related show

Commit Message

Anton Kuzmin July 14, 2018, 7:13 a.m.

Patch

Signed-off-by: Anton Kuzmin <ak@aries-embedded.de>
---
 Makefile                                |  3 ++-
 arch/Config.in.riscv                    | 13 +++++++++++--
 arch/arch.mk.riscv                      | 18 ++++++++++++++++++
 toolchain/toolchain-buildroot/Config.in |  3 ++-
 4 files changed, 33 insertions(+), 4 deletions(-)
 create mode 100644 arch/arch.mk.riscv

diff --git a/Makefile b/Makefile
index 8d25c8a239..5e2302e1d3 100644
--- a/Makefile
+++ b/Makefile
@@ -434,7 +434,8 @@  KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
 	-e s/powerpc64.*/powerpc/ \
 	-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
 	-e s/sh.*/sh/ \
-	-e s/microblazeel/microblaze/)
+	-e s/microblazeel/microblaze/ \
+	-e s/riscv.*/riscv/)
 
 ZCAT := $(call qstrip,$(BR2_ZCAT))
 BZCAT := $(call qstrip,$(BR2_BZCAT))
diff --git a/arch/Config.in.riscv b/arch/Config.in.riscv
index 31c25a92c2..23c5b2da6c 100644
--- a/arch/Config.in.riscv
+++ b/arch/Config.in.riscv
@@ -64,5 +64,14 @@  config BR2_ARCH
 config BR2_ENDIAN
 	default "LITTLE"
 
-config BR2_ARCH_HAS_NO_TOOLCHAIN_BUILDROOT
-	default y
+config BR2_GCC_TARGET_ARCH
+#	Extension characters are appended by arch/arch.mk.riscv file
+	default "rv32i"	if BR2_rv32i
+	default "rv64i"	if BR2_rv64i
+
+config BR2_GCC_TARGET_ABI
+	default "ilp32"	if BR2_rv32i
+	default "lp64"	if BR2_rv64i
+
+config BR2_READELF_ARCH_NAME
+	default "RISC-V"
diff --git a/arch/arch.mk.riscv b/arch/arch.mk.riscv
new file mode 100644
index 0000000000..c8c5763c2c
--- /dev/null
+++ b/arch/arch.mk.riscv
@@ -0,0 +1,18 @@ 
+ifeq ($(BR2_riscv_m),y)
+BR2_GCC_TARGET_ARCH := $(echo $(BR2_GCC_TARGET_ARCH)"m")
+endif
+ifeq ($(BR2_riscv_f),y)
+BR2_GCC_TARGET_ARCH := $(echo $(BR2_GCC_TARGET_ARCH)"f")
+endif
+ifeq ($(BR2_riscv_d),y)
+BR2_GCC_TARGET_ARCH := $(echo $(BR2_GCC_TARGET_ARCH)"d")
+endif
+ifeq ($(BR2_riscv_a),y)
+BR2_GCC_TARGET_ARCH := $(echo $(BR2_GCC_TARGET_ARCH)"a")
+endif
+ifeq ($(BR2_riscv_c),y)
+BR2_GCC_TARGET_ARCH := $(echo $(BR2_GCC_TARGET_ARCH)"c")
+endif
+ifeq ($(BR2_riscv_v),y)
+BR2_GCC_TARGET_ARCH := $(echo $(BR2_GCC_TARGET_ARCH)"v")
+endif
diff --git a/toolchain/toolchain-buildroot/Config.in b/toolchain/toolchain-buildroot/Config.in
index 75e8191f46..6f0af1b936 100644
--- a/toolchain/toolchain-buildroot/Config.in
+++ b/toolchain/toolchain-buildroot/Config.in
@@ -47,7 +47,8 @@  config BR2_TOOLCHAIN_BUILDROOT_GLIBC
 		   BR2_mipsel      || BR2_mips64     || BR2_mips64el|| \
 		   BR2_powerpc     || BR2_powerpc64  || BR2_powerpc64le || \
 		   BR2_sh          || BR2_sparc64    || BR2_x86_64 || \
-		   BR2_microblaze  || BR2_nios2      || BR2_archs38
+		   BR2_microblaze  || BR2_nios2      || BR2_archs38 || \
+		   BR2_riscv
 	depends on BR2_USE_MMU
 	depends on !BR2_STATIC_LIBS
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_2
-- 
2.18.0