Skip to content

Commit

Permalink
Make cargo build work (#719)
Browse files Browse the repository at this point in the history
Right now a simple `cargo build` fails.  So let's fix that.

This PR also disentangles `ceno_rt`, so that we can work on building
guest programs much easier.

Update: I extracted the remove of the target matrix into
#725 for ease of review.

This PR also enables debug assertions for our tests.
  • Loading branch information
matthiasgoergens authored Dec 13, 2024
1 parent b58ef82 commit af836bf
Show file tree
Hide file tree
Showing 31 changed files with 73 additions and 112 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,17 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
guest/target/
key: integration-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dtolnay/rust-toolchain@nightly

- name: Run example
env:
RAYON_NUM_THREADS: 2
RUSTFLAGS: "-C opt-level=3"
run: cargo run --package ceno_zkvm --example riscv_opcodes -- --start 10 --end 11

- name: Run fibonacci
env:
RAYON_NUM_THREADS: 8
RUST_LOG: debug
RUSTFLAGS: "-C opt-level=3"
run: cargo run --package ceno_zkvm --bin e2e -- --platform=sp1 ceno_zkvm/examples/fibonacci.elf
8 changes: 4 additions & 4 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
examples/target/
guest/target/
key: lint-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install cargo make
Expand All @@ -62,13 +62,13 @@ jobs:
env:
RUSTFLAGS: "-Dwarnings"
run: |
cargo check --workspace --all-targets --exclude ceno_rt
cargo check --workspace --all-targets
# We have a lot of code under #[cfg(not(debug_assertions))] and similar,
# so we need to run cargo check in release mode, too:
cargo check --workspace --all-targets --exclude ceno_rt --release
cargo check --workspace --all-targets --release
cargo make clippy
# Same for clippy:
cargo clippy --workspace --all-targets --exclude ceno_rt --release
cargo clippy --workspace --all-targets --release
- name: Install taplo
run: taplo --version || cargo install taplo-cli
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
examples/target/
guest/target/
key: tests-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install cargo make
Expand Down
87 changes: 19 additions & 68 deletions Cargo.lock

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

10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[workspace]
exclude = ["examples"]
exclude = ["guest"]
members = [
"ceno_emul",
"examples-builder",
"ceno_rt",
"mpcs",
"multilinear_extensions",
"sumcheck",
Expand Down Expand Up @@ -54,6 +53,13 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[profile.dev]
lto = "thin"
# We are running our tests with optimizations turned on to make them faster.
# Please turn optimizations off, when you want accurate stack traces for debugging.
opt-level = 2

[profile.dev.package."*"]
# Set the default for dependencies in Development mode.
opt-level = 3

[profile.release]
lto = "thin"
7 changes: 0 additions & 7 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CORE = { script = ["nproc"] }
RAYON_NUM_THREADS = "${CORE}"

[tasks.tests]
args = [
Expand All @@ -11,10 +9,7 @@ args = [
"--bins",
"--tests",
"--examples",
"--release",
"--workspace",
"--exclude",
"ceno_rt",
]
command = "cargo"
workspace = false
Expand All @@ -34,8 +29,6 @@ args = [
"clippy",
"--workspace",
"--all-targets",
"--exclude",
"ceno_rt",
"--",
"-D",
"warnings",
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ Clippy and check work as usual:
```sh
cargo check
cargo clippy
cargo build
```

Alas, `cargo build` doesn't work. That's a known problem and we're working on it. Please use `cargo make build` instead for now.

### Setting up self-hosted CI docker container

To set up docker container for CI, you can run the following command:
Expand Down
4 changes: 1 addition & 3 deletions ceno_zkvm/Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CORE = { script = ["nproc"] }
RAYON_NUM_THREADS = "${CORE}"

[tasks.riscv_opcodes_flamegraph]
args = ["run", "--package", "ceno_zkvm", "--release", "--example", "riscv_opcodes"]
command = "cargo"
env = { "RUST_LOG" = "debug", "RAYON_NUM_THREADS" = "8" }
env = { "RUST_LOG" = "debug" }
8 changes: 4 additions & 4 deletions examples-builder/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn build_elfs() {
// See git history for an attempt to do this.
let output = Command::new("cargo")
.args(["build", "--release", "--examples"])
.current_dir("../examples")
.current_dir("../guest/examples")
.env_clear()
.envs(std::env::vars().filter(|x| !x.0.starts_with("CARGO_")))
.output()
Expand All @@ -41,11 +41,11 @@ fn build_elfs() {
dest,
r#"#[allow(non_upper_case_globals)]
pub const {example}: &[u8] =
include_bytes!(r"{CARGO_MANIFEST_DIR}/../examples/target/riscv32im-unknown-none-elf/release/examples/{example}");"#
include_bytes!(r"{CARGO_MANIFEST_DIR}/../guest/target/riscv32im-unknown-none-elf/release/examples/{example}");"#
).expect("failed to write vars.rs");
}
let input_path = "../examples/";
let elfs_path = "../examples/target/riscv32im-unknown-none-elf/release/examples/";
let input_path = "../guest/";
let elfs_path = "../guest/target/riscv32im-unknown-none-elf/release/examples/";

println!("cargo:rerun-if-changed={input_path}");
println!("cargo:rerun-if-changed={elfs_path}");
Expand Down
1 change: 0 additions & 1 deletion examples/.cargo/config.toml

This file was deleted.

9 changes: 0 additions & 9 deletions examples/Cargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion examples/rust-toolchain.toml

This file was deleted.

File renamed without changes.
12 changes: 6 additions & 6 deletions examples/Cargo.lock → guest/Cargo.lock

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

Loading

0 comments on commit af836bf

Please sign in to comment.