diff --git a/barretenberg/cpp/bootstrap.sh b/barretenberg/cpp/bootstrap.sh index 75fb18d14f44..f9b8e536cf89 100755 --- a/barretenberg/cpp/bootstrap.sh +++ b/barretenberg/cpp/bootstrap.sh @@ -34,6 +34,10 @@ function inject_version { # Version starts immediately after the sentinel local version_offset=$((sentinel_offset + ${#sentinel})) printf "$version\0" | dd of="$binary" bs=1 seek=$version_offset conv=notrunc 2>/dev/null + # 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 } # Define build commands for each preset diff --git a/barretenberg/cpp/src/barretenberg/bb/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/bb/CMakeLists.txt index c3858e2dded9..0bf527c0ba9f 100644 --- a/barretenberg/cpp/src/barretenberg/bb/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/bb/CMakeLists.txt @@ -21,6 +21,9 @@ if (NOT(FUZZING)) # Link avm_transpiler when library is provided if(AVM_TRANSPILER_LIB) target_link_libraries(bb PRIVATE ${AVM_TRANSPILER_LIB}) + if(APPLE) + target_link_libraries(bb PRIVATE "-framework CoreFoundation") + endif() endif() if(NOT WASM) target_link_libraries(bb PRIVATE ipc) @@ -38,6 +41,14 @@ if (NOT(FUZZING)) ) endif() + # Re-sign on macOS to fix invalid linker-generated adhoc signature + if(APPLE) + add_custom_command(TARGET bb POST_BUILD + COMMAND codesign -s - -f $ + COMMENT "Re-signing bb binary for macOS" + ) + endif() + if(AVM) # Full bb-avm binary with AVM support (opt-in) add_executable( @@ -61,6 +72,9 @@ if (NOT(FUZZING)) # Link avm_transpiler when library is provided if(AVM_TRANSPILER_LIB) target_link_libraries(bb-avm PRIVATE ${AVM_TRANSPILER_LIB}) + if(APPLE) + target_link_libraries(bb-avm PRIVATE "-framework CoreFoundation") + endif() endif() if(NOT WASM) target_link_libraries(bb-avm PRIVATE ipc) @@ -77,5 +91,13 @@ if (NOT(FUZZING)) -ldw -lelf ) endif() + + # 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 $ + COMMENT "Re-signing bb-avm binary for macOS" + ) + endif() endif() endif() diff --git a/barretenberg/cpp/src/barretenberg/world_state/world_state.test.cpp b/barretenberg/cpp/src/barretenberg/world_state/world_state.test.cpp index 3411d5d2e71d..6d6b1c882e68 100644 --- a/barretenberg/cpp/src/barretenberg/world_state/world_state.test.cpp +++ b/barretenberg/cpp/src/barretenberg/world_state/world_state.test.cpp @@ -492,9 +492,9 @@ TEST_F(WorldStateTest, NullifierBatchInsert) auto response = ws.batch_insert_indexed_leaves( MerkleTreeId::NULLIFIER_TREE, { NullifierLeafValue(150), NullifierLeafValue(142), NullifierLeafValue(180) }, 2); - std::vector> expected_sorted_leaves = { { NullifierLeafValue(180), 2 }, - { NullifierLeafValue(150), 0 }, - { NullifierLeafValue(142), 1 } }; + std::vector> expected_sorted_leaves = { { NullifierLeafValue(180), 2 }, + { NullifierLeafValue(150), 0 }, + { NullifierLeafValue(142), 1 } }; EXPECT_EQ(response.sorted_leaves, expected_sorted_leaves); { diff --git a/barretenberg/crs/bootstrap.sh b/barretenberg/crs/bootstrap.sh index c2502e3621cd..3fdbfb1ce634 100755 --- a/barretenberg/crs/bootstrap.sh +++ b/barretenberg/crs/bootstrap.sh @@ -12,7 +12,16 @@ function build { crs_size_bytes=$((crs_size*64)) g1=$crs_path/bn254_g1.dat g2=$crs_path/bn254_g2.dat - if [ ! -f "$g1" ] || [ $(stat -c%s "$g1") -lt $crs_size_bytes ]; then + # stat -c%s is Linux-only, use stat -f%z on macOS + local g1_size=0 + if [ -f "$g1" ]; then + if [[ "$(uname)" == "Darwin" ]]; then + g1_size=$(stat -f%z "$g1") + else + g1_size=$(stat -c%s "$g1") + fi + fi + if [ ! -f "$g1" ] || [ $g1_size -lt $crs_size_bytes ]; then echo "Downloading crs of size: ${crs_size} ($((crs_size_bytes/(1024*1024)))MB)" mkdir -p $crs_path curl -s -H "Range: bytes=0-$((crs_size_bytes-1))" -o $g1 \ @@ -28,7 +37,15 @@ function build { crs_size=$((2**18)) crs_size_bytes=$((crs_size*64)) gg1=$crs_path/grumpkin_g1.flat.dat - if [ ! -f "$gg1" ] || [ $(stat -c%s "$gg1") -lt $crs_size_bytes ]; then + local gg1_size=0 + if [ -f "$gg1" ]; then + if [[ "$(uname)" == "Darwin" ]]; then + gg1_size=$(stat -f%z "$gg1") + else + gg1_size=$(stat -c%s "$gg1") + fi + fi + if [ ! -f "$gg1" ] || [ $gg1_size -lt $crs_size_bytes ]; then echo "Downloading grumpkin crs of size: ${crs_size} ($((crs_size_bytes/(1024*1024)))MB)" curl -s -H "Range: bytes=0-$((crs_size_bytes-1))" -o $gg1 \ https://crs.aztec.network/grumpkin_g1.dat diff --git a/ci3/arch b/ci3/arch index b4bf030fc5c6..ac2d92d00f18 100755 --- a/ci3/arch +++ b/ci3/arch @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Returns the standard artifact prefixes for each arch. case $(uname -m) in - aarch64) + aarch64|arm64) echo arm64 ;; amd64|x86_64) diff --git a/ci3/denoise b/ci3/denoise index 5f9fa75ab8d7..0138114ffd90 100755 --- a/ci3/denoise +++ b/ci3/denoise @@ -77,7 +77,13 @@ function publish_log_final { function live_publish_log { while [ -f $outfile ]; do - if [ $(( $(date +%s) - $(stat -c %Y "$outfile") )) -le 5 ]; then + local file_mtime + if [[ "$(uname)" == "Darwin" ]]; then + file_mtime=$(stat -f %m "$outfile") + else + file_mtime=$(stat -c %Y "$outfile") + fi + if [ $(( $(date +%s) - $file_mtime )) -le 5 ]; then publish_log fi sleep 5 @@ -94,7 +100,13 @@ fi set +e echo -e "Executing: $cmd ${log_info:-}" echo -n " 0 " -tail --sleep-interval=0.2 -n +1 -f "$outfile" > >( +# macOS tail doesn't support --sleep-interval +if [[ "$(uname)" == "Darwin" ]]; then + tail_args="-n +1 -f" +else + tail_args="--sleep-interval=0.2 -n +1 -f" +fi +tail $tail_args "$outfile" > >( while IFS= read -r line; do dot_count=$((dot_count+1)) [ $realtime -eq 1 ] && printf "." diff --git a/ci3/source b/ci3/source index c53bb28b3828..455c37625e55 100644 --- a/ci3/source +++ b/ci3/source @@ -3,7 +3,10 @@ # This can be sourced multiple by scripts calling scripts, so it makes sense to only do certain sets through first pass. # Enter our script directory, allowing usage of scripts from any directory. -[ -z "${NO_CD:-}" ] && cd "$(dirname $0)" +# Skip cd if $0 is a shell binary (e.g., /bin/bash or /opt/homebrew/bin/bash) +if [ -z "${NO_CD:-}" ] && [[ "$0" != */bash ]] && [[ "$0" != */zsh ]] && [[ "$0" != */sh ]]; then + cd "$(dirname $0)" +fi # We export so we can use from exported functions. export root=${root:-$(git rev-parse --show-toplevel)} @@ -21,6 +24,12 @@ fi # We are fine using foundry nightly. export FOUNDRY_DISABLE_NIGHTLY_WARNING=1 +# Fix for parallel setting XDG_CACHE_HOME to empty string, which breaks corepack. +# If XDG_CACHE_HOME is set but empty, unset it to use the default. +if [ -n "${XDG_CACHE_HOME+x}" ] && [ -z "$XDG_CACHE_HOME" ]; then + unset XDG_CACHE_HOME +fi + source $ci3/source_options source $ci3/source_stdlib source $ci3/source_color diff --git a/ci3/source_stdlib b/ci3/source_stdlib index 18ac41dc369d..4e4279f1329b 100644 --- a/ci3/source_stdlib +++ b/ci3/source_stdlib @@ -33,6 +33,8 @@ function get_num_cpus { else echo $((cpu_quota / cpu_period)) fi + elif [[ "$(uname)" == "Darwin" ]]; then + sysctl -n hw.ncpu else nproc fi