Skip to content

Commit

Permalink
Rollup merge of rust-lang#66899 - msizanoen1:riscv-std, r=alexcrichton
Browse files Browse the repository at this point in the history
Standard library support for riscv64gc-unknown-linux-gnu

Add std support for RISC-V 64-bit GNU/Linux and update libc for RISC-V support.

r? @alexcrichton
  • Loading branch information
JohnTitor committed Dec 5, 2019
2 parents ac97356 + 930a0a2 commit d4b923a
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1823,9 +1823,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"

[[package]]
name = "libc"
version = "0.2.64"
version = "0.2.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c"
checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down
3 changes: 3 additions & 0 deletions src/libpanic_unwind/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,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
Expand Down
5 changes: 5 additions & 0 deletions src/libstd/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,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::*;
Expand Down
7 changes: 6 additions & 1 deletion src/libstd/os/linux/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
Expand Down
6 changes: 4 additions & 2 deletions src/libstd/os/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down Expand Up @@ -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")),
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ macro_rules! cfg_has_statx {
// target_arch = "mips64",
// target_arch = "s390x",
target_arch = "sparc64",
target_arch = "riscv64",
)))] {
$($then_tt)*
} else {
Expand All @@ -76,6 +77,7 @@ macro_rules! cfg_has_statx {
// target_arch = "mips64",
// target_arch = "s390x",
target_arch = "sparc64",
target_arch = "riscv64",
)))]
{
$($block_inner)*
Expand Down
3 changes: 2 additions & 1 deletion src/libstd/sys_common/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions src/libunwind/libunwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d4b923a

Please sign in to comment.