Skip to content

refactor!: make bootstrap.sh work on mac (draft)#19357

Closed
mverzilli wants to merge 1 commit intonextfrom
martin/make-bootstrap-work-on-mac
Closed

refactor!: make bootstrap.sh work on mac (draft)#19357
mverzilli wants to merge 1 commit intonextfrom
martin/make-bootstrap-work-on-mac

Conversation

@mverzilli
Copy link
Contributor

@mverzilli mverzilli commented Jan 6, 2026

This is the result of tasking Claude Code with getting bootstrap to work locally on a MacBook Pro, with M5 and Tahoe 26.1.

I'm posting it as a PR since it seems a handy way of showing all the tweaks and env work in a single place, but I don't work on these scripts myself so I don't expect this to be merged as-is. All credit goes to Claude!

Changes to the codebase itself are easily reviewable here. I dump below a report of out of band changes that were necessary.

1. Software Installed

Homebrew Packages

brew install bash cmake ninja llvm@20 yarn corepack

  • bash (5.3.9) - Required for bash 4+ features like globstar
  • cmake (3.31+) - Build system
  • ninja - Fast build tool
  • llvm@20 - Clang 20 compiler
  • yarn - Package manager
  • corepack - Node.js package manager manager

Clang 20 Symlinks

Created symlinks in ~/bin/ pointing to Homebrew's LLVM 20:

  mkdir -p ~/bin
  ln -sf /opt/homebrew/Cellar/llvm@20/20.1.8/bin/clang ~/bin/clang-20
  ln -sf /opt/homebrew/Cellar/llvm@20/20.1.8/bin/clang++ ~/bin/clang++-20

Zig Compiler (0.15.1)

  sudo mkdir -p /opt/zig
  cd /opt/zig
  sudo curl -L https://ziglang.org/builds/zig-macos-aarch64-0.15.0-dev.10+6362d8c3a.tar.xz | sudo tar xJ --strip-components=1
  Note: Version 0.15.1 wasn't available, used closest dev build.

Rust Toolchain

  curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  rustup target add wasm32-wasip1

wasi-sdk (for WASM builds)

cd /opt
sudo curl -L https://github.com/aspect-build/aspect-cli/releases/download/wasi-sdk-v0.0.5/wasi-sdk-24.0-arm64-macos.tar.gz | sudo tar xz
sudo mv wasi-sdk-24.0-arm64-macos wasi-sdk


###  Foundry 

curl -L https://foundry.paradigm.xyz | bash
foundryup


###  Node.js (via nvm)

nvm install 24
nvm use 24


##  2. Code Changes

###  2.1 ci3/arch - Architecture Detection Fix

  Problem: The script returned "unknown architecture arm64" on macOS.

  Change:

aarch64|arm64)
echo arm64
;;


###  2.2 barretenberg/cpp/src/barretenberg/bb/CMakeLists.txt - Code Signing

  Problem: The bb binary was killed by macOS (SIGKILL) due to invalid code signature when linked with libavm_transpiler.a.

  Change: Added post-build signing step for both bb and bb-avm targets:

After the bb target definition (around line 42-50):

Re-sign on macOS to fix invalid linker-generated adhoc signature

if(APPLE)
add_custom_command(TARGET bb POST_BUILD
COMMAND codesign -s - -f $<TARGET_FILE:bb>
COMMENT "Re-signing bb binary for macOS"
)
endif()

After the bb-avm target definition (around line 95-101):

Re-sign on macOS to fix invalid linker-generated adhoc signature

if(APPLE)
add_custom_command(TARGET bb-avm POST_BUILD
COMMAND codesign -s - -f $<TARGET_FILE:bb-avm>
COMMENT "Re-signing bb-avm binary for macOS"
)
endif()


###  2.3 barretenberg/cpp/bootstrap.sh - Version Injection Re-signing

  Problem: The inject_version function modifies the binary with dd after building, which invalidates the code signature.

  Change: Added re-signing after version injection in the inject_version function:

At the end of the inject_version function (around line 37-40):

# Re-sign on macOS after modifying the binary (version injection invalidates code signature)
if [[ "$(uname)" == "Darwin" ]]; then
  codesign -s - -f "$binary" 2>/dev/null || true
fi

##  3. Environment Configuration

  Required PATH

  The following PATH must be set for bootstrap to find all tools:

export PATH="/opt/zig:/opt/homebrew/bin:/opt/homebrew/sbin:$HOME/bin:$HOME/.cargo/bin:$HOME/.foundry/bin:$HOME/.nvm/versions/node/v24.12.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"


  Running Bootstrap

cd /path/to/aztec-packages

PATH="/opt/zig:/opt/homebrew/bin:/opt/homebrew/sbin:$HOME/bin:$HOME/.cargo/bin:$HOME/.foundry/bin:$HOME/.nvm/versions/node/v24.12.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/opt/homebrew/bin/bash -c 'source ci3/source && ./bootstrap.sh'


##  4. Root Cause Analysis

###  The Code Signature Issue

  The main blocker was the bb binary being killed immediately by macOS with SIGKILL (Code Signature Invalid). Investigation revealed:

  1. The crash happened during static initialization before main() even ran
  2. macOS crash reports showed: "termination":{"namespace":"CODESIGNING","indicator":"Invalid Page"}
  3. The linker creates an adhoc signature when linking, but it was invalid for binaries linking libavm_transpiler.a (Rust static library)
  4. The inject_version function in bootstrap.sh further modified the binary, invalidating any existing signature

###  Solution

  Two-part fix:
  1. CMake post-build step to re-sign after linking
  2. Bootstrap script re-sign after version injection

@mverzilli mverzilli requested a review from charlielye as a code owner January 6, 2026 16:16
@AztecBot
Copy link
Collaborator

AztecBot commented Jan 6, 2026

Flakey Tests

🤖 says: This CI run detected 2 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (\0338;;http://ci.aztec-labs.com/031741c92d745d7a�031741c92d745d7a8;;�\033): barretenberg/acir_tests/scripts/browser_prove.sh verify_honk_proof webkit (19s) (code: 1) (\033Martin\033: make bootstrap work on mac)
\033FLAKED\033 (\0338;;http://ci.aztec-labs.com/b99f62b29d8c3a73�b99f62b29d8c3a738;;�\033):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_p2p/add_rollup.test.ts (192s) (code: 1) group:e2e-p2p-epoch-flakes (\033Martin\033: make bootstrap work on mac)

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