Skip to content

Commit d5700c2

Browse files
committed
fix: build native-packages Release/NDEBUG to match barretenberg (ODR)
The standalone wsdb/lmdblib/kvdb builds set no CMAKE_BUILD_TYPE, so they compiled bb's headers (inline/template crypto + field code) without NDEBUG and without -O3, while bb's prebuilt archive is Release (-O3 -DNDEBUG). bb headers are compiled into both, so the NDEBUG/opt mismatch is an ODR violation that can silently diverge inlined results (e.g. tree leaf hashing) -> the wsdb NullifierTree failing to find a leaf pre-image by hash in e2e. Default these builds to Release to match bb.
1 parent 6b467b8 commit d5700c2

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

native-packages/kvdb/cpp/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
1414
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1515
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
1616

17+
# Match barretenberg's prebuilt archive (Release -> -O3 -DNDEBUG): bb headers compiled
18+
# here must use the same NDEBUG/opt as bb to avoid ODR-divergent inlined code.
19+
if(NOT CMAKE_BUILD_TYPE)
20+
set(CMAKE_BUILD_TYPE Release)
21+
endif()
22+
1723
add_definitions(-DNAPI_VERSION=9)
1824

1925
# ---------------------------------------------------------------------------

native-packages/lmdblib/cpp/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
1919
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2020
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
2121

22+
# Match barretenberg's prebuilt archive (Release -> -O3 -DNDEBUG): bb headers compiled
23+
# here must use the same NDEBUG/opt as bb to avoid ODR-divergent inlined code.
24+
if(NOT CMAKE_BUILD_TYPE)
25+
set(CMAKE_BUILD_TYPE Release)
26+
endif()
27+
2228
# ---------------------------------------------------------------------------
2329
# Third-party deps (own copies; commits must match barretenberg/cpp/cmake/*).
2430
# ---------------------------------------------------------------------------

native-packages/wsdb/cpp/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
2020
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2121
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2222

23+
# Match barretenberg's prebuilt archive build (Release -> -O3 -DNDEBUG). bb headers
24+
# (inline/template crypto + field code) are compiled into BOTH bb's Release archive
25+
# and this build; compiling them here without NDEBUG/-O3 is an ODR violation that can
26+
# silently diverge inlined results (e.g. tree leaf hashes). Default to Release.
27+
if(NOT CMAKE_BUILD_TYPE)
28+
set(CMAKE_BUILD_TYPE Release)
29+
endif()
30+
2331
# ---------------------------------------------------------------------------
2432
# Locate the prebuilt barretenberg tree.
2533
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)