Skip to content

[DO NOT MERGE] chore: alternative macos bootstrap#19379

Closed
Thunkar wants to merge 1 commit intonextfrom
gj/boostrap_on_mac_alternative
Closed

[DO NOT MERGE] chore: alternative macos bootstrap#19379
Thunkar wants to merge 1 commit intonextfrom
gj/boostrap_on_mac_alternative

Conversation

@Thunkar
Copy link
Contributor

@Thunkar Thunkar commented Jan 7, 2026

Based on: #19357, but attempting to minimize conditionals for MacOS. It essentially relies on overriding the FreeBSD bundled utils with GNU's, and correctly configuring the path to have a "seamless" experience.

Also had to add a few more XDG_CACHE_HOME fixes due to GNU parallel setting it wrongly.

Finally, fixed the noir-projects compilation issue that has haunted me forever (not only on Mac, but on my Linux desktop too) due to JSON corruption when processing noir contracts. This particular fix was heavily influenced by Claude, so reviewer beware!

1. Software Installed

Homebrew Packages

brew install bash cmake ninja llvm@20 doxygen coreutils grep gnu-sed

  • 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
  • doxygen - BB docs
  • coreutils - Use GNU utils, not FreeBSD's
  • grep - GNU grep

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/download/0.15.1/zig-aarch64-macos-0.15.1.tar.xz | sudo tar xJ --strip-components=1

