diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index 420fb003d42e..62b4f4851719 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -19,7 +19,6 @@ }, "cacheVariables": { "CMAKE_BUILD_TYPE": "Release", - "TARGET_ARCH": "skylake", "ENABLE_PIC": "ON" } }, diff --git a/barretenberg/cpp/bootstrap.sh b/barretenberg/cpp/bootstrap.sh index a4c70bba834c..7a38e0bd4f80 100755 --- a/barretenberg/cpp/bootstrap.sh +++ b/barretenberg/cpp/bootstrap.sh @@ -7,7 +7,6 @@ else export native_preset=${NATIVE_PRESET:-clang20-no-avm} fi export hash=$(hash_str $(../../avm-transpiler/bootstrap.sh hash) $(cache_content_hash .rebuild_patterns)) -export native_build_dir=$(scripts/preset-build-dir) # Injects version number into a given bb binary. # Means we don't actually need to rebuild bb to release a new version if code hasn't changed. diff --git a/barretenberg/cpp/cmake/arch.cmake b/barretenberg/cpp/cmake/arch.cmake index 71b6dbb599ff..fe6488cbce3f 100644 --- a/barretenberg/cpp/cmake/arch.cmake +++ b/barretenberg/cpp/cmake/arch.cmake @@ -5,7 +5,19 @@ if(WASM) add_compile_options(-fno-exceptions -fno-slp-vectorize) endif() -if(NOT WASM AND NOT ARM AND TARGET_ARCH) +# Auto-detect TARGET_ARCH if not explicitly set. +# Use 'skylake' on x86_64 (matches our cross-compile presets) and 'generic' on ARM +# to avoid emitting CPU-specific instructions (e.g. SVE on Graviton) that break on +# other ARM machines like Apple Silicon. +if(NOT WASM AND NOT TARGET_ARCH) + if(ARM) + set(TARGET_ARCH "generic") + else() + set(TARGET_ARCH "skylake") + endif() +endif() + +if(NOT WASM AND TARGET_ARCH) message(STATUS "Target architecture: ${TARGET_ARCH}") add_compile_options(-march=${TARGET_ARCH}) endif() diff --git a/barretenberg/cpp/scripts/zig-c++.sh b/barretenberg/cpp/scripts/zig-c++.sh index 3c1a69cb9ad6..dc7e822e03a4 100755 --- a/barretenberg/cpp/scripts/zig-c++.sh +++ b/barretenberg/cpp/scripts/zig-c++.sh @@ -1,6 +1,8 @@ #!/bin/bash # Wrapper for zig c++ that pins glibc 2.35 on Linux (Ubuntu 22.04+ compat) # and uses native target on macOS. +# Note: arch.cmake handles -march selection (skylake on x86, generic on ARM) +# which overrides zig's native CPU detection, preventing CPU-specific instructions. if [[ "$(uname -s)" == "Linux" ]]; then exec zig c++ -target native-linux-gnu.2.35 "$@" else diff --git a/barretenberg/cpp/scripts/zig-cc.sh b/barretenberg/cpp/scripts/zig-cc.sh index 6f1444434676..bc39365b6c09 100755 --- a/barretenberg/cpp/scripts/zig-cc.sh +++ b/barretenberg/cpp/scripts/zig-cc.sh @@ -1,6 +1,8 @@ #!/bin/bash # Wrapper for zig cc that pins glibc 2.35 on Linux (Ubuntu 22.04+ compat) # and uses native target on macOS. +# Note: arch.cmake handles -march selection (skylake on x86, generic on ARM) +# which overrides zig's native CPU detection, preventing CPU-specific instructions. if [[ "$(uname -s)" == "Linux" ]]; then exec zig cc -target native-linux-gnu.2.35 "$@" else diff --git a/barretenberg/sol/scripts/init_honk.sh b/barretenberg/sol/scripts/init_honk.sh index cf24ef092aba..5711269ce03c 100755 --- a/barretenberg/sol/scripts/init_honk.sh +++ b/barretenberg/sol/scripts/init_honk.sh @@ -1,14 +1,22 @@ #!/usr/bin/env bash +set -eu # the verification key is the same for ultra and ultra zk SRS_PATH="$HOME/.bb-crs" OUTPUT_PATH="./src/honk" +KEYGEN="../cpp/build/bin/honk_solidity_key_gen" + +if [ ! -x "$KEYGEN" ]; then + echo "Error: honk_solidity_key_gen binary not found at $KEYGEN" >&2 + echo "Run barretenberg/cpp bootstrap first." >&2 + exit 1 +fi mkdir -p './src/honk/keys' -../cpp/build/bin/honk_solidity_key_gen add2 $OUTPUT_PATH $SRS_PATH -../cpp/build/bin/honk_solidity_key_gen blake $OUTPUT_PATH $SRS_PATH -../cpp/build/bin/honk_solidity_key_gen ecdsa $OUTPUT_PATH $SRS_PATH -../cpp/build/bin/honk_solidity_key_gen recursive $OUTPUT_PATH $SRS_PATH +$KEYGEN add2 $OUTPUT_PATH $SRS_PATH +$KEYGEN blake $OUTPUT_PATH $SRS_PATH +$KEYGEN ecdsa $OUTPUT_PATH $SRS_PATH +$KEYGEN recursive $OUTPUT_PATH $SRS_PATH echo "" echo "✓ VK generation complete" diff --git a/noir/bootstrap.sh b/noir/bootstrap.sh index 4fd19781f16a..1fcb30d95250 100755 --- a/noir/bootstrap.sh +++ b/noir/bootstrap.sh @@ -25,7 +25,12 @@ function build_native { set -euo pipefail if ! cache_download noir-$hash.tar.gz; then - (cd noir-repo && cargo build --locked --release --target-dir target) + # Serialize cargo operations to avoid race conditions with avm-transpiler + # which may run in parallel and share the same CARGO_HOME. + ( + flock -x 200 + cd noir-repo && cargo build --locked --release --target-dir target + ) 200>/tmp/rustup.lock cache_upload noir-$hash.tar.gz noir-repo/target/release/{nargo,acvm,noir-profiler} fi }