From de0d55cb3c197b13d90922c8998bf90399f3b8a2 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 16 Sep 2020 08:42:39 -0700 Subject: [PATCH 1/9] library/panic_unwind: Add UNWIND_DATA_REG for RISC-V 32-bit Signed-off-by: Alistair Francis --- library/panic_unwind/src/gcc.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs index 85a2a18947db2..81b7b556eb4f0 100644 --- a/library/panic_unwind/src/gcc.rs +++ b/library/panic_unwind/src/gcc.rs @@ -123,6 +123,9 @@ const UNWIND_DATA_REG: (i32, i32) = (0, 1); // R0, R1 #[cfg(target_arch = "riscv64")] const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11 +#[cfg(target_arch = "riscv32")] +const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11 + // The following code is based on GCC's C and C++ personality routines. For reference, see: // https://github.com/gcc-mirror/gcc/blob/master/libstdc++-v3/libsupc++/eh_personality.cc // https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c From 84fe26c4d33924d2195af4324f036b64709baba2 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 16 Sep 2020 08:43:54 -0700 Subject: [PATCH 2/9] library/std: linux: Add support for RISC-V 32-bit Signed-off-by: Alistair Francis --- library/std/src/os/linux/raw.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/std/src/os/linux/raw.rs b/library/std/src/os/linux/raw.rs index a007fd2b6be04..4ff3a6e578984 100644 --- a/library/std/src/os/linux/raw.rs +++ b/library/std/src/os/linux/raw.rs @@ -234,7 +234,8 @@ mod arch { target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", - target_arch = "riscv64" + target_arch = "riscv64", + target_arch = "riscv32" ))] mod arch { pub use libc::{blkcnt_t, blksize_t, ino_t, nlink_t, off_t, stat, time_t}; From cd066c9debeace035d02867a5b5b2d72197f1831 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 16 Sep 2020 08:44:35 -0700 Subject: [PATCH 3/9] library/std: raw: Add support for RISC-V 32-bit Signed-off-by: Alistair Francis --- library/std/src/os/raw/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/std/src/os/raw/mod.rs b/library/std/src/os/raw/mod.rs index 83e8853fe7923..16272aa05712f 100644 --- a/library/std/src/os/raw/mod.rs +++ b/library/std/src/os/raw/mod.rs @@ -22,7 +22,8 @@ mod tests; target_arch = "powerpc", target_arch = "powerpc64", target_arch = "s390x", - target_arch = "riscv64" + target_arch = "riscv64", + target_arch = "riscv32" ) ), all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")), @@ -65,7 +66,8 @@ pub type c_char = u8; target_arch = "powerpc", target_arch = "powerpc64", target_arch = "s390x", - target_arch = "riscv64" + target_arch = "riscv64", + target_arch = "riscv32" ) ), all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")), From cf075355da15c9fb0b1c975649dd13759a78a2bd Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 16 Sep 2020 08:45:08 -0700 Subject: [PATCH 4/9] library/std: sys_common: Add support for RISC-V 32-bit Signed-off-by: Alistair Francis --- library/std/src/sys_common/alloc.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys_common/alloc.rs b/library/std/src/sys_common/alloc.rs index c669410078592..f22476be32560 100644 --- a/library/std/src/sys_common/alloc.rs +++ b/library/std/src/sys_common/alloc.rs @@ -14,7 +14,8 @@ use crate::ptr; target_arch = "powerpc64", target_arch = "asmjs", target_arch = "wasm32", - target_arch = "hexagon" + target_arch = "hexagon", + target_arch = "riscv32" )))] pub const MIN_ALIGN: usize = 8; #[cfg(all(any( From 0f3ccbd662977d9434f8478a379f292c5bb72a8c Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 16 Sep 2020 08:45:49 -0700 Subject: [PATCH 5/9] library/unwind: Add support for RISC-V 32-bit Signed-off-by: Alistair Francis --- library/unwind/src/libunwind.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 0c57861f70a82..2d65ded390916 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -57,6 +57,9 @@ pub const unwinder_private_data_size: usize = 2; #[cfg(target_arch = "riscv64")] pub const unwinder_private_data_size: usize = 2; +#[cfg(target_arch = "riscv32")] +pub const unwinder_private_data_size: usize = 2; + #[cfg(target_os = "emscripten")] pub const unwinder_private_data_size: usize = 20; From 3e942958536aad794cec08a2d2b8d6f125e36bb4 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 16 Sep 2020 09:37:00 -0700 Subject: [PATCH 6/9] tools/build-manifest: Add support for RISC-V 32-bit Signed-off-by: Alistair Francis --- src/tools/build-manifest/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 58022484fa6cc..1e86f7a4737cc 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -110,6 +110,7 @@ static TARGETS: &[&str] = &[ "riscv32i-unknown-none-elf", "riscv32imc-unknown-none-elf", "riscv32imac-unknown-none-elf", + "riscv32gc-unknown-linux-gnu", "riscv64imac-unknown-none-elf", "riscv64gc-unknown-none-elf", "riscv64gc-unknown-linux-gnu", From fd762681666d7fe229acf82a1b7b23476fd96148 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 16 Sep 2020 14:31:42 -0700 Subject: [PATCH 7/9] library/panic_unwind: Consolidate RV32 and RV64 Signed-off-by: Alistair Francis --- library/panic_unwind/src/gcc.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/panic_unwind/src/gcc.rs b/library/panic_unwind/src/gcc.rs index 81b7b556eb4f0..1cfd527b5841a 100644 --- a/library/panic_unwind/src/gcc.rs +++ b/library/panic_unwind/src/gcc.rs @@ -120,10 +120,7 @@ const UNWIND_DATA_REG: (i32, i32) = (24, 25); // I0, I1 #[cfg(target_arch = "hexagon")] const UNWIND_DATA_REG: (i32, i32) = (0, 1); // R0, R1 -#[cfg(target_arch = "riscv64")] -const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11 - -#[cfg(target_arch = "riscv32")] +#[cfg(any(target_arch = "riscv64", target_arch = "riscv32"))] const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11 // The following code is based on GCC's C and C++ personality routines. For reference, see: From 57b2da808c36fa2acf991379cd971639091122f7 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Wed, 16 Sep 2020 15:19:13 -0700 Subject: [PATCH 8/9] library/unwind: Consolidate RV32 and RV64 Signed-off-by: Alistair Francis --- library/unwind/src/libunwind.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 2d65ded390916..677843e12e1be 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -54,10 +54,7 @@ pub const unwinder_private_data_size: usize = 2; #[cfg(target_arch = "sparc64")] pub const unwinder_private_data_size: usize = 2; -#[cfg(target_arch = "riscv64")] -pub const unwinder_private_data_size: usize = 2; - -#[cfg(target_arch = "riscv32")] +#[cfg(any(target_arch = "riscv64", target_arch = "riscv32")] pub const unwinder_private_data_size: usize = 2; #[cfg(target_os = "emscripten")] From 3d1b6d6cc29587ace6895814fa32ec38a49d8a68 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Thu, 17 Sep 2020 07:10:10 -0700 Subject: [PATCH 9/9] library/unwind: Add missing ) Signed-off-by: Alistair Francis --- library/unwind/src/libunwind.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index 677843e12e1be..dcf4fcd4e5aab 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -54,7 +54,7 @@ pub const unwinder_private_data_size: usize = 2; #[cfg(target_arch = "sparc64")] pub const unwinder_private_data_size: usize = 2; -#[cfg(any(target_arch = "riscv64", target_arch = "riscv32")] +#[cfg(any(target_arch = "riscv64", target_arch = "riscv32"))] pub const unwinder_private_data_size: usize = 2; #[cfg(target_os = "emscripten")]