diff --git a/Cargo.lock b/Cargo.lock index 06f8b51f0a..30965c8b64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -540,7 +540,7 @@ dependencies = [ "alloy-rlp", "alloy-serde", "alloy-sol-types", - "itertools 0.13.0", + "itertools 0.14.0", "serde", "serde_json", "serde_with", @@ -674,7 +674,7 @@ checksum = "ae9abaedb9123ebe4b1527bc88a0409d65b2727c3de89a289284ba91ad70ae99" dependencies = [ "alloy-json-rpc", "alloy-transport", - "itertools 0.13.0", + "itertools 0.14.0", "reqwest 0.13.2", "serde_json", "tower", @@ -3507,7 +3507,7 @@ dependencies = [ "dyn-clone", "foundry-compilers-artifacts", "foundry-compilers-core", - "itertools 0.13.0", + "itertools 0.14.0", "path-slash", "rayon", "semver 1.0.27", @@ -9615,7 +9615,7 @@ dependencies = [ "derive_more 2.1.1", "dunce", "inturn", - "itertools 0.11.0", + "itertools 0.14.0", "itoa", "normalize-path", "once_map", @@ -9651,7 +9651,7 @@ dependencies = [ "alloy-primitives", "bitflags", "bumpalo", - "itertools 0.11.0", + "itertools 0.14.0", "memchr", "num-bigint 0.4.6", "num-rational", diff --git a/benchmarks/guest/base64_json/src/main.rs b/benchmarks/guest/base64_json/src/main.rs index 3adf07be60..9b28003202 100644 --- a/benchmarks/guest/base64_json/src/main.rs +++ b/benchmarks/guest/base64_json/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/benchmarks/guest/bincode/src/main.rs b/benchmarks/guest/bincode/src/main.rs index 0a5f3e252c..306e9b57ba 100644 --- a/benchmarks/guest/bincode/src/main.rs +++ b/benchmarks/guest/bincode/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/benchmarks/guest/bubblesort/src/main.rs b/benchmarks/guest/bubblesort/src/main.rs index ccbe1db7e0..3581422e95 100644 --- a/benchmarks/guest/bubblesort/src/main.rs +++ b/benchmarks/guest/bubblesort/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/benchmarks/guest/ecrecover/src/main.rs b/benchmarks/guest/ecrecover/src/main.rs index 2028f26a38..75222975d7 100644 --- a/benchmarks/guest/ecrecover/src/main.rs +++ b/benchmarks/guest/ecrecover/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/benchmarks/guest/fibonacci/src/main.rs b/benchmarks/guest/fibonacci/src/main.rs index b907f1a705..37006d6789 100644 --- a/benchmarks/guest/fibonacci/src/main.rs +++ b/benchmarks/guest/fibonacci/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::{read, reveal_u64}; diff --git a/benchmarks/guest/fibonacci_iterative/src/main.rs b/benchmarks/guest/fibonacci_iterative/src/main.rs index d25c83abb7..636d916053 100644 --- a/benchmarks/guest/fibonacci_iterative/src/main.rs +++ b/benchmarks/guest/fibonacci_iterative/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/benchmarks/guest/fibonacci_recursive/src/main.rs b/benchmarks/guest/fibonacci_recursive/src/main.rs index 5bfffb20ed..e50c74e689 100644 --- a/benchmarks/guest/fibonacci_recursive/src/main.rs +++ b/benchmarks/guest/fibonacci_recursive/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/benchmarks/guest/keccak256/src/main.rs b/benchmarks/guest/keccak256/src/main.rs index 0bb07be5d7..16bb17e0a4 100644 --- a/benchmarks/guest/keccak256/src/main.rs +++ b/benchmarks/guest/keccak256/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/benchmarks/guest/keccak256_iter/src/main.rs b/benchmarks/guest/keccak256_iter/src/main.rs index f17ad699a9..b7a73d7b91 100644 --- a/benchmarks/guest/keccak256_iter/src/main.rs +++ b/benchmarks/guest/keccak256_iter/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/benchmarks/guest/kitchen-sink/src/main.rs b/benchmarks/guest/kitchen-sink/src/main.rs index c76050343c..fd8a016d66 100644 --- a/benchmarks/guest/kitchen-sink/src/main.rs +++ b/benchmarks/guest/kitchen-sink/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/benchmarks/guest/pairing/src/main.rs b/benchmarks/guest/pairing/src/main.rs index 438a2e4c65..5e3ee44e11 100644 --- a/benchmarks/guest/pairing/src/main.rs +++ b/benchmarks/guest/pairing/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/benchmarks/guest/quicksort/src/main.rs b/benchmarks/guest/quicksort/src/main.rs index 363dfd1f14..a5a87487c0 100644 --- a/benchmarks/guest/quicksort/src/main.rs +++ b/benchmarks/guest/quicksort/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/benchmarks/guest/regex/src/main.rs b/benchmarks/guest/regex/src/main.rs index c469dcd51f..8081472c30 100644 --- a/benchmarks/guest/regex/src/main.rs +++ b/benchmarks/guest/regex/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/benchmarks/guest/revm_snailtracer/src/main.rs b/benchmarks/guest/revm_snailtracer/src/main.rs index a98f699ac3..b91edfcb5e 100644 --- a/benchmarks/guest/revm_snailtracer/src/main.rs +++ b/benchmarks/guest/revm_snailtracer/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/benchmarks/guest/revm_transfer/src/main.rs b/benchmarks/guest/revm_transfer/src/main.rs index 9a69405ea2..3c251505db 100644 --- a/benchmarks/guest/revm_transfer/src/main.rs +++ b/benchmarks/guest/revm_transfer/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] //! Program to match the workload of diff --git a/benchmarks/guest/rkyv/src/main.rs b/benchmarks/guest/rkyv/src/main.rs index 0f11cedb6a..83acb2c8b7 100644 --- a/benchmarks/guest/rkyv/src/main.rs +++ b/benchmarks/guest/rkyv/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/benchmarks/guest/sha256/src/main.rs b/benchmarks/guest/sha256/src/main.rs index c4c261e4df..5c58cc9305 100644 --- a/benchmarks/guest/sha256/src/main.rs +++ b/benchmarks/guest/sha256/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/benchmarks/guest/sha256_iter/src/main.rs b/benchmarks/guest/sha256_iter/src/main.rs index f09ca65cb8..75aa431d73 100644 --- a/benchmarks/guest/sha256_iter/src/main.rs +++ b/benchmarks/guest/sha256_iter/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/benchmarks/guest/sha2_bench/src/main.rs b/benchmarks/guest/sha2_bench/src/main.rs index 42b28edb16..ce896fe96a 100644 --- a/benchmarks/guest/sha2_bench/src/main.rs +++ b/benchmarks/guest/sha2_bench/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/crates/cli/templates/main.rs b/crates/cli/templates/main.rs index 2f3590bd4d..da6af3522e 100644 --- a/crates/cli/templates/main.rs +++ b/crates/cli/templates/main.rs @@ -1,5 +1,5 @@ // src/main.rs -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::{read, reveal_u64}; diff --git a/crates/cli/tests/programs/fibonacci/src/main.rs b/crates/cli/tests/programs/fibonacci/src/main.rs index 762644c694..31ef048195 100644 --- a/crates/cli/tests/programs/fibonacci/src/main.rs +++ b/crates/cli/tests/programs/fibonacci/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/crates/cli/tests/programs/multi/calculator/examples/fibonacci.rs b/crates/cli/tests/programs/multi/calculator/examples/fibonacci.rs index e66d0c91f3..b14ed5458c 100644 --- a/crates/cli/tests/programs/multi/calculator/examples/fibonacci.rs +++ b/crates/cli/tests/programs/multi/calculator/examples/fibonacci.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/crates/cli/tests/programs/multi/calculator/src/main.rs b/crates/cli/tests/programs/multi/calculator/src/main.rs index 3545517b3f..5317839422 100644 --- a/crates/cli/tests/programs/multi/calculator/src/main.rs +++ b/crates/cli/tests/programs/multi/calculator/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use calculator::count_primes; diff --git a/crates/cli/tests/programs/multi/string-utils/examples/palindrome.rs b/crates/cli/tests/programs/multi/string-utils/examples/palindrome.rs index 9ebcff8da2..c678cf8fe1 100644 --- a/crates/cli/tests/programs/multi/string-utils/examples/palindrome.rs +++ b/crates/cli/tests/programs/multi/string-utils/examples/palindrome.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/crates/cli/tests/programs/multi/string-utils/src/main.rs b/crates/cli/tests/programs/multi/string-utils/src/main.rs index f868d98fd5..b5ddb67cf1 100644 --- a/crates/cli/tests/programs/multi/string-utils/src/main.rs +++ b/crates/cli/tests/programs/multi/string-utils/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/crates/continuations/programs/examples/fibonacci.rs b/crates/continuations/programs/examples/fibonacci.rs index b907f1a705..37006d6789 100644 --- a/crates/continuations/programs/examples/fibonacci.rs +++ b/crates/continuations/programs/examples/fibonacci.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::{read, reveal_u64}; diff --git a/crates/continuations/programs/examples/multiple.rs b/crates/continuations/programs/examples/multiple.rs index d87edc7ab1..e6127160ca 100644 --- a/crates/continuations/programs/examples/multiple.rs +++ b/crates/continuations/programs/examples/multiple.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::read; diff --git a/crates/sdk/guest/fib/src/main.rs b/crates/sdk/guest/fib/src/main.rs index d342f4d3ab..ea4c513e85 100644 --- a/crates/sdk/guest/fib/src/main.rs +++ b/crates/sdk/guest/fib/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/crates/sdk/guest/little/src/main.rs b/crates/sdk/guest/little/src/main.rs index 1e47f88689..bbae4d8cf4 100644 --- a/crates/sdk/guest/little/src/main.rs +++ b/crates/sdk/guest/little/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/crates/sdk/guest/p256/src/main.rs b/crates/sdk/guest/p256/src/main.rs index e2fae918ad..ada9a98d8f 100644 --- a/crates/sdk/guest/p256/src/main.rs +++ b/crates/sdk/guest/p256/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/crates/sdk/programs/examples/fibonacci.rs b/crates/sdk/programs/examples/fibonacci.rs index b907f1a705..37006d6789 100644 --- a/crates/sdk/programs/examples/fibonacci.rs +++ b/crates/sdk/programs/examples/fibonacci.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::{read, reveal_u64}; diff --git a/crates/sdk/programs/examples/verify-stark.rs b/crates/sdk/programs/examples/verify-stark.rs index 56698e76f7..2fef3b6f44 100644 --- a/crates/sdk/programs/examples/verify-stark.rs +++ b/crates/sdk/programs/examples/verify-stark.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/crates/toolchain/build/src/lib.rs b/crates/toolchain/build/src/lib.rs index 72e547be5e..66bfdb1d2e 100644 --- a/crates/toolchain/build/src/lib.rs +++ b/crates/toolchain/build/src/lib.rs @@ -19,16 +19,15 @@ pub use self::config::GuestOptions; mod config; -/// Custom rustc target for the openvm guest. The JSON spec lives at -/// `.json` next to this crate. -pub const RUSTC_TARGET: &str = "riscv64im-openvm-none-elf"; +/// Custom rustc target for the openvm guest. +pub const RUSTC_TARGET: &str = "riscv64im-unknown-openvm-elf"; /// Directory containing the target JSON; passed to cargo as `RUST_TARGET_PATH`. pub fn rustc_target_spec_dir() -> &'static Path { Path::new(env!("CARGO_MANIFEST_DIR")) } /// The default Rust toolchain name to use if OPENVM_RUST_TOOLCHAIN is not set -pub const DEFAULT_RUSTUP_TOOLCHAIN_NAME: &str = "nightly-2026-01-18"; +pub const DEFAULT_RUSTUP_TOOLCHAIN_NAME: &str = "openvm-rv64"; /// Get the Rust toolchain name from environment variable or default pub fn get_rustup_toolchain_name() -> String { @@ -251,7 +250,8 @@ fn sanitized_cmd(tool: &str) -> Command { /// Creates a std::process::Command to execute the given cargo /// command in an environment suitable for targeting the zkvm guest. -pub fn cargo_command(subcmd: &str, rust_flags: &[&str]) -> Command { +/// If `with_std` is true, `std` is added to the `-Zbuild-std` crate list. +pub fn cargo_command(subcmd: &str, rust_flags: &[&str], with_std: bool) -> Command { let toolchain = format!("+{}", get_rustup_toolchain_name()); let rustc = sanitized_cmd("rustup") @@ -271,12 +271,12 @@ pub fn cargo_command(subcmd: &str, rust_flags: &[&str]) -> Command { args.push("--locked"); } - args.extend_from_slice(&[ - "-Z", - "build-std=alloc,core,panic_abort", - "-Z", - "build-std-features=compiler-builtins-mem", - ]); + let build_std = if with_std { + "build-std=alloc,core,panic_abort,std" + } else { + "build-std=alloc,core,panic_abort" + }; + args.extend_from_slice(&["-Z", build_std, "-Z", "build-std-features=compiler-builtins-mem"]); println!("Building guest package: cargo {}", args.join(" ")); @@ -398,16 +398,23 @@ pub fn build_generic(guest_opts: &GuestOptions) -> Result> // Check if the required toolchain and rust-src component are installed, and if not, install // them. This requires that `rustup` is installed. - if let Err(code) = ensure_toolchain_installed(&get_rustup_toolchain_name(), &["rust-src"]) { - eprintln!("rustup toolchain commands failed. Please ensure rustup is installed (https://www.rust-lang.org/tools/install)"); - return Err(Some(code)); + // Skip for linked toolchains (e.g. custom-built rustc) where rustup component commands + // don't apply — the toolchain is expected to already include rust-src. + let toolchain_name = get_rustup_toolchain_name(); + let is_linked_toolchain = !toolchain_name.contains("nightly") && !toolchain_name.contains("stable") && !toolchain_name.contains("beta"); + if !is_linked_toolchain { + if let Err(code) = ensure_toolchain_installed(&toolchain_name, &["rust-src"]) { + eprintln!("rustup toolchain commands failed. Please ensure rustup is installed (https://www.rust-lang.org/tools/install)"); + return Err(Some(code)); + } } let target_dir = guest_opts.target_dir.as_ref().unwrap(); fs::create_dir_all(target_dir).unwrap(); let rust_flags: Vec<_> = guest_opts.rustc_flags.iter().map(|s| s.as_str()).collect(); - let mut cmd = cargo_command("build", &rust_flags); + let with_std = guest_opts.features.iter().any(|f| f == "std"); + let mut cmd = cargo_command("build", &rust_flags, with_std); if !guest_opts.features.is_empty() { cmd.args(["--features", guest_opts.features.join(",").as_str()]); diff --git a/crates/toolchain/openvm/src/lib.rs b/crates/toolchain/openvm/src/lib.rs index 7811ae3f94..9424da3458 100644 --- a/crates/toolchain/openvm/src/lib.rs +++ b/crates/toolchain/openvm/src/lib.rs @@ -20,6 +20,8 @@ pub use openvm_riscv_guest::*; #[cfg(openvm_intrinsics)] mod getrandom; +#[cfg(openvm_intrinsics)] +mod pal_abi; pub mod io; pub mod process; pub mod serde; @@ -71,7 +73,7 @@ fn _fault() -> ! { /// /// fn main() { } /// ``` -#[cfg(all(not(feature = "std"), openvm_intrinsics))] +#[cfg(openvm_intrinsics)] #[macro_export] macro_rules! entry { ($path:path) => { @@ -88,9 +90,8 @@ macro_rules! entry { } }; } -/// This macro does nothing. You should name the function `main` so that the normal rust main -/// function setup is used. -#[cfg(any(feature = "std", not(openvm_intrinsics)))] +/// This macro does nothing when not compiling for the guest target. +#[cfg(not(openvm_intrinsics))] #[macro_export] macro_rules! entry { ($path:path) => {}; diff --git a/crates/toolchain/openvm/src/pal_abi.rs b/crates/toolchain/openvm/src/pal_abi.rs new file mode 100644 index 0000000000..c2ebe374a2 --- /dev/null +++ b/crates/toolchain/openvm/src/pal_abi.rs @@ -0,0 +1,234 @@ +/// For rust std library compatibility, we need to define the ABI specified in +/// +/// while we are using target = "riscv64im-unknown-openvm-elf". +use openvm_platform::{fileno::*, memory::sys_alloc_aligned, rust_rt::terminate, WORD_SIZE}; +use openvm_riscv_guest::{hint_buffer_chunked, hint_random, raw_print_str_from_bytes}; + +const DIGEST_WORDS: usize = 8; + +pub mod exit_code { + pub const SUCCESS: u8 = 0; + pub const PANIC: u8 = 1; + pub const UNIMP: u8 = 2; + // Temporarily use 4 to detect if halt is called. + pub const HALT: u8 = 4; + pub const PAUSE: u8 = 5; +} + +/// # Safety +/// +/// `out_state` must be aligned and dereferenceable. +// [inline(never)] is added to mitigate potentially leaking information about program execution +// through the final value of the program counter (pc) on halt where there is more than one +// location in the program where `sys_halt` is called. As long as the halt instruction only exists +// in one place within the program, the pc will always be the same invariant with input. +#[inline(never)] +#[no_mangle] +pub extern "C" fn sys_halt(_user_exit: u8, _out_state: *const [u32; DIGEST_WORDS]) -> ! { + terminate::<{ exit_code::HALT }>(); + unreachable!() +} + +/// Not used +#[no_mangle] +pub extern "C" fn sys_output(_output_id: u32, _output_value: u32) { + terminate::<{ exit_code::UNIMP }>(); +} + +/// # Safety +/// +/// `out_state`, `in_state`, `block1_ptr`, and `block2_ptr` must be aligned and +/// dereferenceable. +#[inline(always)] +#[no_mangle] +pub unsafe extern "C" fn sys_sha_compress( + _out_state: *mut [u32; DIGEST_WORDS], + _in_state: *const [u32; DIGEST_WORDS], + _block1_ptr: *const [u32; DIGEST_WORDS], + _block2_ptr: *const [u32; DIGEST_WORDS], +) { + unreachable!("sha_compress should not be part of PAL") +} + +/// # Safety +/// +/// `out_state`, `in_state`, and `buf` must be aligned and dereferenceable. +#[inline(always)] +#[no_mangle] +pub unsafe extern "C" fn sys_sha_buffer( + _out_state: *mut [u32; DIGEST_WORDS], + _in_state: *const [u32; DIGEST_WORDS], + _buf: *const u8, + _count: u32, +) { + unreachable!("sha_buffer should not be part of PAL") +} + +/// # Safety +/// +/// `recv_buf` must be aligned and dereferenceable. +#[no_mangle] +pub unsafe extern "C" fn sys_rand(recv_buf: *mut u32, words: usize) { + hint_random(words); + hint_buffer_chunked(recv_buf as *mut u8, words); +} + +/// # Safety +/// +/// `msg_ptr` must be aligned and dereferenceable. +#[no_mangle] +unsafe extern "C" fn sys_panic(msg_ptr: *const u8, len: usize) -> ! { + raw_print_str_from_bytes(msg_ptr, len); + terminate::<{ exit_code::PANIC }>(); + unreachable!() +} + +/// # Safety +/// +/// `msg_ptr` must be aligned and dereferenceable. +#[no_mangle] +pub unsafe extern "C" fn sys_log(msg_ptr: *const u8, len: usize) { + raw_print_str_from_bytes(msg_ptr, len); +} + +/// Cycle count +#[no_mangle] +pub extern "C" fn sys_cycle_count() -> u64 { + crate::io::println("TODO"); + terminate::<{ exit_code::UNIMP }>(); + 0u64 +} + +/// Reads the given number of bytes into the given buffer, posix-style. Returns +/// the number of bytes actually read. On end of file, returns 0. +/// +/// Like POSIX read, this is not guaranteed to read all bytes +/// requested. If we haven't reached EOF, it is however guaranteed to +/// read at least one byte. +/// +/// Users should prefer a higher-level abstraction. +/// +/// # Safety +/// +/// `recv_ptr` must be aligned and dereferenceable. +#[no_mangle] +pub unsafe extern "C" fn sys_read(_fd: u32, _recv_ptr: *mut u8, _nread: usize) -> usize { + crate::io::println("sys_read is todo"); + terminate::<{ exit_code::UNIMP }>(); + 0 +} + +/// Reads up to the given number of words into the buffer [recv_buf, +/// recv_buf + nwords). Returns the number of bytes actually read. +/// sys_read_words is a more efficient interface than sys_read, but +/// varies from POSIX semantics. Notably: +/// +/// * The read length is specified in words, not bytes. (The output +/// length is still returned in bytes) +/// +/// * If not all data is available, `sys_read_words` will return a short read. +/// +/// * recv_buf must be word-aligned. +/// +/// * Return a short read in the case of EOF mid-way through. +/// +/// # Safety +/// +/// `recv_ptr' must be a word-aligned pointer and point to a region of +/// `nwords' size. +#[no_mangle] +pub unsafe extern "C" fn sys_read_words(_fd: u32, _recv_ptr: *mut u32, _nwords: usize) -> usize { + crate::io::println("sys_read_words is todo"); + terminate::<{ exit_code::UNIMP }>(); + 0 +} + +/// # Safety +/// +/// `write_ptr` must be aligned and dereferenceable. +#[no_mangle] +pub unsafe extern "C" fn sys_write(fd: u32, write_ptr: *const u8, nbytes: usize) { + if fd == STDOUT || fd == STDERR { + // We always print to host stdout using UTF-8 encoding. + raw_print_str_from_bytes(write_ptr, nbytes); + } else { + use core::fmt::Write; + let mut writer = crate::io::Writer; + let _ = write!(writer, "sys_write to fd={fd} not supported.\n"); + terminate::<{ exit_code::UNIMP }>(); + } +} + +/// Retrieves the value of an environment variable, and stores as much +/// of it as it can it in the memory at [out_words, out_words + +/// out_nwords). +/// +/// Returns the length of the value, in bytes, or usize::MAX if the variable is +/// not set. +/// +/// This is normally called twice to read an environment variable: +/// Once to get the length of the value, and once to fill in allocated +/// memory. +/// +/// NOTE: Repeated calls to sys_getenv are not guaranteed to result in the same +/// data being returned. Returned data is entirely in the control of the host. +/// +/// # Safety +/// +/// `out_words` and `varname` must be aligned and dereferenceable. +#[no_mangle] +pub unsafe extern "C" fn sys_getenv( + _out_words: *mut u32, + _out_nwords: usize, + _varname: *const u8, + _varname_len: usize, +) -> usize { + crate::io::println("sys_getenv is todo; returning 0"); + 0 +} + +/// Retrieves the count of arguments provided to program execution. +/// +/// NOTE: Repeated calls to sys_argc are not guaranteed to result in the same +/// data being returned. Returned data is entirely in the control of the host. +#[no_mangle] +pub extern "C" fn sys_argc() -> usize { + crate::io::println("sys_argc is todo; returning 0"); + 0 +} + +/// Retrieves the argument with arg_index, and stores as much +/// of it as it can it in the memory at [out_words, out_words + +/// out_nwords). +/// +/// Returns the length, in bytes, of the argument string. If the requested +/// argument index does not exist (i.e. `arg_index` >= argc) then this syscall +/// will not return. +/// +/// This is normally called twice to read an argument: Once to get the length of +/// the value, and once to fill in allocated memory. +/// +/// NOTE: Repeated calls to sys_argv are not guaranteed to result in the same +/// data being returned. Returned data is entirely in the control of the host. +/// +/// # Safety +/// +/// `out_words` must be aligned and dereferenceable. +#[no_mangle] +pub unsafe extern "C" fn sys_argv( + _out_words: *mut u32, + _out_nwords: usize, + _arg_index: usize, +) -> usize { + crate::io::println("sys_argv is todo; returning 0"); + 0 +} + +/// Deprecated, use `sys_alloc_aligned` instead. +#[no_mangle] +#[deprecated] +pub extern "C" fn sys_alloc_words(nwords: usize) -> *mut u32 { + unsafe { sys_alloc_aligned(WORD_SIZE * nwords, WORD_SIZE) as *mut u32 } +} + +// sys_alloc_aligned is already extern no_mangle exported from openvm_platform::memory diff --git a/crates/toolchain/platform/Cargo.toml b/crates/toolchain/platform/Cargo.toml index 5f082d2e96..33f0bb7dec 100644 --- a/crates/toolchain/platform/Cargo.toml +++ b/crates/toolchain/platform/Cargo.toml @@ -13,7 +13,7 @@ openvm-riscv-guest.workspace = true # This crate should have as few dependencies as possible so it can be # used as many places as possible to share the platform definitions. -[target.'cfg(all(target_arch = "riscv64", target_os = "none"))'.dependencies] +[target.'cfg(all(target_arch = "riscv64", any(target_os = "none", target_os = "openvm")))'.dependencies] critical-section = { workspace = true, optional = true } embedded-alloc = { version = "0.6.0", features = [ "allocator_api", diff --git a/examples/algebra/src/main.rs b/examples/algebra/src/main.rs index 1d521f3f89..54a74b8704 100644 --- a/examples/algebra/src/main.rs +++ b/examples/algebra/src/main.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/examples/ecc/src/main.rs b/examples/ecc/src/main.rs index 454cad235c..0bd76a0ee2 100644 --- a/examples/ecc/src/main.rs +++ b/examples/ecc/src/main.rs @@ -1,5 +1,5 @@ // [!region imports] -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use hex_literal::hex; diff --git a/examples/i256/src/main.rs b/examples/i256/src/main.rs index 04ca7a8445..dee68244ff 100644 --- a/examples/i256/src/main.rs +++ b/examples/i256/src/main.rs @@ -1,5 +1,5 @@ #![allow(clippy::needless_range_loop)] -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use core::array; diff --git a/examples/keccak/src/main.rs b/examples/keccak/src/main.rs index dc9250b067..715c3ccbd6 100644 --- a/examples/keccak/src/main.rs +++ b/examples/keccak/src/main.rs @@ -1,5 +1,5 @@ // [!region imports] -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/examples/pairing/src/main.rs b/examples/pairing/src/main.rs index 1791e993f1..bef83f4c8c 100644 --- a/examples/pairing/src/main.rs +++ b/examples/pairing/src/main.rs @@ -1,5 +1,5 @@ // [!region pre] -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use hex_literal::hex; diff --git a/examples/sha2/src/main.rs b/examples/sha2/src/main.rs index 2d73f7afdb..1b14312920 100644 --- a/examples/sha2/src/main.rs +++ b/examples/sha2/src/main.rs @@ -1,5 +1,5 @@ // [!region imports] -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/examples/u256/src/main.rs b/examples/u256/src/main.rs index 67aa120a2b..83f39be29b 100644 --- a/examples/u256/src/main.rs +++ b/examples/u256/src/main.rs @@ -1,5 +1,5 @@ #![allow(clippy::needless_range_loop)] -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use core::array; diff --git a/extensions/algebra/tests/programs/examples/complex_redundant_modulus.rs b/extensions/algebra/tests/programs/examples/complex_redundant_modulus.rs index a17d3e4d5b..c1c7321bcf 100644 --- a/extensions/algebra/tests/programs/examples/complex_redundant_modulus.rs +++ b/extensions/algebra/tests/programs/examples/complex_redundant_modulus.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/algebra/tests/programs/examples/complex_secp256k1.rs b/extensions/algebra/tests/programs/examples/complex_secp256k1.rs index 8ecae56365..041cbad507 100644 --- a/extensions/algebra/tests/programs/examples/complex_secp256k1.rs +++ b/extensions/algebra/tests/programs/examples/complex_secp256k1.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/algebra/tests/programs/examples/complex_two_moduli.rs b/extensions/algebra/tests/programs/examples/complex_two_moduli.rs index 752a861301..266e7cbeec 100644 --- a/extensions/algebra/tests/programs/examples/complex_two_moduli.rs +++ b/extensions/algebra/tests/programs/examples/complex_two_moduli.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/algebra/tests/programs/examples/invalid_setup.rs b/extensions/algebra/tests/programs/examples/invalid_setup.rs index b9e697f3f5..27e0de7e57 100644 --- a/extensions/algebra/tests/programs/examples/invalid_setup.rs +++ b/extensions/algebra/tests/programs/examples/invalid_setup.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/algebra/tests/programs/examples/little.rs b/extensions/algebra/tests/programs/examples/little.rs index d5218c35e6..c68d997975 100644 --- a/extensions/algebra/tests/programs/examples/little.rs +++ b/extensions/algebra/tests/programs/examples/little.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/algebra/tests/programs/examples/moduli_setup.rs b/extensions/algebra/tests/programs/examples/moduli_setup.rs index 3ea841d45e..ee05430a33 100644 --- a/extensions/algebra/tests/programs/examples/moduli_setup.rs +++ b/extensions/algebra/tests/programs/examples/moduli_setup.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/algebra/tests/programs/examples/sqrt.rs b/extensions/algebra/tests/programs/examples/sqrt.rs index 7f86ab1d0a..d37ebcb32c 100644 --- a/extensions/algebra/tests/programs/examples/sqrt.rs +++ b/extensions/algebra/tests/programs/examples/sqrt.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/deferral/tests/programs/examples/multiple.rs b/extensions/deferral/tests/programs/examples/multiple.rs index a85c99edec..f181f591d9 100644 --- a/extensions/deferral/tests/programs/examples/multiple.rs +++ b/extensions/deferral/tests/programs/examples/multiple.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm_deferral_guest::{deferred_compute, get_deferred_output, Commit}; diff --git a/extensions/deferral/tests/programs/examples/single.rs b/extensions/deferral/tests/programs/examples/single.rs index f559f84843..140bb6f696 100644 --- a/extensions/deferral/tests/programs/examples/single.rs +++ b/extensions/deferral/tests/programs/examples/single.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm_deferral_guest::{deferred_compute, get_deferred_output, Commit}; diff --git a/extensions/ecc/tests/programs/examples/decompress.rs b/extensions/ecc/tests/programs/examples/decompress.rs index 0f833275fb..6673c7d058 100644 --- a/extensions/ecc/tests/programs/examples/decompress.rs +++ b/extensions/ecc/tests/programs/examples/decompress.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use core::ops::Neg; diff --git a/extensions/ecc/tests/programs/examples/ec.rs b/extensions/ecc/tests/programs/examples/ec.rs index 5984674719..8fcc56d0c1 100644 --- a/extensions/ecc/tests/programs/examples/ec.rs +++ b/extensions/ecc/tests/programs/examples/ec.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use hex_literal::hex; diff --git a/extensions/ecc/tests/programs/examples/ec_nonzero_a.rs b/extensions/ecc/tests/programs/examples/ec_nonzero_a.rs index 478d49a351..7599f350e1 100644 --- a/extensions/ecc/tests/programs/examples/ec_nonzero_a.rs +++ b/extensions/ecc/tests/programs/examples/ec_nonzero_a.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use hex_literal::hex; diff --git a/extensions/ecc/tests/programs/examples/ec_two_curves.rs b/extensions/ecc/tests/programs/examples/ec_two_curves.rs index d3d20b8f49..840e53a8f7 100644 --- a/extensions/ecc/tests/programs/examples/ec_two_curves.rs +++ b/extensions/ecc/tests/programs/examples/ec_two_curves.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use hex_literal::hex; diff --git a/extensions/ecc/tests/programs/examples/ecdsa.rs b/extensions/ecc/tests/programs/examples/ecdsa.rs index 775dd919d0..9e05aecaec 100644 --- a/extensions/ecc/tests/programs/examples/ecdsa.rs +++ b/extensions/ecc/tests/programs/examples/ecdsa.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] #![allow(unused_imports)] diff --git a/extensions/ecc/tests/programs/examples/ecdsa_recover_k256.rs b/extensions/ecc/tests/programs/examples/ecdsa_recover_k256.rs index f1994ba3c3..3a81227e31 100644 --- a/extensions/ecc/tests/programs/examples/ecdsa_recover_k256.rs +++ b/extensions/ecc/tests/programs/examples/ecdsa_recover_k256.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/ecc/tests/programs/examples/ecdsa_recover_p256.rs b/extensions/ecc/tests/programs/examples/ecdsa_recover_p256.rs index 988ff5226e..81babb406e 100644 --- a/extensions/ecc/tests/programs/examples/ecdsa_recover_p256.rs +++ b/extensions/ecc/tests/programs/examples/ecdsa_recover_p256.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/ecc/tests/programs/examples/invalid_setup.rs b/extensions/ecc/tests/programs/examples/invalid_setup.rs index e29072ae57..03f1380e9b 100644 --- a/extensions/ecc/tests/programs/examples/invalid_setup.rs +++ b/extensions/ecc/tests/programs/examples/invalid_setup.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm_ecc_guest::CyclicGroup; diff --git a/extensions/ecc/tests/programs/examples/sec1_decode.rs b/extensions/ecc/tests/programs/examples/sec1_decode.rs index 31a5053f08..64219fbdb9 100644 --- a/extensions/ecc/tests/programs/examples/sec1_decode.rs +++ b/extensions/ecc/tests/programs/examples/sec1_decode.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/riscv/tests/programs/examples/collatz.rs b/extensions/riscv/tests/programs/examples/collatz.rs index f592befffe..5e326aba42 100644 --- a/extensions/riscv/tests/programs/examples/collatz.rs +++ b/extensions/riscv/tests/programs/examples/collatz.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/extensions/riscv/tests/programs/examples/fibonacci.rs b/extensions/riscv/tests/programs/examples/fibonacci.rs index 762644c694..31ef048195 100644 --- a/extensions/riscv/tests/programs/examples/fibonacci.rs +++ b/extensions/riscv/tests/programs/examples/fibonacci.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/extensions/riscv/tests/programs/examples/getrandom.rs b/extensions/riscv/tests/programs/examples/getrandom.rs index 7664b62960..9e4feb3286 100644 --- a/extensions/riscv/tests/programs/examples/getrandom.rs +++ b/extensions/riscv/tests/programs/examples/getrandom.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "getrandom-v02")] compile_error!("this program is not compatible with getrandom v0.2"); diff --git a/extensions/riscv/tests/programs/examples/getrandom_v02.rs b/extensions/riscv/tests/programs/examples/getrandom_v02.rs index 70a66dc4f0..7779fd9936 100644 --- a/extensions/riscv/tests/programs/examples/getrandom_v02.rs +++ b/extensions/riscv/tests/programs/examples/getrandom_v02.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] #[cfg(feature = "getrandom")] compile_error!("this program is not compatible with getrandom v0.2"); diff --git a/extensions/riscv/tests/programs/examples/hashmap.rs b/extensions/riscv/tests/programs/examples/hashmap.rs index 2968f4761d..cfed27a682 100644 --- a/extensions/riscv/tests/programs/examples/hashmap.rs +++ b/extensions/riscv/tests/programs/examples/hashmap.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/extensions/riscv/tests/programs/examples/heap_overflow.rs b/extensions/riscv/tests/programs/examples/heap_overflow.rs index 080b15296b..070f12ad56 100644 --- a/extensions/riscv/tests/programs/examples/heap_overflow.rs +++ b/extensions/riscv/tests/programs/examples/heap_overflow.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use alloc::vec; diff --git a/extensions/riscv/tests/programs/examples/hint.rs b/extensions/riscv/tests/programs/examples/hint.rs index 42d9ec6044..f3871891a6 100644 --- a/extensions/riscv/tests/programs/examples/hint.rs +++ b/extensions/riscv/tests/programs/examples/hint.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::read_vec; diff --git a/extensions/riscv/tests/programs/examples/hint_large_buffer.rs b/extensions/riscv/tests/programs/examples/hint_large_buffer.rs index 0f8507e94e..8558b358d3 100644 --- a/extensions/riscv/tests/programs/examples/hint_large_buffer.rs +++ b/extensions/riscv/tests/programs/examples/hint_large_buffer.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::read_vec; diff --git a/extensions/riscv/tests/programs/examples/load_x0.rs b/extensions/riscv/tests/programs/examples/load_x0.rs index f281b625dd..3ce1cf6c4f 100644 --- a/extensions/riscv/tests/programs/examples/load_x0.rs +++ b/extensions/riscv/tests/programs/examples/load_x0.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use core::arch::asm; diff --git a/extensions/riscv/tests/programs/examples/print.rs b/extensions/riscv/tests/programs/examples/print.rs index d5d077a5dd..1043107ff0 100644 --- a/extensions/riscv/tests/programs/examples/print.rs +++ b/extensions/riscv/tests/programs/examples/print.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::print; diff --git a/extensions/riscv/tests/programs/examples/read.rs b/extensions/riscv/tests/programs/examples/read.rs index bd861383ed..4f8ce9b736 100644 --- a/extensions/riscv/tests/programs/examples/read.rs +++ b/extensions/riscv/tests/programs/examples/read.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; use openvm::io::read; diff --git a/extensions/riscv/tests/programs/examples/reveal.rs b/extensions/riscv/tests/programs/examples/reveal.rs index 886dd54691..cb3aff3b6d 100644 --- a/extensions/riscv/tests/programs/examples/reveal.rs +++ b/extensions/riscv/tests/programs/examples/reveal.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::{reveal_bytes32, reveal_u64}; diff --git a/extensions/riscv/tests/programs/examples/tiny-mem-test.rs b/extensions/riscv/tests/programs/examples/tiny-mem-test.rs index c0b0ecaf4e..e75438def4 100644 --- a/extensions/riscv/tests/programs/examples/tiny-mem-test.rs +++ b/extensions/riscv/tests/programs/examples/tiny-mem-test.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; use alloc::vec::Vec; diff --git a/guest-libs/ff_derive/tests/programs/examples/batch_inversion.rs b/guest-libs/ff_derive/tests/programs/examples/batch_inversion.rs index c1fdc2e6ec..b8f164a1f6 100644 --- a/guest-libs/ff_derive/tests/programs/examples/batch_inversion.rs +++ b/guest-libs/ff_derive/tests/programs/examples/batch_inversion.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/guest-libs/ff_derive/tests/programs/examples/constants.rs b/guest-libs/ff_derive/tests/programs/examples/constants.rs index 1feb22b307..a6e62df17f 100644 --- a/guest-libs/ff_derive/tests/programs/examples/constants.rs +++ b/guest-libs/ff_derive/tests/programs/examples/constants.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/guest-libs/ff_derive/tests/programs/examples/fermat.rs b/guest-libs/ff_derive/tests/programs/examples/fermat.rs index 41d2526df8..8e552f2a62 100644 --- a/guest-libs/ff_derive/tests/programs/examples/fermat.rs +++ b/guest-libs/ff_derive/tests/programs/examples/fermat.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/guest-libs/ff_derive/tests/programs/examples/from_u128.rs b/guest-libs/ff_derive/tests/programs/examples/from_u128.rs index 7bc6c4c141..7bdf55452f 100644 --- a/guest-libs/ff_derive/tests/programs/examples/from_u128.rs +++ b/guest-libs/ff_derive/tests/programs/examples/from_u128.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/guest-libs/ff_derive/tests/programs/examples/full_limbs.rs b/guest-libs/ff_derive/tests/programs/examples/full_limbs.rs index 0b5580c029..0ce06099d6 100644 --- a/guest-libs/ff_derive/tests/programs/examples/full_limbs.rs +++ b/guest-libs/ff_derive/tests/programs/examples/full_limbs.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/guest-libs/ff_derive/tests/programs/examples/operations.rs b/guest-libs/ff_derive/tests/programs/examples/operations.rs index fa9d47f25b..9b85738518 100644 --- a/guest-libs/ff_derive/tests/programs/examples/operations.rs +++ b/guest-libs/ff_derive/tests/programs/examples/operations.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/guest-libs/ff_derive/tests/programs/examples/sqrt.rs b/guest-libs/ff_derive/tests/programs/examples/sqrt.rs index 52a80248bb..c0b4f227bb 100644 --- a/guest-libs/ff_derive/tests/programs/examples/sqrt.rs +++ b/guest-libs/ff_derive/tests/programs/examples/sqrt.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] openvm::entry!(main); diff --git a/guest-libs/k256/tests/programs/examples/add.rs b/guest-libs/k256/tests/programs/examples/add.rs index db97d1b462..23fd907827 100644 --- a/guest-libs/k256/tests/programs/examples/add.rs +++ b/guest-libs/k256/tests/programs/examples/add.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use elliptic_curve::{group::Curve, CurveArithmetic, Group}; diff --git a/guest-libs/k256/tests/programs/examples/ecdsa.rs b/guest-libs/k256/tests/programs/examples/ecdsa.rs index 1305ccf213..797e2c5fda 100644 --- a/guest-libs/k256/tests/programs/examples/ecdsa.rs +++ b/guest-libs/k256/tests/programs/examples/ecdsa.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/guest-libs/k256/tests/programs/examples/linear_combination.rs b/guest-libs/k256/tests/programs/examples/linear_combination.rs index ff24b93cab..1bba368a22 100644 --- a/guest-libs/k256/tests/programs/examples/linear_combination.rs +++ b/guest-libs/k256/tests/programs/examples/linear_combination.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use elliptic_curve::{ops::LinearCombination, Group, PrimeField}; diff --git a/guest-libs/k256/tests/programs/examples/mul.rs b/guest-libs/k256/tests/programs/examples/mul.rs index 2d8e7a9d08..f0798a9bd1 100644 --- a/guest-libs/k256/tests/programs/examples/mul.rs +++ b/guest-libs/k256/tests/programs/examples/mul.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use elliptic_curve::{CurveArithmetic, Group, PrimeField}; diff --git a/guest-libs/k256/tests/programs/examples/scalar_sqrt.rs b/guest-libs/k256/tests/programs/examples/scalar_sqrt.rs index 4392fc01da..af30c788e7 100644 --- a/guest-libs/k256/tests/programs/examples/scalar_sqrt.rs +++ b/guest-libs/k256/tests/programs/examples/scalar_sqrt.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use elliptic_curve::{CurveArithmetic, Field, PrimeField}; diff --git a/guest-libs/keccak256/tests/programs/examples/keccak.rs b/guest-libs/keccak256/tests/programs/examples/keccak.rs index 6d02324dfc..8c91bc202e 100644 --- a/guest-libs/keccak256/tests/programs/examples/keccak.rs +++ b/guest-libs/keccak256/tests/programs/examples/keccak.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/guest-libs/p256/tests/programs/examples/add.rs b/guest-libs/p256/tests/programs/examples/add.rs index 0f4ae63854..16dde04d58 100644 --- a/guest-libs/p256/tests/programs/examples/add.rs +++ b/guest-libs/p256/tests/programs/examples/add.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use elliptic_curve::{group::Curve, CurveArithmetic, Group}; diff --git a/guest-libs/p256/tests/programs/examples/ecdsa.rs b/guest-libs/p256/tests/programs/examples/ecdsa.rs index 4447de455b..6d9193db0c 100644 --- a/guest-libs/p256/tests/programs/examples/ecdsa.rs +++ b/guest-libs/p256/tests/programs/examples/ecdsa.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/guest-libs/p256/tests/programs/examples/linear_combination.rs b/guest-libs/p256/tests/programs/examples/linear_combination.rs index fd31ddadec..bcc31fbcc6 100644 --- a/guest-libs/p256/tests/programs/examples/linear_combination.rs +++ b/guest-libs/p256/tests/programs/examples/linear_combination.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use elliptic_curve::{ops::LinearCombination, Group, PrimeField}; diff --git a/guest-libs/p256/tests/programs/examples/mul.rs b/guest-libs/p256/tests/programs/examples/mul.rs index 7c05d962a2..855fa63045 100644 --- a/guest-libs/p256/tests/programs/examples/mul.rs +++ b/guest-libs/p256/tests/programs/examples/mul.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use elliptic_curve::{CurveArithmetic, Group, PrimeField}; diff --git a/guest-libs/p256/tests/programs/examples/scalar_sqrt.rs b/guest-libs/p256/tests/programs/examples/scalar_sqrt.rs index 045afe89a8..785fb5287d 100644 --- a/guest-libs/p256/tests/programs/examples/scalar_sqrt.rs +++ b/guest-libs/p256/tests/programs/examples/scalar_sqrt.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use elliptic_curve::{CurveArithmetic, Field, PrimeField}; diff --git a/guest-libs/pairing/tests/programs/examples/bls_ec.rs b/guest-libs/pairing/tests/programs/examples/bls_ec.rs index 63ce641a75..d29433b551 100644 --- a/guest-libs/pairing/tests/programs/examples/bls_ec.rs +++ b/guest-libs/pairing/tests/programs/examples/bls_ec.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] #[allow(unused_imports)] diff --git a/guest-libs/pairing/tests/programs/examples/bls_final_exp_hint.rs b/guest-libs/pairing/tests/programs/examples/bls_final_exp_hint.rs index a96d9e90d0..eadf0b2a8d 100644 --- a/guest-libs/pairing/tests/programs/examples/bls_final_exp_hint.rs +++ b/guest-libs/pairing/tests/programs/examples/bls_final_exp_hint.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/guest-libs/pairing/tests/programs/examples/bn_ec.rs b/guest-libs/pairing/tests/programs/examples/bn_ec.rs index 922c537171..ddd138dd5b 100644 --- a/guest-libs/pairing/tests/programs/examples/bn_ec.rs +++ b/guest-libs/pairing/tests/programs/examples/bn_ec.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] #[allow(unused_imports)] diff --git a/guest-libs/pairing/tests/programs/examples/bn_final_exp_hint.rs b/guest-libs/pairing/tests/programs/examples/bn_final_exp_hint.rs index 1a1a02ba48..f83a4f0a60 100644 --- a/guest-libs/pairing/tests/programs/examples/bn_final_exp_hint.rs +++ b/guest-libs/pairing/tests/programs/examples/bn_final_exp_hint.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/guest-libs/pairing/tests/programs/examples/fp12_mul.rs b/guest-libs/pairing/tests/programs/examples/fp12_mul.rs index 031b793cd3..e08841f2b1 100644 --- a/guest-libs/pairing/tests/programs/examples/fp12_mul.rs +++ b/guest-libs/pairing/tests/programs/examples/fp12_mul.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] #![allow(unused_imports)] diff --git a/guest-libs/pairing/tests/programs/examples/pairing_check.rs b/guest-libs/pairing/tests/programs/examples/pairing_check.rs index 9e19684200..15311149ce 100644 --- a/guest-libs/pairing/tests/programs/examples/pairing_check.rs +++ b/guest-libs/pairing/tests/programs/examples/pairing_check.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] #![allow(unused_imports)] diff --git a/guest-libs/pairing/tests/programs/examples/pairing_check_fallback.rs b/guest-libs/pairing/tests/programs/examples/pairing_check_fallback.rs index 1a9fecaf6c..149ba0638d 100644 --- a/guest-libs/pairing/tests/programs/examples/pairing_check_fallback.rs +++ b/guest-libs/pairing/tests/programs/examples/pairing_check_fallback.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] #![allow(unused_imports)] diff --git a/guest-libs/pairing/tests/programs/examples/pairing_line.rs b/guest-libs/pairing/tests/programs/examples/pairing_line.rs index 2790d7c2e7..5890483c10 100644 --- a/guest-libs/pairing/tests/programs/examples/pairing_line.rs +++ b/guest-libs/pairing/tests/programs/examples/pairing_line.rs @@ -1,5 +1,5 @@ #![allow(unused_imports)] -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::read_vec; diff --git a/guest-libs/pairing/tests/programs/examples/pairing_miller_loop.rs b/guest-libs/pairing/tests/programs/examples/pairing_miller_loop.rs index f40b830e91..bc2484bcad 100644 --- a/guest-libs/pairing/tests/programs/examples/pairing_miller_loop.rs +++ b/guest-libs/pairing/tests/programs/examples/pairing_miller_loop.rs @@ -1,5 +1,5 @@ #![allow(unused_imports)] -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/guest-libs/pairing/tests/programs/examples/pairing_miller_step.rs b/guest-libs/pairing/tests/programs/examples/pairing_miller_step.rs index 726420f4d2..bc368cccc6 100644 --- a/guest-libs/pairing/tests/programs/examples/pairing_miller_step.rs +++ b/guest-libs/pairing/tests/programs/examples/pairing_miller_step.rs @@ -1,5 +1,5 @@ #![allow(unused_imports)] -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm::io::read_vec; diff --git a/guest-libs/sha2/tests/programs/examples/sha2.rs b/guest-libs/sha2/tests/programs/examples/sha2.rs index 3f106e4239..4c639dce64 100644 --- a/guest-libs/sha2/tests/programs/examples/sha2.rs +++ b/guest-libs/sha2/tests/programs/examples/sha2.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] extern crate alloc; diff --git a/guest-libs/sha2/tests/programs/examples/sha2_reset.rs b/guest-libs/sha2/tests/programs/examples/sha2_reset.rs index 56a20100cb..412f08ad3d 100644 --- a/guest-libs/sha2/tests/programs/examples/sha2_reset.rs +++ b/guest-libs/sha2/tests/programs/examples/sha2_reset.rs @@ -1,4 +1,4 @@ -#![cfg_attr(target_os = "none", no_main)] +#![cfg_attr(any(target_os = "none", target_os = "openvm"), no_main)] #![cfg_attr(not(feature = "std"), no_std)] use openvm_sha2::{Digest, Sha256, Sha384, Sha512};