From b830b673e7369fc67ffa57e9a5140185315549d3 Mon Sep 17 00:00:00 2001 From: msizanoen1 Date: Sat, 23 Nov 2019 14:22:05 +0700 Subject: [PATCH 1/3] Add support for RISC-V 64-bit GNU/Linux --- src/libpanic_unwind/gcc.rs | 3 +++ src/libstd/env.rs | 6 ++++++ src/libstd/os/linux/raw.rs | 7 ++++++- src/libstd/os/raw/mod.rs | 6 ++++-- src/libstd/sys/unix/fs.rs | 2 ++ src/libstd/sys_common/alloc.rs | 3 ++- src/libunwind/libunwind.rs | 3 +++ 7 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/libpanic_unwind/gcc.rs b/src/libpanic_unwind/gcc.rs index e5e8e805b6e89..fc90d103ec643 100644 --- a/src/libpanic_unwind/gcc.rs +++ b/src/libpanic_unwind/gcc.rs @@ -130,6 +130,9 @@ 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 + // 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 diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 13fe3bda525ae..af35a5d9b7c47 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -878,6 +878,7 @@ pub mod consts { /// - mips64 /// - powerpc /// - powerpc64 + /// - riscv64 /// - s390x /// - sparc64 #[stable(feature = "env", since = "1.0.0")] @@ -1035,6 +1036,11 @@ mod arch { pub const ARCH: &'static str = "hexagon"; } +#[cfg(target_arch = "riscv64")] +mod arch { + pub const ARCH: &'static str = "riscv64"; +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/libstd/os/linux/raw.rs b/src/libstd/os/linux/raw.rs index d9b2236047bdf..0caec97bb7b90 100644 --- a/src/libstd/os/linux/raw.rs +++ b/src/libstd/os/linux/raw.rs @@ -230,7 +230,12 @@ mod arch { } } -#[cfg(any(target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))] +#[cfg(any( + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + target_arch = "riscv64" +))] mod arch { pub use libc::{blkcnt_t, blksize_t, ino_t, nlink_t, off_t, stat, time_t}; } diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw/mod.rs index e09012007f2d4..47daf0cce1b37 100644 --- a/src/libstd/os/raw/mod.rs +++ b/src/libstd/os/raw/mod.rs @@ -18,7 +18,8 @@ target_arch = "hexagon", target_arch = "powerpc", target_arch = "powerpc64", - target_arch = "s390x" + target_arch = "s390x", + target_arch = "riscv64" ) ), all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")), @@ -60,7 +61,8 @@ pub type c_char = u8; target_arch = "hexagon", target_arch = "powerpc", target_arch = "powerpc64", - target_arch = "s390x" + target_arch = "s390x", + target_arch = "riscv64" ) ), all(target_os = "android", any(target_arch = "aarch64", target_arch = "arm")), diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 26fb0bf10fe3e..1cb6a9d37a989 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -67,6 +67,7 @@ macro_rules! cfg_has_statx { // target_arch = "mips64", // target_arch = "s390x", target_arch = "sparc64", + target_arch = "riscv64", )))] { $($then_tt)* } else { @@ -86,6 +87,7 @@ macro_rules! cfg_has_statx { // target_arch = "mips64", // target_arch = "s390x", target_arch = "sparc64", + target_arch = "riscv64", )))] { $($block_inner)* diff --git a/src/libstd/sys_common/alloc.rs b/src/libstd/sys_common/alloc.rs index 713b9949f6461..c669410078592 100644 --- a/src/libstd/sys_common/alloc.rs +++ b/src/libstd/sys_common/alloc.rs @@ -22,7 +22,8 @@ pub const MIN_ALIGN: usize = 8; target_arch = "aarch64", target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64" + target_arch = "sparc64", + target_arch = "riscv64" )))] pub const MIN_ALIGN: usize = 16; diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index c03b6bf416cbf..dccaf6fd24ca3 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -53,6 +53,9 @@ 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_os = "emscripten")] pub const unwinder_private_data_size: usize = 20; From 34cc3571786fd376f3d40b058f9a6d0a62024d22 Mon Sep 17 00:00:00 2001 From: msizanoen1 Date: Sat, 28 Dec 2019 11:10:17 +0700 Subject: [PATCH 2/3] Update LLVM --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 2cb41005ed5c4..9330ec5a4c1df 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 2cb41005ed5c4747b10d2bf01d8779d3bb4ae32d +Subproject commit 9330ec5a4c1df5fc1fa62f993ed6a04da68cb040 From d61e193cd0867da2fbe81fca349bd1c0afc36d08 Mon Sep 17 00:00:00 2001 From: msizanoen1 Date: Mon, 6 Jan 2020 22:44:57 +0700 Subject: [PATCH 3/3] Update cc crate --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 947c0b8f465b9..d46d3cfb8c337 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -395,9 +395,9 @@ version = "0.1.0" [[package]] name = "cc" -version = "1.0.47" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" +checksum = "e450b8da92aa6f274e7c6437692f9f2ce6d701fb73bacfcf87897b3f89a4c20e" dependencies = [ "jobserver", "num_cpus",