Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native artifact dependency #32

Draft
wants to merge 12 commits into
base: replay
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ TABLEGEN_190_PREFIX = "/usr/lib/llvm-19/"
# https://github.com/rust-lang/rust/issues/39915#issuecomment-618726211
[target.'cfg(all(target_os = "linux"))']
rustflags = ["-Clink-arg=-fuse-ld=lld"]

[unstable]
bindeps = true
4 changes: 2 additions & 2 deletions .github/workflows/replay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
# required to clone native as a git submodule
submodules: recursive
- uses: dtolnay/rust-toolchain@1.82.0
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- uses: Swatinem/rust-cache@v2
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Run cargo clippy
run: |
cd crates/blockifier
cargo clippy --all-targets --all-features --no-deps
cargo +nightly clippy --all-targets --all-features --no-deps

format:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "crates/blockifier/cairo_native"]
path = crates/blockifier/cairo_native
url = https://github.com/lambdaclass/cairo_native
rev = 6a4efafa26d6a0424dee593d2091206c6e9f428d
branch = runtime_artifact_dependency
28 changes: 14 additions & 14 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ cairo-lang-sierra-to-casm = "2.10.0-rc.0"
cairo-lang-starknet-classes = "2.10.0-rc.0"
cairo-lang-utils = "2.10.0-rc.0"
# Important: when updated, make sure to update the cairo-native submodule as well.
cairo-native = { git = "https://github.com/lambdaclass/cairo_native.git", rev = "6a4efafa26d6a0424dee593d2091206c6e9f428d" }
cairo-native = { git = "https://github.com/lambdaclass/cairo_native.git", branch = "runtime_artifact_dependency" }
sierra-emu = { git = "https://github.com/lambdaclass/sierra-emu.git", rev = "b3c9d6bd193b2da881fab3dce57fe12c363aed86" }
cairo-vm = "=1.0.1"
camelpaste = "0.1.0"
Expand Down
4 changes: 2 additions & 2 deletions crates/bin/starknet-native-compile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ license = "Apache-2.0"

[dependencies]
# TODO(Avi, 01/02/2025): Check consistency with the blockifier.
cairo-lang-sierra = "2.9.2"
cairo-lang-starknet-classes = "2.9.2"
cairo-lang-sierra = "2.10.0-rc.0"
cairo-lang-starknet-classes = "2.10.0-rc.0"
cairo-native = "0.2.4"
clap = { version = "4.5.4", features = ["derive"] }
serde_json = "1.0.116"
43 changes: 0 additions & 43 deletions crates/blockifier/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,6 @@ fn compile_cairo_native_aot_runtime() {
cairo_native_dir.to_str().unwrap()
);
}

let runtime_target_dir = cairo_native_dir.join(PathBuf::from("target"));
let status = Command::new("cargo")
.args([
"build",
"--release",
"-p",
"cairo-native-runtime",
"--message-format=json",
"--target-dir",
runtime_target_dir.to_str().unwrap(),
])
.current_dir(cairo_native_dir)
.status()
.expect("Failed to execute cargo");
if !status.success() {
panic!("Building cairo native runtime failed: {status}")
}

let runtime_target_path =
runtime_target_dir.join(PathBuf::from("release/libcairo_native_runtime.a"));

const RUNTIME_LIBRARY: &str = "CAIRO_NATIVE_RUNTIME_LIBRARY";
let runtime_expected_path = {
let expected_path_env =
std::env::var(RUNTIME_LIBRARY).expect("Cairo Native runtime path variable is not set");
let expected_path = PathBuf::from(&expected_path_env);

if expected_path.is_absolute() {
expected_path
} else {
current_dir().expect("Failed to get current directory").join(expected_path)
}
};

std::fs::copy(&runtime_target_path, &runtime_expected_path)
.expect("Failed to copy native runtime");

println!("cargo::rerun-if-changed=./cairo_native/runtime/");
// todo(rodrigo): this directive seems to cause the build script to trigger everytime on
// Linux based machines. Investigate the issue further.
println!("cargo::rerun-if-changed={}", runtime_expected_path.to_str().unwrap());
println!("cargo::rerun-if-env-changed={RUNTIME_LIBRARY}");
}

fn main() {
Expand Down
Loading