diff --git a/README.md b/README.md index 5a1b4d0ec8..ff1653cb24 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The structured reference string contains monomials up to x^{2^20}. This SRS was ### Dependencies -- cmake >= 3.16 +- cmake >= 3.24 - clang >= 10 or gcc >= 10 - clang-format - libomp (if multithreading is required. Multithreading can be disabled using the compiler flag `-DMULTITHREADING 0`) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index c736aef2f9..d56429d250 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1,7 +1,7 @@ # barretenberg # copyright 2019 Spilsbury Holdings Ltd -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.24) include(cmake/toolchain.cmake) diff --git a/cpp/cmake/module.cmake b/cpp/cmake/module.cmake index 3203763d09..6980b1b3ee 100644 --- a/cpp/cmake/module.cmake +++ b/cpp/cmake/module.cmake @@ -23,6 +23,7 @@ function(barretenberg_module MODULE_NAME) OBJECT ${SOURCE_FILES} ) + list(APPEND lib_targets ${MODULE_NAME}_objects) add_library( ${MODULE_NAME} @@ -36,6 +37,7 @@ function(barretenberg_module MODULE_NAME) ${ARGN} ${TBB_IMPORTED_TARGETS} ) + list(APPEND lib_targets ${MODULE_NAME}) set(MODULE_LINK_NAME ${MODULE_NAME}) endif() @@ -47,6 +49,7 @@ function(barretenberg_module MODULE_NAME) OBJECT ${TEST_SOURCE_FILES} ) + list(APPEND lib_targets ${MODULE_NAME}_test_objects) target_link_libraries( ${MODULE_NAME}_test_objects @@ -59,6 +62,7 @@ function(barretenberg_module MODULE_NAME) ${MODULE_NAME}_tests $ ) + list(APPEND exe_targets ${MODULE_NAME}_tests) if(WASM) target_link_options( @@ -111,22 +115,23 @@ function(barretenberg_module MODULE_NAME) foreach(FUZZER_SOURCE_FILE ${FUZZERS_SOURCE_FILES}) get_filename_component(FUZZER_NAME_STEM ${FUZZER_SOURCE_FILE} NAME_WE) add_executable( - ${MODULE_NAME}_${FUZZER_NAME_STEM}_fuzzer - ${FUZZER_SOURCE_FILE} + ${MODULE_NAME}_${FUZZER_NAME_STEM}_fuzzer + ${FUZZER_SOURCE_FILE} ) + list(APPEND exe_targets ${MODULE_NAME}_${FUZZER_NAME_STEM}_fuzzer) target_link_options( - ${MODULE_NAME}_${FUZZER_NAME_STEM}_fuzzer + ${MODULE_NAME}_${FUZZER_NAME_STEM}_fuzzer PRIVATE "-fsanitize=fuzzer" ${SANITIZER_OPTIONS} - ) + ) target_link_libraries( - ${MODULE_NAME}_${FUZZER_NAME_STEM}_fuzzer - PRIVATE + ${MODULE_NAME}_${FUZZER_NAME_STEM}_fuzzer + PRIVATE ${MODULE_LINK_NAME} - ) + ) endforeach() endif() @@ -137,6 +142,7 @@ function(barretenberg_module MODULE_NAME) OBJECT ${BENCH_SOURCE_FILES} ) + list(APPEND lib_targets ${MODULE_NAME}_bench_objects) target_link_libraries( ${MODULE_NAME}_bench_objects @@ -149,6 +155,7 @@ function(barretenberg_module MODULE_NAME) ${MODULE_NAME}_bench $ ) + list(APPEND exe_targets ${MODULE_NAME}_bench) target_link_libraries( ${MODULE_NAME}_bench @@ -165,4 +172,7 @@ function(barretenberg_module MODULE_NAME) WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) endif() -endfunction() \ No newline at end of file + + set(${MODULE_NAME}_lib_targets ${lib_targets} PARENT_SCOPE) + set(${MODULE_NAME}_exe_targets ${exe_targets} PARENT_SCOPE) +endfunction() diff --git a/cpp/dockerfiles/Dockerfile.wasm-linux-clang b/cpp/dockerfiles/Dockerfile.wasm-linux-clang index 320ae12ae3..82cd3db43a 100644 --- a/cpp/dockerfiles/Dockerfile.wasm-linux-clang +++ b/cpp/dockerfiles/Dockerfile.wasm-linux-clang @@ -1,4 +1,4 @@ -FROM ubuntu:focal AS builder +FROM ubuntu:kinetic AS builder RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential wget git libssl-dev cmake curl binaryen RUN curl https://wasmtime.dev/install.sh -sSf | bash /dev/stdin --version v3.0.1 WORKDIR /usr/src/barretenberg/cpp/src diff --git a/cpp/src/aztec/stdlib/merkle_tree/CMakeLists.txt b/cpp/src/aztec/stdlib/merkle_tree/CMakeLists.txt index 118676fc00..dac8373d78 100644 --- a/cpp/src/aztec/stdlib/merkle_tree/CMakeLists.txt +++ b/cpp/src/aztec/stdlib/merkle_tree/CMakeLists.txt @@ -1,26 +1,43 @@ +barretenberg_module(stdlib_merkle_tree stdlib_primitives stdlib_blake3s stdlib_pedersen) + if(NOT WASM) include(FetchContent) FetchContent_Declare( leveldb GIT_REPOSITORY https://github.com/google/leveldb.git GIT_TAG 1.22 + FIND_PACKAGE_ARGS ) - FetchContent_GetProperties(leveldb) - if(NOT leveldb_POPULATED) - FetchContent_Populate(leveldb) - set(LEVELDB_BUILD_TESTS OFF CACHE BOOL "LevelDB tests off") - add_subdirectory(${leveldb_SOURCE_DIR} ${leveldb_BINARY_DIR} EXCLUDE_FROM_ALL) - endif() + # Disable some leveldb targets before we call FetchContent_MakeAvailable + # so they are configured correctly if it needs to fetch + set(LEVELDB_BUILD_TESTS OFF CACHE BOOL "LevelDB tests off") + set(LEVELDB_BUILD_BENCHMARKS OFF CACHE BOOL "LevelDB benchmarks off") - # Silence all compiler warnings from LevelDB - target_compile_options( - leveldb - PRIVATE - -w - ) + FetchContent_MakeAvailable(leveldb) - link_libraries(leveldb) -endif() + if (leveldb_FOUND) + # Globally installed leveldb needs Threads available as Threads::Threads as discovered by `find_package` + find_package(Threads REQUIRED) -barretenberg_module(stdlib_merkle_tree stdlib_primitives stdlib_blake3s stdlib_pedersen) \ No newline at end of file + foreach(target IN LISTS stdlib_merkle_tree_lib_targets stdlib_merkle_tree_exe_targets) + target_link_libraries(${target} PRIVATE leveldb::leveldb) + endforeach() + else() + # FetchContent_MakeAvailable calls FetchContent_Populate if `find_package` is unsuccessful + # so these variables will be available if we reach this case + set_property(DIRECTORY ${leveldb_SOURCE_DIR} PROPERTY EXCLUDE_FROM_ALL) + set_property(DIRECTORY ${leveldb_BINARY_DIR} PROPERTY EXCLUDE_FROM_ALL) + + # Silence all compiler warnings from LevelDB + target_compile_options( + leveldb + PRIVATE + -w + ) + + foreach(target IN LISTS stdlib_merkle_tree_lib_targets stdlib_merkle_tree_exe_targets) + target_link_libraries(${target} PRIVATE leveldb) + endforeach() + endif() +endif()