Rust Toolchain

  curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.85```

###  wasi-sdk (for WASM builds)

  cd /opt
  sudo curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.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 -i v1.4.1     

Node.js (via nvm)

  nvm install 22
  nvm use 22

Node packages

 npm i -g yarn solhint
 corepack enable

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

2.4

Change the shebang in all our scripts to use #!/usr/bin/env bash. This way MacOS uses the homebrew installed bash version with globstar support.

3. Environment Configuration

Add the following to ~/.zshrc (assuming Mac's default shell):

export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:${PATH}"
export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:${PATH}"
export PATH="/opt/homebrew/opt/grep/libexec/gnubin:${PATH}"
export PATH="/opt/zig:${PATH}"
export PATH="/opt/homebrew/bin:${PATH}"
export PATH="/opt/homebrew/sbin:${PATH}"
export PATH="$HOME/bin:${PATH}"
export PATH="$HOME/.cargo/bin:${PATH}"
export PATH="$HOME/.foundry/bin:${PATH}"

@Thunkar Thunkar requested review from ludamad and mverzilli January 7, 2026 11:11
@Thunkar Thunkar self-assigned this Jan 7, 2026
@Thunkar Thunkar force-pushed the gj/boostrap_on_mac_alternative branch from f42f308 to 6b35575 Compare January 21, 2026 13:53
- Add CoreFoundation framework linking for bb/bb-avm on Apple
- Re-sign bb/bb-avm binaries post-build to fix adhoc signature issues
- Increase gtest_discover_tests timeout on macOS for Gatekeeper checks
- Fix bash compatibility (use bash arrays, OSTYPE detection)
- Various shell script portability fixes for macOS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Thunkar Thunkar force-pushed the gj/boostrap_on_mac_alternative branch from a5e74e4 to de6a6af Compare February 3, 2026 14:42
@AztecBot
Copy link
Collaborator

AztecBot commented Feb 3, 2026

⚠️ Docs Examples Validation Failed

TypeScript validation

(truncated)...
➤�[39m �[90mYN0000�[39m: ┌ Link step
aztecjs_connection	�[94m➤�[39m �[90mYN0000�[39m: └ Completed
aztecjs_connection	�[94m➤�[39m �[90mYN0000�[39m: ┌ Link step
aztecjs_getting_started	�[94m➤�[39m �[90mYN0000�[39m: ┌ Resolution step
aztecjs_advanced	�[93m➤�[39m �]8;;https://yarnpkg.com/advanced/error-codes#yn0072---nm_preserve_symlinks_required�YN0072�]8;;�: │ The application uses portals and that's why �[96m--preserve-symlinks�[39m Node option is required for launching it
aztecjs_advanced	�[94m➤�[39m �[90mYN0000�[39m: └ Completed
aztecjs_authwit	�[93m➤�[39m �]8;;https://yarnpkg.com/advanced/error-codes#yn0072---nm_preserve_symlinks_required�YN0072�]8;;�: │ The application uses portals and that's why �[96m--preserve-symlinks�[39m Node option is required for launching it
aztecjs_authwit	�[94m➤�[39m �[90mYN0000�[39m: └ Completed
aztecjs_advanced	�[93m➤�[39m YN0000: · Done with warnings in 0s 55ms
aztecjs_connection	�[93m➤�[39m �]8;;https://yarnpkg.com/advanced/error-codes#yn0072---nm_preserve_symlinks_required�YN0072�]8;;�: │ The application uses portals and that's why �[96m--preserve-symlinks�[39m Node option is required for launching it
aztecjs_getting_started	�[94m➤�[39m �]8;;https://yarnpkg.com/advanced/error-codes#yn0085---updated_resolution_record�YN0085�]8;;�: │ �[32m+�[39m �[91m@aztec/�[39m�[91maccounts�[39m�[96m@�[39m�[96mlink:/home/aztec-dev/aztec-packages/yarn-project/accounts::locator=aztecjs_getting_started%40workspace%3A.�[39m, and �[93m3�[39m more.
aztecjs_connection	�[94m➤�[39m �[90mYN0000�[39m: └ Completed
aztecjs_getting_started	�[94m➤�[39m �[90mYN0000�[39m: └ Completed
aztecjs_getting_started	�[94m➤�[39m �[90mYN0000�[39m: ┌ Fetch step
aztecjs_authwit	�[93m➤�[39m YN0000: · Done with warnings in 0s 51ms
aztecjs_getting_started	�[94m➤�[39m �[90mYN0000�[39m: └ Completed
aztecjs_connection	�[93m➤�[39m YN0000: · Done with warnings in 0s 46ms
aztecjs_getting_started	�[94m➤�[39m �[90mYN0000�[39m: ┌ Link step
aztecjs_getting_started	�[93m➤�[39m �]8;;https://yarnpkg.com/advanced/error-codes#yn0072---nm_preserve_symlinks_required�YN0072�]8;;�: │ The application uses portals and that's why �[96m--preserve-symlinks�[39m Node option is required for launching it
aztecjs_getting_started	�[94m➤�[39m �[90mYN0000�[39m: └ Completed
aztecjs_getting_started	�[93m➤�[39m YN0000: · Done with warnings in 0s 49ms
aztecjs_advanced	Verifying linked packages...
aztecjs_authwit	Verifying linked packages...
aztecjs_advanced	✓ @aztec/aztec.js: 77 .d.ts files
aztecjs_connection	Verifying linked packages...
aztecjs_authwit	✓ @aztec/aztec.js: 77 .d.ts files
aztecjs_advanced	✓ @aztec/accounts: 27 .d.ts files
aztecjs_connection	✓ @aztec/aztec.js: 77 .d.ts files
aztecjs_authwit	✓ @aztec/accounts: 27 .d.ts files
aztecjs_advanced	✓ @aztec/test-wallet: 8 .d.ts files
aztecjs_connection	✓ @aztec/accounts: 27 .d.ts files
aztecjs_authwit	✓ @aztec/test-wallet: 8 .d.ts files
aztecjs_advanced	✓ @aztec/noir-contracts.js: 33 .d.ts files
aztecjs_connection	✓ @aztec/test-wallet: 8 .d.ts files
aztecjs_getting_started	Verifying linked packages...
aztecjs_authwit	✓ @aztec/noir-contracts.js: 33 .d.ts files
aztecjs_connection	✓ @aztec/noir-contracts.js: 33 .d.ts files
aztecjs_advanced	✓ @aztec/ethereum: 85 .d.ts files
aztecjs_getting_started	✓ @aztec/aztec.js: 77 .d.ts files
aztecjs_getting_started	✓ @aztec/accounts: 27 .d.ts files
aztecjs_advanced	✓ @aztec/stdlib: 475 .d.ts files
aztecjs_getting_started	✓ @aztec/test-wallet: 8 .d.ts files
aztecjs_getting_started	✓ @aztec/noir-contracts.js: 33 .d.ts files
aztecjs_advanced	Type checking 'aztecjs_advanced'...
aztecjs_getting_started	Type checking 'aztecjs_getting_started'...
aztecjs_connection	Type checking 'aztecjs_connection'...
aztecjs_authwit	Type checking 'aztecjs_authwit'...
aztecjs_authwit	✓ 'aztecjs_authwit' validated successfully
aztecjs_authwit	Cleaning up temporary files for 'aztecjs_authwit'...
aztecjs_testing	validate_project aztecjs_testing
aztecjs_advanced	index.ts(114,48): error TS2339: Property 'instance' does not exist on type 'TokenContract'.
aztecjs_advanced	ERROR: Type checking failed for 'aztecjs_advanced'
aztecjs_advanced	Validation failed for 'aztecjs_advanced', cleaning up...
parallel: This job failed:
validate_project aztecjs_advanced
Seq	Host	Starttime	JobRuntime	Send	Receive	Exitval	Signal	Command
2	:	1770130986.333	     4.838	0	1867	0	0	validate_project aztecjs_authwit
1	:	1770130986.330	     4.893	0	2191	1	0	validate_project aztecjs_advanced
ERROR: Some project(s) failed validation

Action required: Please fix the docs examples or update them to match the current API.

cc @AztecProtocol/devrel

@AztecBot
Copy link
Collaborator

AztecBot commented Feb 3, 2026

Flakey Tests

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

\033FLAKED\033 (8;;http://ci.aztec-labs.com/e16e2b9b5796d34e�e16e2b9b5796d34e8;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_epochs/epochs_high_tps_block_building.test.ts (207s) (code: 1) group:e2e-p2p-epoch-flakes (\033thunkar\033: chore: macOS bootstrap compatibility fixes)

AztecBot pushed a commit that referenced this pull request Feb 26, 2026
Tweaks and builds upon gregos #19379.
You can install dependencies prior to bootstrapping with.
```
./bootstrap.sh install_deps
```
You can then:
```
./bootstrap.sh gentle
```
To trigger a makefile build with 1 job at a time, and cmake will target nproc parallelism -2, and a MEMSUSPEND at 1g.

Tested on fresh macos 15/26 install + brew.

Didn't build on macos 14. Looks hairy, not important.
AztecBot pushed a commit that referenced this pull request Feb 26, 2026
Tweaks and builds upon gregos #19379.
You can install dependencies prior to bootstrapping with.
```
./bootstrap.sh install_deps
```
You can then:
```
./bootstrap.sh gentle
```
To trigger a makefile build with 1 job at a time, and cmake will target nproc parallelism -2, and a MEMSUSPEND at 1g.

Tested on fresh macos 15/26 install + brew.

Didn't build on macos 14. Looks hairy, not important.
charlielye added a commit that referenced this pull request Mar 5, 2026
Tweaks and builds upon gregos #19379.
You can install dependencies prior to bootstrapping with.
```
./bootstrap.sh install_deps
```
You can then:
```
./bootstrap.sh gentle
```
To trigger a makefile build with 1 job at a time, and cmake will target nproc parallelism -2, and a MEMSUSPEND at 1g.

Tested on fresh macos 15/26 install + brew.

Didn't build on macos 14. Looks hairy, not important.
charlielye added a commit that referenced this pull request Mar 5, 2026
Tweaks and builds upon gregos
#19379.
You can install dependencies prior to bootstrapping with.
```
./bootstrap.sh install_deps
```
You can then:
```
./bootstrap.sh gentle
```
To trigger a makefile build with 1 job at a time, and cmake will target
nproc parallelism -2, and a MEMSUSPEND at 1g.

Tested on fresh macos 15/26 install + brew.

Didn't build on macos 14. Looks hairy, not important.

---------

Co-authored-by: Jonathan Hao <jonathan@aztec-labs.com>
@charlielye
Copy link
Contributor

Solved in another pr

@charlielye charlielye closed this Mar 12, 2026
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.

3 participants