Skip to content

refactor: clean up bb build infrastructure#21522

Open
charlielye wants to merge 12 commits intonextfrom
cl/bb_build_clean
Open

refactor: clean up bb build infrastructure#21522
charlielye wants to merge 12 commits intonextfrom
cl/bb_build_clean

Conversation

@charlielye
Copy link
Contributor

@charlielye charlielye commented Mar 13, 2026

Summary

  • Rename MOBILE → BB_LITE across all CMake files and presets for clarity
  • Unify build functions via a single build_preset entry point that handles cache download/upload, cmake build, and version injection automatically
  • Auto-derive cache paths from preset targets via preset_cache_paths helper (jq queries CMakePresets.json) — targeted presets cache only their outputs, not intermediate artifacts
  • Remove zig- prefix from cross-compile preset names (zig-arm64-linuxarm64-linux etc.), enabling Makefile to call build_preset directly and eliminating wrapper functions
  • Merge wasm-threads-bench targets into wasm-threads preset (negligible build impact), removing the shared-dir edge case
  • Disable wasm-opt via --no-wasm-opt LDFLAGS in wasm preset (was silently picked up from PATH)
  • Move format check to its own Makefile target (bb-cpp-format-check)
  • Move yarn install to Makefile dependency (bb-cpp-yarn) for serialization
  • Add build preset targets to CMakePresets.json for cross-compiles, asan-fast (single source of truth)
  • Rename scripts/native-preset-build-dirscripts/preset-build-dir to accept any preset name

Add zig-amd64-windows CMake preset targeting x86_64-windows-gnu (MinGW)
to produce bb.exe and libbb-external.a for Windows. Built only during
release flows and published to GitHub release assets.

Build system:
- CMakePresets.json: zig-amd64-windows preset with MOBILE=ON
- CMakeLists.txt: link ws2_32, bcrypt, psapi for Windows
- bootstrap.sh: build_cross_windows function, release packaging
- Makefile: bb-cpp-cross-amd64-windows targets
- avm-transpiler: x86_64-pc-windows-gnu rust target

C++ Windows compatibility:
- net.hpp: winsock2.h + __builtin_bswap64 for byte order
- compiler_hints.hpp: __forceinline without inline on _WIN32
- backing_memory.hpp: _WIN32 guards for sys/mman.h
- engine.cpp: BCryptGenRandom for CSPRNG
- logstr.cpp: windows.h before psapi.h include order
- timer.hpp: _WIN32 guard for sys/resource.h
- api_msgpack.cpp: _WIN32 guards for IPC code
- file_io.hpp: std::filesystem::path overloads
- get_bytecode.hpp: std::filesystem::path overload
- http_download.hpp: suppress -Wsign-conversion in httplib
- Fix 1UL/2UL to size_t{} for Windows LLP64 compatibility

CMake guards:
- api/CMakeLists.txt, bb/CMakeLists.txt: NOT MOBILE for ipc
clang-format alphabetically sorts includes, but psapi.h requires
windows.h to be included first. Use clang-format off/on to preserve
the correct order.
On Linux/macOS, libstdc++ implicitly converts std::filesystem::path to
std::string, so overloads are unnecessary and cause ambiguity with
string literal arguments (const char* matches both std::string and
std::filesystem::path equally).
- Rename MOBILE CMake option to BB_LITE (clearer intent: excludes
  server-side subsystems, not just mobile)
- Move build targets into CMakePresets.json build presets so bootstrap.sh
  doesn't duplicate target lists
- Merge build_cross + build_cross_windows into single build_cross function
- Add build_cached generic function for cache-download/build/cache-upload
- Set AVM_TRANSPILER_LIB="" in Windows preset (was pointing to nonexistent path)
- Move Clang warning flags out of version guard for Zig cross-compile compat
- Add bb-cpp-yarn Makefile target for nodejs_module dependency
- Remove build_bench (native benches built by bb-cpp-native, wasm by
  bb-cpp-wasm-threads-benches)
- Set CI_FULL=1 in ci-barretenberg-full so Make handles full builds
- Remove redundant file-existence checks in build_release_dir
- Add platform guard reference comment in top-level CMakeLists.txt
…ject

- Rename scripts/native-preset-build-dir → scripts/preset-build-dir
  (accepts any preset name as positional arg, resolves binaryDir via
  inheritance)
- Fix tab-delimiter bug in preset-build-dir (bash read collapses
  consecutive tabs, switch to pipe delimiter)
- build_cached now derives build dir from preset and always runs
  inject_bb_versions (no-op if no bb binaries)
- build_native and build_cross collapse to one-line build_cached calls
- Move format.sh check to build_format_check function + Makefile target
  (bb-cpp-format-check), skipped on cache hit
- build_wasm and build_wasm_threads no longer need explicit cache paths
  (build_cached defaults to $build_dir/{bin,lib})
- Add inject_bb_versions helper for all bb/bb.exe/bb-avm binaries
…x from presets

Merge build_cached into build_preset so ./bootstrap.sh build_preset <name>
handles cache download/upload, cmake build, and version injection automatically.
Add preset_cache_paths to derive cache files from preset targets via jq.

Remove zig- prefix from cross-compile presets (zig-arm64-linux → arm64-linux etc.)
so Makefile can call build_preset directly, eliminating wrapper functions.

Also: disable wasm-opt (--no-wasm-opt LDFLAGS), merge wasm-threads-bench into
wasm-threads, fix inject_bb_versions set -e bug.
@charlielye charlielye changed the title Cl/bb build clean refactor: clean up bb build infrastructure Mar 13, 2026
@charlielye charlielye marked this pull request as ready for review March 13, 2026 15:19
Base automatically changed from cl/bb_win32 to next March 13, 2026 15:27
@charlielye charlielye requested a review from ludamad March 13, 2026 15:34
@ludamad ludamad added the ci-barretenberg Run all barretenberg/cpp checks. label Mar 13, 2026
@ludamad
Copy link
Collaborator

ludamad commented Mar 13, 2026

if ci-barretenberg and ci-release-pr passes lgtm

@ludamad ludamad added ci-barretenberg Run all barretenberg/cpp checks. and removed ci-full-no-test-cache ci-barretenberg Run all barretenberg/cpp checks. labels Mar 13, 2026
ci-barretenberg sets AVM_TRANSPILER=0 and doesn't check out the noir
submodule. Early-exit before hash computation to avoid failure.
@charlielye charlielye added ci-release-pr and removed ci-barretenberg Run all barretenberg/cpp checks. labels Mar 14, 2026
vm2_sim doesn't exist under BB_LITE (windows, ios, android). It's a
transitive dependency of nodejs_module and will be built during the
full build_preset phase for non-BB_LITE presets.
Windows uses BB_LITE which excludes vm2_sim. Instead of removing
vm2_sim from all cross-compiles, just skip the objects pre-phase
for windows since it's BB_LITE with fewer targets anyway.
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