diff --git a/crates/starknet_sierra_compile/build.rs b/crates/starknet_sierra_compile/build.rs index c9cffecca3..a2000a0538 100644 --- a/crates/starknet_sierra_compile/build.rs +++ b/crates/starknet_sierra_compile/build.rs @@ -40,13 +40,16 @@ fn install_starknet_native_compile() { let binary_name = CAIRO_NATIVE_BINARY_NAME; let required_version = REQUIRED_CAIRO_NATIVE_VERSION; + let repo_root_dir = + infra_utils::path::project_path().expect("Should be able to get the project path"); + // Set the runtime library path. This is required for Cairo native compilation. - let runtime_library_path = repo_root_dir() + let runtime_library_path = repo_root_dir .join("crates/blockifier/cairo_native/target/release/libcairo_native_runtime.a"); println!("cargo:rustc-env=CAIRO_NATIVE_RUNTIME_LIBRARY={}", runtime_library_path.display()); println!("cargo:rerun-if-env-changed=CAIRO_NATIVE_RUNTIME_LIBRARY"); - let starknet_native_compile_crate_path = repo_root_dir().join("crates/bin").join(binary_name); + let starknet_native_compile_crate_path = repo_root_dir.join("crates/bin").join(binary_name); let starknet_native_compile_crate_path_str = starknet_native_compile_crate_path .to_str() .expect("Failed to convert the crate path to str"); @@ -126,10 +129,3 @@ fn out_dir() -> std::path::PathBuf { .expect("Failed to get the build time OUT_DIR environment variable") .into() } - -#[cfg(feature = "cairo_native")] -fn repo_root_dir() -> std::path::PathBuf { - std::path::Path::new(infra_utils::compile_time_cargo_manifest_dir!()) - .join("../..") - .to_path_buf() -} diff --git a/crates/starknet_sierra_compile/src/command_line_compiler.rs b/crates/starknet_sierra_compile/src/command_line_compiler.rs index 0d3bcd52c2..ce324b49f5 100644 --- a/crates/starknet_sierra_compile/src/command_line_compiler.rs +++ b/crates/starknet_sierra_compile/src/command_line_compiler.rs @@ -7,8 +7,6 @@ use cairo_lang_starknet_classes::contract_class::ContractClass; #[cfg(feature = "cairo_native")] use cairo_native::executor::AotContractExecutor; use tempfile::NamedTempFile; -#[cfg(feature = "cairo_native")] -use tempfile::TempDir; use crate::config::SierraToCasmCompilationConfig; use crate::constants::CAIRO_LANG_BINARY_NAME; @@ -66,10 +64,9 @@ impl SierraToNativeCompiler for CommandLineCompiler { contract_class: ContractClass, ) -> Result { let compiler_binary_path = &self.path_to_starknet_native_compile_binary; - let output_dir = - TempDir::new().expect("Failed to create temporary compilation output directory."); - let output_file = output_dir.path().join("output.so"); - let output_file_path = output_file.to_str().ok_or( + + let output_file = NamedTempFile::new()?; + let output_file_path = output_file.path().to_str().ok_or( CompilationUtilError::UnexpectedError("Failed to get output file path".to_owned()), )?; let additional_args = [output_file_path];