Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstam committed Jul 26, 2024
1 parent 245a301 commit 0e51f02
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 106 deletions.
75 changes: 36 additions & 39 deletions library/std/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,50 @@ use std::env;

fn main() {
println!("cargo:rerun-if-changed=build.rs");

let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH was not set");
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS was not set");
let target_vendor =
env::var("CARGO_CFG_TARGET_VENDOR").expect("CARGO_CFG_TARGET_VENDOR was not set");
let target_env = env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV was not set");

if target_os == "netbsd" && env::var("RUSTC_STD_NETBSD10").is_ok() {
println!("cargo:rustc-cfg=netbsd10");
}
if target_os == "linux"
|| target_os == "android"
|| target_os == "netbsd"
|| target_os == "dragonfly"
|| target_os == "openbsd"
|| target_os == "freebsd"
|| target_os == "solaris"
|| target_os == "illumos"
|| target_os == "macos"
|| target_os == "ios"
|| target_os == "tvos"
|| target_os == "watchos"
|| target_os == "visionos"
|| target_os == "windows"
|| target_os == "fuchsia"
|| (target_vendor == "fortanix" && target_env == "sgx")
|| target_os == "hermit"
|| target_os == "l4re"
|| target_os == "redox"
|| target_os == "haiku"
|| target_os == "vxworks"
|| target_arch == "wasm32"
|| target_arch == "wasm64"
|| target_os == "espidf"
|| target_os.starts_with("solid")
|| (target_vendor == "nintendo" && target_env == "newlib")
|| target_os == "vita"
|| target_os == "aix"
|| target_os == "nto"
|| target_os == "xous"
|| target_os == "hurd"
|| target_os == "uefi"
|| target_os == "teeos"
|| target_os == "zkvm"

let target = env::var("TARGET").expect("TARGET was not set");
if target.contains("linux")
|| target.contains("netbsd")
|| target.contains("dragonfly")
|| target.contains("openbsd")
|| target.contains("freebsd")
|| target.contains("solaris")
|| target.contains("illumos")
|| target.contains("apple-darwin")
|| target.contains("apple-ios")
|| target.contains("apple-tvos")
|| target.contains("apple-watchos")
|| target.contains("uwp")
|| target.contains("windows")
|| target.contains("fuchsia")
|| (target.contains("sgx") && target.contains("fortanix"))
|| target.contains("hermit")
|| target.contains("l4re")
|| target.contains("redox")
|| target.contains("haiku")
|| target.contains("vxworks")
|| target.contains("wasm32")
|| target.contains("wasm64")
|| target.contains("asmjs")
|| target.contains("espidf")
|| target.contains("solid")
|| target.contains("nintendo-3ds")
|| target.contains("vita")
|| target.contains("aix")
|| target.contains("nto")
|| target.contains("xous")
|| target.contains("hurd")
|| target.contains("uefi")
|| target.contains("zkvm")
// See src/bootstrap/synthetic_targets.rs
// See src/bootstrap/src/core/build_steps/synthetic_targets.rs
|| env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()
{
// These platforms don't have any special requirements.
Expand All @@ -63,7 +61,6 @@ fn main() {
// - Any new targets that have not been explicitly added above.
println!("cargo:rustc-cfg=feature=\"restricted-std\"");
}

println!("cargo:rustc-env=STD_ENV_ARCH={}", target_arch);
println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap());
println!("cargo:rustc-cfg=backtrace_in_libstd");
}
38 changes: 3 additions & 35 deletions library/std/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,9 @@ pub mod sync;
#[allow(unused_imports)]
pub mod thread_local;

cfg_if::cfg_if! {
if #[cfg(unix)] {
mod unix;
pub use self::unix::*;
} else if #[cfg(windows)] {
mod windows;
pub use self::windows::*;
} else if #[cfg(target_os = "solid_asp3")] {
mod solid;
pub use self::solid::*;
} else if #[cfg(target_os = "hermit")] {
mod hermit;
pub use self::hermit::*;
} else if #[cfg(target_os = "wasi")] {
mod wasi;
pub use self::wasi::*;
} else if #[cfg(target_family = "wasm")] {
mod wasm;
pub use self::wasm::*;
} else if #[cfg(target_os = "xous")] {
mod xous;
pub use self::xous::*;
} else if #[cfg(target_os = "uefi")] {
mod uefi;
pub use self::uefi::*;
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
mod sgx;
pub use self::sgx::*;
} else if #[cfg(target_os = "zkvm")] {
mod zkvm;
pub use self::zkvm::*;
} else {
mod unsupported;
pub use self::unsupported::*;
}
#[cfg(target_os = "zkvm")] {
mod zkvm;
pub use self::zkvm::*;
}

// FIXME(117276): remove this, move feature implementations into individual
Expand Down
14 changes: 2 additions & 12 deletions library/std/src/sys_common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,9 @@ cfg_if::cfg_if! {
target_os = "hermit",
target_os = "solid_asp3"
))] {
pub use crate::sys::net;
} else if #[cfg(any(
target_os = "l4re",
target_os = "zkvm",
target_os = "uefi",
feature = "restricted-std",
all(target_family = "wasm", not(target_os = "emscripten")),
target_os = "xous",
all(target_vendor = "fortanix", target_env = "sgx")
))] {
pub use crate::sys::net;
} else {
pub mod net;
} else {
pub use crate::sys::net;
}
}

