Skip to content

Commit

Permalink
fix: additional guards on entrypoint macro (#1659)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuwen Zhang <yuwen01@gmail.com>
  • Loading branch information
sinasab and yuwen01 authored Oct 22, 2024
1 parent 9121fe4 commit d8ce8c4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ sp1-sdk = { path = "crates/sdk", version = "3.0.0" }
sp1-cuda = { path = "crates/cuda", version = "3.0.0" }
sp1-stark = { path = "crates/stark", version = "3.0.0" }
sp1-lib = { path = "crates/zkvm/lib", version = "3.0.0", default-features = false }
sp1-zkvm = { path = "crates/zkvm/entrypoint", version = "3.0.0", default-features = false }

# NOTE: The version in this crate is manually set to 3.0.1 right now. When upgrading SP1 versions,
# make sure to update this crate.
sp1-zkvm = { path = "crates/zkvm/entrypoint", version = "3.0.1", default-features = false }

# p3
p3-air = "0.1.4-succinct"
Expand Down
2 changes: 1 addition & 1 deletion crates/zkvm/entrypoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "sp1-zkvm"
description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM."
readme = "../../../README.md"
version = { workspace = true }
version = "3.0.1"
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
Expand Down
13 changes: 9 additions & 4 deletions crates/zkvm/entrypoint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,27 @@ macro_rules! entrypoint {

use $crate::heap::SimpleAlloc;

#[cfg(target_os = "zkvm")]
#[global_allocator]
static HEAP: SimpleAlloc = SimpleAlloc;

mod zkvm_generated_main {

#[no_mangle]
fn main() {
// Link to the actual entrypoint only when compiling for zkVM. Doing this avoids
// compilation errors when building for the host target.
// Link to the actual entrypoint only when compiling for zkVM, otherwise run a
// simple noop. Doing this avoids compilation errors when building for the host
// target.
//
// Note that, however, it's generally considered wasted effort compiling zkVM
// programs against the host target. This just makes it such that doing so wouldn't
// result in an error, which can happen when building a Cargo workspace containing
// zkVM program crates.
#[cfg(target_os = "zkvm")]
super::ZKVM_ENTRY()
if cfg!(target_os = "zkvm") {
super::ZKVM_ENTRY()
} else {
println!("Not running in zkVM, skipping entrypoint");
}
}
}
};
Expand Down

0 comments on commit d8ce8c4

Please sign in to comment.