Skip to content

Commit

Permalink
fix: multiple target cargo build warnings (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-a16z authored Oct 24, 2024
1 parent 847fdd1 commit e61e51e
Show file tree
Hide file tree
Showing 32 changed files with 62 additions and 58 deletions.
4 changes: 0 additions & 4 deletions examples/alloc/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "alloc-guest"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "guest"
path = "./src/lib.rs"

[features]
guest = []

Expand Down
1 change: 0 additions & 1 deletion examples/alloc/guest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

extern crate alloc;
use alloc::vec::Vec;
Expand Down
5 changes: 5 additions & 0 deletions examples/alloc/guest/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[allow(unused_imports)]
use alloc_guest::*;
4 changes: 0 additions & 4 deletions examples/collatz/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "collatz-guest"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "guest"
path = "./src/lib.rs"

[features]
guest = []

Expand Down
1 change: 0 additions & 1 deletion examples/collatz/guest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[jolt::provable]
fn collatz_convergence_range(start: u128, end: u128) -> u128 {
Expand Down
5 changes: 5 additions & 0 deletions examples/collatz/guest/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[allow(unused_imports)]
use collatz_guest::*;
4 changes: 0 additions & 4 deletions examples/fibonacci/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "fibonacci-guest"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "guest"
path = "./src/lib.rs"

[features]
guest = []

Expand Down
1 change: 0 additions & 1 deletion examples/fibonacci/guest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[jolt::provable]
fn fib(n: u32) -> u128 {
Expand Down
5 changes: 5 additions & 0 deletions examples/fibonacci/guest/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[allow(unused_imports)]
use fibonacci_guest::*;
4 changes: 0 additions & 4 deletions examples/muldiv/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "muldiv-guest"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "guest"
path = "./src/lib.rs"

[features]
guest = []

Expand Down
1 change: 0 additions & 1 deletion examples/muldiv/guest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[jolt::provable]
fn muldiv(a: u32, b: u32, c: u32) -> u32 {
Expand Down
5 changes: 5 additions & 0 deletions examples/muldiv/guest/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[allow(unused_imports)]
use muldiv_guest::*;
4 changes: 0 additions & 4 deletions examples/multi-function/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "multi-function-guest"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "guest"
path = "./src/lib.rs"

[features]
guest = []

Expand Down
1 change: 0 additions & 1 deletion examples/multi-function/guest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[jolt::provable]
fn add(x: u32, y: u32) -> u32 {
Expand Down
5 changes: 5 additions & 0 deletions examples/multi-function/guest/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[allow(unused_imports)]
use multi_function_guest::*;
4 changes: 0 additions & 4 deletions examples/sha2-chain/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "sha2-chain-guest"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "guest"
path = "./src/lib.rs"

[features]
guest = []

Expand Down
1 change: 0 additions & 1 deletion examples/sha2-chain/guest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

use sha2::{Digest, Sha256};

Expand Down
5 changes: 5 additions & 0 deletions examples/sha2-chain/guest/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[allow(unused_imports)]
use sha2_chain_guest::*;
4 changes: 0 additions & 4 deletions examples/sha2-ex/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "sha2-guest"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "guest"
path = "./src/lib.rs"

[features]
guest = []

Expand Down
1 change: 0 additions & 1 deletion examples/sha2-ex/guest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

use sha2::{Digest, Sha256};

Expand Down
5 changes: 5 additions & 0 deletions examples/sha2-ex/guest/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[allow(unused_imports)]
use sha2_guest::*;
4 changes: 0 additions & 4 deletions examples/sha3-chain/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "sha3-chain-guest"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "guest"
path = "./src/lib.rs"

[features]
guest = []

Expand Down
1 change: 0 additions & 1 deletion examples/sha3-chain/guest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

use sha3::{Digest, Keccak256};

Expand Down
5 changes: 5 additions & 0 deletions examples/sha3-chain/guest/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[allow(unused_imports)]
use sha3_chain_guest::*;
4 changes: 0 additions & 4 deletions examples/sha3-ex/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "sha3-guest"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "guest"
path = "./src/lib.rs"

[features]
guest = []

Expand Down
1 change: 0 additions & 1 deletion examples/sha3-ex/guest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

use sha3::{Digest, Keccak256};

Expand Down
5 changes: 5 additions & 0 deletions examples/sha3-ex/guest/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![cfg_attr(feature = "guest", no_std)]
#![no_main]

#[allow(unused_imports)]
use sha3_guest::*;
4 changes: 0 additions & 4 deletions examples/stdlib/guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name = "stdlib-guest"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "guest"
path = "./src/lib.rs"

[features]
guest = []

Expand Down
2 changes: 0 additions & 2 deletions examples/stdlib/guest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![no_main]

#[jolt::provable]
fn int_to_string(n: i32) -> String {
n.to_string()
Expand Down
4 changes: 4 additions & 0 deletions examples/stdlib/guest/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![no_main]

#[allow(unused_imports)]
use stdlib_guest::*;
5 changes: 3 additions & 2 deletions jolt-core/src/host/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,16 @@ impl Program {
panic!("failed to compile guest");
}

let elf = format!("{}/{}/release/guest", target, toolchain);
let elf = format!("{}/{}/release/{}", target, toolchain, self.guest);
self.elf = Some(PathBuf::from_str(&elf).unwrap());
}
}

pub fn decode(&mut self) -> (Vec<ELFInstruction>, Vec<(u64, u8)>) {
self.build();
let elf = self.elf.as_ref().unwrap();
let mut elf_file = File::open(elf).unwrap();
let mut elf_file =
File::open(elf).unwrap_or_else(|_| panic!("could not open elf file: {:?}", elf));
let mut elf_contents = Vec::new();
elf_file.read_to_end(&mut elf_contents).unwrap();
tracer::decode(&elf_contents)
Expand Down
15 changes: 10 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ fn create_guest_files(name: &str) -> Result<()> {
let mut lib_file = File::create(format!("{}/guest/src/lib.rs", name))?;
lib_file.write_all(GUEST_LIB.as_bytes())?;

let mut main_file = File::create(format!("{}/guest/src/main.rs", name))?;
main_file.write_all(GUEST_MAIN.as_bytes())?;

Ok(())
}

Expand Down Expand Up @@ -210,10 +213,6 @@ name = "guest"
version = "0.1.0"
edition = "2021"
[[bin]]
name = "guest"
path = "./src/lib.rs"
[features]
guest = []
Expand All @@ -222,7 +221,6 @@ jolt = { package = "jolt-sdk", git = "https://github.com/a16z/jolt" }
"#;

const GUEST_LIB: &str = r#"#![cfg_attr(feature = "guest", no_std)]
#![no_main]
#[jolt::provable]
fn fib(n: u32) -> u128 {
Expand All @@ -238,3 +236,10 @@ fn fib(n: u32) -> u128 {
b
}
"#;

const GUEST_MAIN: &str = r#"#![cfg_attr(feature = "guest", no_std)]
#![no_main]
#[allow(unused_imports)]
use fibonacci_guest::*;
"#;

0 comments on commit e61e51e

Please sign in to comment.