Expand Down
6 changes: 2 additions & 4 deletions library/test/src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,8 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu

// Prevent the usage of `Instant` in some cases:
// - It's currently not supported for wasm targets.
// - We disable it for miri because it's not available when isolation is enabled.
let is_instant_unsupported = (cfg!(target_family = "wasm") && !cfg!(target_os = "wasi"))
|| cfg!(target_os = "zkvm")
|| cfg!(miri);
let is_instant_unsupported =
(cfg!(target_family = "wasm") && !cfg!(target_os = "wasi")) || cfg!(target_os = "zkvm");

let start_time = (!is_instant_unsupported).then(Instant::now);
run_tests(opts, tests, |x| on_test_event(&x, &mut st, &mut *out))?;
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
/* Extra values not defined in the built-in targets yet, but used in std */
(Some(Mode::Std), "target_env", Some(&["libnx", "p2"])),
(Some(Mode::Std), "target_os", Some(&["visionos", "zkvm"])),
(Some(Mode::Std), "target_vendor", Some(&["risc0", "succinct"])),
(Some(Mode::Std), "target_arch", Some(&["arm64ec", "spirv", "nvptx", "xtensa", "asmjs"])),
(Some(Mode::Std), "target_vendor", Some(&["succinct"])),
(Some(Mode::Std), "target_arch", Some(&["arm64ec", "spirv", "nvptx", "xtensa"])),
(Some(Mode::ToolStd), "target_os", Some(&["visionos"])),
/* Extra names used by dependencies */
// FIXME: Used by serde_json, but we should not be triggering on external dependencies.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# `riscv32im-curta-zkvm-elf`
# `riscv32im-succinct-zkvm-elf`

**Tier: 3**

RISC Zero's Zero Knowledge Virtual Machine (zkVM) implementing the RV32IM instruction set.
Succinct's Zero Knowledge Virtual Machine (zkVM) implementing the RV32IM instruction set.

## Target maintainers

- Frank Laub, `[email protected]`, https://github.com/flaub
- Jeremy Bruestle, `[email protected]`, https://github.com/jbruestle
- Erik Kaneda, `[email protected]`, https://github.com/SchmErik

## Background

This target is an execution environment to produce a proof of execution of
Expand All @@ -20,7 +16,7 @@ cryptographic seal. This receipt can be verified to ensure the integrity of the
computation and its result. This target is implemented as software only; it has
no hardware implementation.

We have a cargo extension called [cargo-risczero] that allow users to generate
We have a cargo extension called [cargo-prove] that allow users to generate
project templates, install tools for improved user experience, build the binary
using a docker environment and test programs.

Expand All @@ -44,7 +40,7 @@ Calling `extern "C"` on the target uses the C calling convention outlined in the

Programs for the zkVM could be built by adding it to the `target` list in
`config.toml`. However, we recommend building programs in our starter template
generated by the [cargo-risczero] utility and the [curta-build] crate. This
generated by the [cargo-prove] utility and the [sp1-build] crate. This
crate calls `rustc` with `-C "link-arg=-Ttext=` so that it maps the text in the
appropriate location as well as generating variables that represent the ELF and
a unique ID associated with the ELF. The starter template provides developers
Expand All @@ -57,15 +53,15 @@ Rust does not yet ship pre-compiled artifacts for this target. To compile for
this target, you will either need to build Rust with the target enabled (see
"Building the target" above). We do not recommend using `build-std` as we have
run into issues building core in the past on our starter template. An alternate
solution is to download the curta tool chain by running `cargo risczero install`.
solution is to download the SP1 tool chain by running `cargo prove install`.

## Testing

Note: the target is implemented as a software emulator called the zkVM and there
is no hardware implementation of the target.

The most practical way to test the target program is to use our starter template
that can be generated by using the `cargo risczero new` command. The template
that can be generated by using the `cargo prove new` command. The template
generates a sample "host" and "guest" code. The guest code compiled to the
target (which is RV32IM) whereas the "host" code is compiled to run on the
programmer's machine running either a Linux distribution or macOS. The host
Expand All @@ -77,10 +73,9 @@ The target currently does not support running the Rust test suite.
## Cross-compilation toolchains and C code

Compatible C code can be built for this target on any compiler that has a RV32IM
target. On clang and ld.lld linker, it can be generated using the
target. On clang and ld.lld linker, it can be generated using the
`-march=rv32im`, `-mabi=ilp32` with llvm features flag `features=+m` and llvm
target `riscv32-unknown-none`.

[RISC-V specification]: https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf
[cargo-risczero]: https://docs.rs/cargo-risczero/latest/cargo_risczero/
[curta-build]: https://crates.io/crates/curta-build
[sp1-build]: https://crates.io/crates/sp1-build
1 change: 0 additions & 1 deletion tests/ui/check-cfg/well-known-values.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux`
| help: there is a expected value with a similar name: `"linux"`
|
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm`
= note: `#[warn(unexpected_cfgs)]` on by default
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration

warning: 28 warnings emitted
Expand Down

0 comments on commit 0e51f02

Please sign in to comment.