diff mbox series

[uclibc-ng-devel] (fwd) [PATCH] Enable build for RISC-V 32-bit target [ustcymgu@gmail.com]

Message ID YinrOL4QE3PcBVUh@waldemar-brodkorb.de
State Superseded
Headers show
Series [uclibc-ng-devel] (fwd) [PATCH] Enable build for RISC-V 32-bit target [ustcymgu@gmail.com] | expand

Commit Message

Waldemar Brodkorb March 10, 2022, 12:12 p.m. UTC
----- Forwarded message from Yimin Gu <ustcymgu@gmail.com> -----

Date: Thu, 10 Mar 2022 19:57:03 +0800
From: Yimin Gu <ustcymgu@gmail.com>
To: devel@uclibc-ng.org
Cc: wbx@uclibc-ng.org
Subject: [PATCH] Enable build for RISC-V 32-bit target

RISC-V 32-bit No-MMU is not officially supported by Linux kernel, but the
current 64-bit toolchain can be built for 32-bit targets without
substantial code change, thus it's nice to let uclibc compile for rv32
targets. I also managed to get uclibc/busybox running on rv32 QEMU and
FPGA softcore without noticable problem based on this:
https://github.com/damien-lemoal/buildroot.
Note that to compile successfully, these macros need to be added in
the arch/riscv/include/uapi/asm/unistd.h kernel header file:

#define __ARCH_WANT_NEW_STAT
#define __ARCH_WANT_SET_GET_RLIMIT
#define __ARCH_WANT_TIME32_SYSCALLS

Signed-off-by: Yimin Gu <ustcymgu@gmail.com>
---
 libc/sysdeps/linux/riscv64/bits/wordsize.h | 3 ++-
 libc/sysdeps/linux/riscv64/sys/asm.h       | 6 +++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libc/sysdeps/linux/riscv64/bits/wordsize.h
b/libc/sysdeps/linux/riscv64/bits/wordsize.h
index 67a16ba62..1fc649aad 100644
--- a/libc/sysdeps/linux/riscv64/bits/wordsize.h
+++ b/libc/sysdeps/linux/riscv64/bits/wordsize.h
@@ -25,5 +25,6 @@ 
 #if __riscv_xlen == 64
 # define __WORDSIZE_TIME64_COMPAT32 1
 #else
-# error "rv32i-based targets are not supported"
+# define __WORDSIZE_TIME64_COMPAT32 1
+// # warning "rv32i-based targets are experimental"
 #endif
diff --git a/libc/sysdeps/linux/riscv64/sys/asm.h
b/libc/sysdeps/linux/riscv64/sys/asm.h
index ddb84b683..3d0f7afbc 100644
--- a/libc/sysdeps/linux/riscv64/sys/asm.h
+++ b/libc/sysdeps/linux/riscv64/sys/asm.h
@@ -26,7 +26,11 @@ 
 # define REG_S sd
 # define REG_L ld
 #elif __riscv_xlen == 32
-# error "rv32i-based targets are not supported"
+# warning "rv32i-based targets are experimental"
+# define PTRLOG 2
+# define SZREG    4
+# define REG_S sw
+# define REG_L lw
 #else
 # error __riscv_xlen must equal 32 or 64
 #endif