Skip to content

apollo_compilation_utils: resolve tools root next to the executable when present#14389

Draft
avi-starkware wants to merge 1 commit into
main-v0.14.3from
avi/v0.14.3-exe-relative-tools-root
Draft

apollo_compilation_utils: resolve tools root next to the executable when present#14389
avi-starkware wants to merge 1 commit into
main-v0.14.3from
avi/v0.14.3-exe-relative-tools-root

Conversation

@avi-starkware

Copy link
Copy Markdown
Collaborator

Why

Prebuilt binaries distributed outside Docker (e.g. a natively-built starknet_transaction_prover for macOS) cannot run Sierra→CASM compilation out of the box: binary_path() resolves the sidecar compiler under $CARGO_TOOLS_ROOT (default ~/.cargo/tools), which does not exist on a machine that never ran scripts/install_compiler_binaries.sh. The recipient currently must either install the toolchain and run the script, or know to set CARGO_TOOLS_ROOT manually — neither is documented for binary recipients. (Background: #14379 hit the harsher, unrecoverable variant of this on the privacy release line.)

What

cargo_tools_root() now checks for a tools directory next to the running executable, after the explicit $CARGO_TOOLS_ROOT override but before the cargo-home default. This makes a packaged layout work with zero configuration:

package/
├── starknet_transaction_prover
└── tools/
    └── starknet-sierra-compile-<version>/
        └── bin/starknet-sierra-compile

The tools/ subtree is exactly what scripts/install_compiler_binaries.sh --sierra produces under CARGO_TOOLS_ROOT, so a packaging job can stage it with:

CARGO_TOOLS_ROOT="$PKG_DIR/tools" scripts/install_compiler_binaries.sh --sierra

The version-suffixed directory layout and verify_compiler_binary() checks are unchanged, so a stale package still fails loudly with the exact expected path.

No behavior change for existing setups:

  • Docker images set CARGO_TOOLS_ROOT explicitly (e.g. /opt/cargo-tools) — the env var branch still wins.
  • Dev machines have no tools directory next to target/{debug,release} binaries — the is_dir() guard falls through to ~/.cargo/tools as before.

Validation

  • cargo build -p apollo_compilation_utils — passes
  • SEED=0 cargo test -p apollo_compilation_utils — 10 passed, 0 failed (includes 3 new tests for the exe-relative resolution)
  • cargo clippy -p apollo_compilation_utils --all-targets — clean
  • scripts/rust_fmt.sh — applied

🤖 Generated with Claude Code

…hen present

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants