Skip to content

Commit 31e7b80

Browse files
reviewer comments
1 parent 5b5e109 commit 31e7b80

File tree

5 files changed

+8
-17
lines changed

5 files changed

+8
-17
lines changed

compiler/rustc_target/src/spec/targets/riscv32im_unknown_openvm_elf.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ pub(crate) fn target() -> Target {
2222
linker: Some("rust-lld".into()),
2323
cpu: "generic-rv32".into(),
2424

25-
// Some crates (*cough* crossbeam) assume you have 64 bit
26-
// atomics if the target name is not in a hardcoded list.
27-
// Since OpenVM is singlethreaded and all operations are
28-
// atomic, I guess we can just say we support 64-bit
29-
// atomics.
25+
// We set atomic_width to 64 for compatibility with crates such as crossbeam,
26+
// but this should never be triggered since compilation should always lower
27+
// atomics and be single-threaded.
3028
max_atomic_width: Some(64),
3129
atomic_cas: true,
3230

library/std/src/sys/env/openvm.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ pub fn getenv(varname: &OsStr) -> Option<OsString> {
2323
debug_assert_eq!(nbytes, nbytes2);
2424

2525
// Convert to OsString.
26-
//
27-
// FIXME: We can probably get rid of the extra copy here if we
28-
// reimplement "os_str" instead of just using the generic unix
29-
// "os_str".
3026
let u8s: &[u8] = unsafe { crate::slice::from_raw_parts(words.cast() as *const u8, nbytes) };
3127
Some(OsString::from_inner(os_str::Buf { inner: u8s.to_vec() }))
3228
}

library/std/src/sys/pal/openvm/abi.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//! ABI definitions for symbols exported by OpenVM.
22
3-
// Included here so we don't have to depend on OpenVM
4-
3+
// We provide the ABI so that the OpenVM-specific implementations can be provided
4+
// by linking the openvm crate without introducing the crate as a dependency here
55
#![allow(dead_code)]
6-
pub const DIGEST_WORDS: usize = 8;
76

87
/// Standard IO file descriptors for use with sys_read and sys_write.
98
pub mod fileno {
@@ -16,11 +15,9 @@ pub mod fileno {
1615
unsafe extern "C" {
1716
// Wrappers around syscalls provided by OpenVM:
1817
pub fn sys_halt();
19-
pub fn sys_output(output_id: u32, output_value: u32);
2018
pub fn sys_rand(recv_buf: *mut u32, words: usize);
2119
pub fn sys_panic(msg_ptr: *const u8, len: usize) -> !;
2220
pub fn sys_log(msg_ptr: *const u8, len: usize);
23-
pub fn sys_cycle_count() -> usize;
2421
pub fn sys_read(fd: u32, recv_buf: *mut u8, nrequested: usize) -> usize;
2522
pub fn sys_write(fd: u32, write_buf: *const u8, nbytes: usize);
2623
pub fn sys_getenv(

library/std/src/sys/random/openvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn fill_bytes(bytes: &mut [u8]) {
99
}
1010

1111
let mut buf = [0u32; 2];
12-
let len = (pre.len() + post.len() + size_of::<u32>() - 1) / size_of::<u32>();
12+
let len = (pre.len() + post.len()).div_ceil(size_of::<u32>());
1313
if len != 0 {
1414
unsafe { abi::sys_rand(buf.as_mut_ptr(), len) };
1515
}

src/doc/rustc/src/platform-support/riscv32im-unknown-openvm-elf.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ We provide a cargo extension called [cargo-openvm] that provides tools for cross
2020
## Requirements
2121

2222
The target supports cross-compilation from any host and does not support host tools. It supports `alloc` with a
23-
default allocator. Partial support for the Rust `std` library is provided using custom RISC-V instructions and requires the `openvm` crate with the `"std"` feature enabled. Further details and limitations of `std` support are documented [here](https://docs.openvm.dev/book/writing-apps/writing-a-program#rust-std-library-support).
23+
default allocator. Partial support for the Rust `std` library is provided using custom RISC-V instructions and requires the `openvm` crate with the `"std"` feature enabled. Further details and limitations of `std` support are documented [here](https://docs.openvm.dev/book/writing-apps/writing-a-program#rust-std-library-support).
2424

2525
The target's execution environment is single-threaded, non-preemptive, and does not support
2626
privileged instructions. At present, unaligned accesses are not supported and will result in execution traps. The binaries expect no operating system and can be thought
2727
of as running on bare-metal. The target does not use `#[target_feature(...)]` or
28-
`-C target-feature=` values.
28+
`-C target-feature=` values.
2929

3030
Binaries are expected to be ELF.
3131

0 commit comments

Comments
 (0)