refactor: clean up bb build infrastructure#21522
Open
charlielye wants to merge 12 commits intonextfrom
Open
Conversation
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).
… into cl/bb_win32
- 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.
94b2657 to
373752d
Compare
Collaborator
|
if ci-barretenberg and ci-release-pr passes lgtm |
ludamad
approved these changes
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
build_presetentry point that handles cache download/upload, cmake build, and version injection automaticallypreset_cache_pathshelper (jq queries CMakePresets.json) — targeted presets cache only their outputs, not intermediate artifactszig-arm64-linux→arm64-linuxetc.), enabling Makefile to callbuild_presetdirectly and eliminating wrapper functions--no-wasm-optLDFLAGS in wasm preset (was silently picked up from PATH)bb-cpp-format-check)bb-cpp-yarn) for serializationscripts/native-preset-build-dir→scripts/preset-build-dirto accept any preset name