From 804ac07002b138b7d5d308e5d9e2e70af11fae31 Mon Sep 17 00:00:00 2001 From: battlmonstr Date: Mon, 16 Dec 2024 09:50:05 +0100 Subject: [PATCH] cmake: upgrade to Conan 2 (#2318) --- .circleci/config.yml | 4 +- .../actions/fuzzer-common-steps/action.yml | 9 +- .github/workflows/macOS.yml | 2 +- .github/workflows/windows.yml | 2 +- CMakeLists.txt | 21 ++- README.md | 6 +- cmake/compiler_settings.cmake | 10 -- cmake/conan.cmake | 129 ++++++++++++++---- cmake/conan_quiet.cmake | 38 ++++++ cmake/conan_quiet.sh | 18 +++ .../experimental/linux_arm64_gcc_12_debug | 6 +- .../experimental/linux_arm64_gcc_12_release | 6 +- .../experimental/linux_x64_clang_16_release | 17 --- .../experimental/linux_x64_gcc_12_debug | 6 +- .../experimental/linux_x64_gcc_12_release | 6 +- .../experimental/macos_arm64_clang_14_debug | 8 +- .../experimental/macos_arm64_clang_14_release | 8 +- .../experimental/macos_x64_clang_14_debug | 8 +- .../experimental/macos_x64_clang_14_release | 8 +- cmake/profiles/experimental/readme.txt | 11 +- .../experimental/windows_msvc_17_debug | 12 -- .../experimental/windows_msvc_17_release | 12 -- ...lang_13_debug => linux_x64_clang_16_debug} | 8 +- ..._13_release => linux_x64_clang_16_release} | 8 +- cmake/profiles/linux_x64_gcc_11_debug | 6 +- cmake/profiles/linux_x64_gcc_11_release | 6 +- cmake/profiles/macos_arm64_clang_13_debug | 8 +- cmake/profiles/macos_arm64_clang_13_release | 8 +- cmake/profiles/macos_x64_clang_13_debug | 8 +- cmake/profiles/macos_x64_clang_13_release | 8 +- cmake/profiles/wasi_release | 7 +- cmake/profiles/windows_msvc_16_debug | 12 -- cmake/profiles/windows_msvc_16_release | 12 -- cmake/profiles/windows_msvc_193_debug | 9 ++ cmake/profiles/windows_msvc_193_release | 9 ++ cmake/setup/compiler_install.sh | 53 +++++-- conanfile.py | 30 ++-- docs/fuzzer.md | 2 +- tests/docker/Dockerfile | 8 +- third_party/cmake-conan/conan_provider.cmake | 11 +- third_party/erigon-mdbx-go/CMakeLists.txt | 13 ++ third_party/gmp/CMakeLists.txt | 22 ++- third_party/libff/CMakeLists.txt | 12 ++ third_party/llvm/README.md | 6 +- 44 files changed, 346 insertions(+), 267 deletions(-) create mode 100644 cmake/conan_quiet.cmake create mode 100755 cmake/conan_quiet.sh delete mode 100644 cmake/profiles/experimental/linux_x64_clang_16_release delete mode 100644 cmake/profiles/experimental/windows_msvc_17_debug delete mode 100644 cmake/profiles/experimental/windows_msvc_17_release rename cmake/profiles/{linux_x64_clang_13_debug => linux_x64_clang_16_debug} (50%) rename cmake/profiles/{linux_x64_clang_13_release => linux_x64_clang_16_release} (51%) delete mode 100644 cmake/profiles/windows_msvc_16_debug delete mode 100644 cmake/profiles/windows_msvc_16_release create mode 100644 cmake/profiles/windows_msvc_193_debug create mode 100644 cmake/profiles/windows_msvc_193_release diff --git a/.circleci/config.yml b/.circleci/config.yml index a35e215116..8808bdfd24 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,7 +85,7 @@ commands: - run: name: "Install Conan" command: | - pip3 install --user --no-warn-script-location conan==1.64.1 + pip3 install --user --no-warn-script-location conan==2.10.2 conan_path="$(python3 -m site --user-base)/bin" echo "export \"PATH=$conan_path:\$PATH\"" >> "$BASH_ENV" "$conan_path/conan" --version @@ -128,7 +128,7 @@ commands: name: "Save Conan cache" key: *conan-cache-key paths: - - ~/.conan + - ~/.conan2 build_fuzzer: steps: diff --git a/.github/actions/fuzzer-common-steps/action.yml b/.github/actions/fuzzer-common-steps/action.yml index 8e4f0c73ab..d524d19e52 100644 --- a/.github/actions/fuzzer-common-steps/action.yml +++ b/.github/actions/fuzzer-common-steps/action.yml @@ -23,17 +23,12 @@ runs: - name: Temporary step - conan cache cleanup - to be executed only once per runner shell: bash - run: conan remove "*" --force - - - name: Preinstall Conan packages - shell: bash - working-directory: ${{runner.workspace}}/silkworm - run: CC=clang-16 CXX=clang++-16 conan install --install-folder=build/conan --build=missing --profile=cmake/profiles/experimental/linux_x64_clang_16_release . + run: /opt/conan2/bin/conan remove --confirm "*" - name: Configure CMake shell: bash working-directory: ${{runner.workspace}}/silkworm/build - run: CC=clang-16 CXX=clang++-16 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=experimental/linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON -DSILKWORM_FUZZER_SANITIZERS=${{inputs.fuzzer_sanitizers}} + run: CC=clang-16 CXX=clang++-16 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON -DSILKWORM_FUZZER_SANITIZERS=${{inputs.fuzzer_sanitizers}} - name: Build Silkworm Fuzzer Test shell: bash diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 736db62b9b..73bd80c16f 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -47,7 +47,7 @@ jobs: - name: Install Prerequisites run: | - pip3 install --user --break-system-packages --no-warn-script-location conan==1.64.1 chardet + pip3 install --user --break-system-packages --no-warn-script-location conan==2.10.2 chardet conan_path="$(python3 -m site --user-base)/bin" echo "$conan_path" >> $GITHUB_PATH "$conan_path/conan" --version diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 94420f50f8..693d05f26d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -47,7 +47,7 @@ jobs: id: conan uses: turtlebrowser/get-conan@main with: - version: 1.64.1 + version: 2.10.2 - name: Create Build Environment # Some projects don't allow in-source building, so create a separate build directory diff --git a/CMakeLists.txt b/CMakeLists.txt index eb8e5c0c14..29f32d64b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ limitations under the License. ]] -cmake_minimum_required(VERSION 3.19.0) +cmake_minimum_required(VERSION 3.24.0) if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/evmone/evmone/evmc/.git) message(FATAL_ERROR "Git submodules not initialized, execute:\n git submodule update --init --recursive") @@ -22,10 +22,21 @@ endif() get_directory_property(SILKWORM_HAS_PARENT PARENT_DIRECTORY) if(NOT SILKWORM_HAS_PARENT) + # reduce the log verbosity of evmone/cmake/cable + if(NOT CMAKE_MESSAGE_LOG_LEVEL) + set(CMAKE_MESSAGE_LOG_LEVEL_EMPTY YES) + set(CMAKE_MESSAGE_LOG_LEVEL NOTICE) + endif() + include(third_party/evmone/evmone/cmake/cable/bootstrap.cmake) include(CableBuildType) cable_set_build_type(DEFAULT Release CONFIGURATION_TYPES Release Debug) + # restore the log verbosity + if(CMAKE_MESSAGE_LOG_LEVEL_EMPTY) + unset(CMAKE_MESSAGE_LOG_LEVEL) + endif() + if(NOT CMAKE_TOOLCHAIN_FILE) set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain/cxx20.cmake @@ -33,6 +44,8 @@ if(NOT SILKWORM_HAS_PARENT) ) include("${CMAKE_TOOLCHAIN_FILE}") endif() + + include(cmake/conan.cmake) endif() project(silkworm) @@ -70,10 +83,6 @@ option(SILKWORM_FUZZER_SANITIZERS "CLang sanitizer options for fuzzers" OFF) option(SILKWORM_USE_MIMALLOC "Enable using mimalloc for dynamic memory management" ON) option(SILKWORM_ALLOW_UNUSED_VAR_WARNINGS "Turn unused variable errors into warnings" OFF) -if(NOT SILKWORM_HAS_PARENT) - include(cmake/conan.cmake) -endif() - set_property( DIRECTORY APPEND @@ -125,5 +134,5 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") # avoid fatal error C1002: compiler is out of heap space list(REMOVE_ITEM UNIT_TEST_TARGETS silkworm_rpcdaemon_test) endif() -message(STATUS "UNIT_TEST_TARGETS: ${UNIT_TEST_TARGETS}") +message(VERBOSE "UNIT_TEST_TARGETS: ${UNIT_TEST_TARGETS}") add_custom_target(all_unit_tests DEPENDS ${UNIT_TEST_TARGETS}) diff --git a/README.md b/README.md index 3b5e87b199..50dc3c4efb 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ or AppleClang ([Xcode](https://developer.apple.com/xcode/) >= 15) Conan requires Python, and can be installed using: - pip3 install --user conan==1.64.1 chardet + pip3 install --user conan==2.10.2 chardet On Linux the conan binary gets installed into `$HOME/.local/bin` which is typically in PATH already. On macOS need to add the binary to PATH manually: @@ -122,9 +122,7 @@ will use "debug" configuration builds of dependencies. See available profiles in [cmake/profiles](cmake/profiles). -The conan packages could also be pre-installed using [conan install](https://docs.conan.io/1/reference/commands/consumer/install.html): - - conan install --install-folder=build/conan --build=missing --profile=cmake/profiles/macos_arm64_clang_13_debug . +During the cmake configuration step `conan_provider.cmake` runs a [conan install](https://docs.conan.io/2/reference/commands/install.html) command that downloads packages and builds some of them from source if needed. The exact arguments to this command are printed in the build log. Then run the build itself diff --git a/cmake/compiler_settings.cmake b/cmake/compiler_settings.cmake index c6cf2395b5..6d865906e0 100644 --- a/cmake/compiler_settings.cmake +++ b/cmake/compiler_settings.cmake @@ -89,16 +89,6 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang$") link_libraries(c++abi) endif() - # cmake-format: off - # abseil in conan is prebuilt with clang 13 (see profiles), - # linking absl::log with clang 18+ produces an error due to an ABI change: - # https://github.com/abseil/abseil-cpp/issues/1747 - # https://github.com/llvm/llvm-project/issues/102443 - # cmake-format: on - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18) - add_compile_options(-fclang-abi-compat=17) - endif() - else() message(WARNING "${CMAKE_CXX_COMPILER_ID} is not a supported compiler. Use at your own risk.") endif() diff --git a/cmake/conan.cmake b/cmake/conan.cmake index 356adc5169..9c918307d3 100644 --- a/cmake/conan.cmake +++ b/cmake/conan.cmake @@ -15,8 +15,18 @@ ]] include(${CMAKE_CURRENT_LIST_DIR}/compiler_settings_sanitize.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/conan_quiet.cmake) function(guess_conan_profile) + if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "" AND CMAKE_HOST_UNIX) + execute_process( + COMMAND uname -m + OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + OUTPUT_STRIP_TRAILING_WHITESPACE + COMMAND_ERROR_IS_FATAL ANY + ) + endif() + if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "") set(ARCH_NAME "") elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64) @@ -38,7 +48,7 @@ function(guess_conan_profile) elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND ARCH_NAME) set(PROFILE macos_${ARCH_NAME}_clang_13_release) elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - set(PROFILE windows_msvc_16_release) + set(PROFILE windows_msvc_193_release) else() message(FATAL_ERROR "CONAN_PROFILE is not defined for ${CMAKE_HOST_SYSTEM_NAME} on ${CMAKE_HOST_SYSTEM_PROCESSOR}") endif() @@ -49,43 +59,69 @@ function(guess_conan_profile) ) endfunction() -set(CONAN_BINARY_DIR "${CMAKE_BINARY_DIR}/conan") -list(APPEND CMAKE_MODULE_PATH ${CONAN_BINARY_DIR}) -list(APPEND CMAKE_PREFIX_PATH ${CONAN_BINARY_DIR}) +function(get_conan_build_type profile_path var) + file(READ "${profile_path}" CONTENTS) + string(REGEX MATCH "build_type=[A-Za-z0-9]+" VALUE "${CONTENTS}") + string(SUBSTRING "${VALUE}" 11 -1 VALUE) + set(${var} + "${VALUE}" + PARENT_SCOPE + ) +endfunction() -# disable verbose logging from FindXXX.cmake files -set(CONAN_CMAKE_SILENT_OUTPUT ON) +macro(format_list_as_json_array list_var var) + list(JOIN ${list_var} "\",\"" ${var}) + set(${var} "[\"${${var}}\"]") +endmacro() -include("${CMAKE_SOURCE_DIR}/third_party/cmake-conan/conan.cmake") +# unset(CONAN_COMMAND CACHE) +find_program( + CONAN_COMMAND "conan" + PATHS /opt/conan2/bin + NO_DEFAULT_PATH +) +if(NOT CONAN_COMMAND) + find_program(CONAN_COMMAND "conan" PATHS ~/.local/bin REQUIRED) +endif() -# provide a static conanfile.py instead of generating it with conan_cmake_configure() -file(COPY "${CMAKE_SOURCE_DIR}/conanfile.py" DESTINATION "${CONAN_BINARY_DIR}") +# use "verbose" for more detailed conan install logs +set(CONAN_VERBOSITY "error") +set(CONAN_BINARY_DIR "${CMAKE_BINARY_DIR}/conan2") if(NOT DEFINED CONAN_PROFILE) guess_conan_profile() endif() -message(STATUS "CONAN_PROFILE: ${CONAN_PROFILE}") +message(VERBOSE "CONAN_PROFILE: ${CONAN_PROFILE}") +set(CONAN_PROFILE_PATH "${CMAKE_SOURCE_DIR}/cmake/profiles/${CONAN_PROFILE}") +set(CONAN_HOST_PROFILE "${CONAN_PROFILE_PATH}") +set(CONAN_BUILD_PROFILE "${CONAN_PROFILE_PATH}") +get_conan_build_type("${CONAN_PROFILE_PATH}" CONAN_BUILD_TYPE) set(CONAN_BUILD "missing") -set(CONAN_CXXFLAGS_ARG) -set(CONAN_OPTIONS) +set(CONAN_SETTINGS "") +set(CONAN_OPTIONS "") +set(CONAN_CONF "") + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + set(OS_VERSION_MIN_CXXFLAG "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") +endif() + +if(OS_VERSION_MIN_CXXFLAG AND NOT SILKWORM_SANITIZE_COMPILER_OPTIONS) + list(APPEND CONAN_CONF "libtorrent/*:tools.build:cxxflags=[\"${OS_VERSION_MIN_CXXFLAG}\"]") +endif() if(SILKWORM_SANITIZE_COMPILER_OPTIONS) set(CONAN_CXXFLAGS ${SILKWORM_SANITIZE_COMPILER_OPTIONS}) - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - list(APPEND CONAN_CXXFLAGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") + if(OS_VERSION_MIN_CXXFLAG) + list(APPEND CONAN_CXXFLAGS ${OS_VERSION_MIN_CXXFLAG}) endif() - list(JOIN CONAN_CXXFLAGS "\", \"" CONAN_CXXFLAGS_STR) - set(CONAN_CXXFLAGS_STR "[\"${CONAN_CXXFLAGS_STR}\"]") - set(CONAN_CXXFLAGS_ARG "tools.build:cxxflags=${CONAN_CXXFLAGS_STR}") - - list(APPEND CONAN_OPTIONS "boost:zlib=False") + list(APPEND CONAN_OPTIONS "boost/*:zlib=False") # libraries that needs to be rebuilt with sanitize flags # cmake-format: off - set(CONAN_BUILD + list(APPEND CONAN_BUILD abseil boost grpc @@ -93,6 +129,23 @@ if(SILKWORM_SANITIZE_COMPILER_OPTIONS) protobuf ) # cmake-format: on + + format_list_as_json_array(CONAN_CXXFLAGS CONAN_CXXFLAGS_STR) + foreach(PACKAGE IN LISTS CONAN_BUILD) + if(NOT PACKAGE STREQUAL "missing") + list(APPEND CONAN_CONF "${PACKAGE}/*:tools.build:cxxflags=${CONAN_CXXFLAGS_STR}") + endif() + endforeach() +endif() + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(CONAN_VERBOSITY "verbose") + set(CONAN_BUILD "missing:libtorrent/*") + # most Windows packages on ConanCenter are built for cppstd=14, + # but some require at least cppstd=17 (otherwise report "Invalid" status) + list(APPEND CONAN_SETTINGS "asio-grpc/*:compiler.cppstd=17") + list(APPEND CONAN_SETTINGS "magic_enum/*:compiler.cppstd=17") + list(APPEND CONAN_SETTINGS "tomlplusplus/*:compiler.cppstd=17") endif() if(SILKWORM_USE_MIMALLOC) @@ -100,19 +153,37 @@ if(SILKWORM_USE_MIMALLOC) # should not be used in sanitizer builds or at least its override option must be disabled # (https://github.com/microsoft/mimalloc/issues/317#issuecomment-708506405) if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND NOT SILKWORM_SANITIZE) - list(APPEND CONAN_OPTIONS "mimalloc:override=True") + list(APPEND CONAN_OPTIONS "mimalloc/*:override=True") endif() endif() if(SILKWORM_CORE_ONLY) - set(CONAN_CXXFLAGS_ARG "catch2/*:tools.build:cxxflags=[\"-fno-exceptions\"]") + list(APPEND CONAN_CONF "catch2/*:tools.build:cxxflags=[\"-fno-exceptions\"]") endif() -conan_cmake_install( - PATH_OR_REFERENCE "${CONAN_BINARY_DIR}" - INSTALL_FOLDER "${CONAN_BINARY_DIR}" - BUILD ${CONAN_BUILD} - OPTIONS ${CONAN_OPTIONS} - PROFILE "${CMAKE_SOURCE_DIR}/cmake/profiles/${CONAN_PROFILE}" - CONF "${CONAN_CXXFLAGS_ARG}" +# cmake-format: off +set(CONAN_INSTALL_ARGS + -v ${CONAN_VERBOSITY} + --output-folder "${CONAN_BINARY_DIR}" + # https://github.com/conan-io/cmake-conan/issues/607 + --settings:all "&:build_type=${CMAKE_BUILD_TYPE}" ) +# cmake-format: on + +foreach(VALUE IN LISTS CONAN_BUILD) + list(APPEND CONAN_INSTALL_ARGS --build=${VALUE}) +endforeach() + +foreach(VALUE IN LISTS CONAN_SETTINGS) + list(APPEND CONAN_INSTALL_ARGS --settings:all=${VALUE}) +endforeach() + +foreach(VALUE IN LISTS CONAN_OPTIONS) + list(APPEND CONAN_INSTALL_ARGS --options:all=${VALUE}) +endforeach() + +foreach(VALUE IN LISTS CONAN_CONF) + list(APPEND CONAN_INSTALL_ARGS --conf:all=${VALUE}) +endforeach() + +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_SOURCE_DIR}/third_party/cmake-conan/conan_provider.cmake") diff --git a/cmake/conan_quiet.cmake b/cmake/conan_quiet.cmake new file mode 100644 index 0000000000..6a3bacc593 --- /dev/null +++ b/cmake/conan_quiet.cmake @@ -0,0 +1,38 @@ +# Reduce verbosity of CMakeDeps conan generator +# do not edit, regenerate with conan_quiet.sh + +set(ZLIB_FIND_QUIETLY YES) +set(Catch2_FIND_QUIETLY YES) +set(jwt-cpp_FIND_QUIETLY YES) +set(GTest_FIND_QUIETLY YES) +set(LibtorrentRasterbar_FIND_QUIETLY YES) +set(Snappy_FIND_QUIETLY YES) +set(Microsoft.GSL_FIND_QUIETLY YES) +set(OpenSSL_FIND_QUIETLY YES) +set(fmt_FIND_QUIETLY YES) +set(roaring_FIND_QUIETLY YES) +set(BZip2_FIND_QUIETLY YES) +set(c-ares_FIND_QUIETLY YES) +set(magic_enum_FIND_QUIETLY YES) +set(absl_FIND_QUIETLY YES) +set(OpenSSL_FIND_QUIETLY YES) +set(tomlplusplus_FIND_QUIETLY YES) +set(spdlog_FIND_QUIETLY YES) +set(SQLite3_FIND_QUIETLY YES) +set(CLI11_FIND_QUIETLY YES) +set(tl-expected_FIND_QUIETLY YES) +set(asio-grpc_FIND_QUIETLY YES) +set(benchmark_FIND_QUIETLY YES) +set(gmp_FIND_QUIETLY YES) +set(Boost_FIND_QUIETLY YES) +set(SQLite3_FIND_QUIETLY YES) +set(mimalloc_FIND_QUIETLY YES) +set(re2_FIND_QUIETLY YES) +set(gRPC_FIND_QUIETLY YES) +set(protobuf_FIND_QUIETLY YES) +set(ZLIB_FIND_QUIETLY YES) +set(Protobuf_FIND_QUIETLY YES) +set(BZip2_FIND_QUIETLY YES) +set(SQLiteCpp_FIND_QUIETLY YES) +set(GTest_FIND_QUIETLY YES) +set(nlohmann_json_FIND_QUIETLY YES) diff --git a/cmake/conan_quiet.sh b/cmake/conan_quiet.sh new file mode 100755 index 0000000000..78efc3b93c --- /dev/null +++ b/cmake/conan_quiet.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +script_dir=$(dirname "${BASH_SOURCE[0]}") +project_dir="$script_dir/.." +build_dir="$1" + +if [[ -z "$build_dir" ]] +then + build_dir="$project_dir/build" +fi + +cat << EOF > "$script_dir/conan_quiet.cmake" +# Reduce verbosity of CMakeDeps conan generator +# do not edit, regenerate with conan_quiet.sh + +EOF + +grep -R FIND_QUIETLY "$build_dir/conan2" | sed -E 's/.+\((.+)\)/set(\1 YES)/' >> "$script_dir/conan_quiet.cmake" diff --git a/cmake/profiles/experimental/linux_arm64_gcc_12_debug b/cmake/profiles/experimental/linux_arm64_gcc_12_debug index 84715c32d4..8944d831e9 100644 --- a/cmake/profiles/experimental/linux_arm64_gcc_12_debug +++ b/cmake/profiles/experimental/linux_arm64_gcc_12_debug @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=armv8 -arch_build=armv8 compiler=gcc compiler.version=12 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/linux_arm64_gcc_12_release b/cmake/profiles/experimental/linux_arm64_gcc_12_release index 47ea55e61b..a072a98730 100644 --- a/cmake/profiles/experimental/linux_arm64_gcc_12_release +++ b/cmake/profiles/experimental/linux_arm64_gcc_12_release @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=armv8 -arch_build=armv8 compiler=gcc compiler.version=12 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/linux_x64_clang_16_release b/cmake/profiles/experimental/linux_x64_clang_16_release deleted file mode 100644 index ba21adcbdc..0000000000 --- a/cmake/profiles/experimental/linux_x64_clang_16_release +++ /dev/null @@ -1,17 +0,0 @@ -[settings] -os=Linux -os_build=Linux -arch=x86_64 -arch_build=x86_64 -compiler=clang -compiler.version=16 -compiler.libcxx=libc++ -build_type=Release - -[options] - -[build_requires] - -[env] -CONAN_CXX_FLAGS="-fuse-ld=lld" -CONAN_C_FLAGS="-fuse-ld=lld" diff --git a/cmake/profiles/experimental/linux_x64_gcc_12_debug b/cmake/profiles/experimental/linux_x64_gcc_12_debug index 35372a5f46..c0f4a39e0a 100644 --- a/cmake/profiles/experimental/linux_x64_gcc_12_debug +++ b/cmake/profiles/experimental/linux_x64_gcc_12_debug @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=gcc compiler.version=12 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/linux_x64_gcc_12_release b/cmake/profiles/experimental/linux_x64_gcc_12_release index 68dd94e10c..c8aaacd327 100644 --- a/cmake/profiles/experimental/linux_x64_gcc_12_release +++ b/cmake/profiles/experimental/linux_x64_gcc_12_release @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=gcc compiler.version=12 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/macos_arm64_clang_14_debug b/cmake/profiles/experimental/macos_arm64_clang_14_debug index 64ddf4a6c0..5e7e3ec2bd 100644 --- a/cmake/profiles/experimental/macos_arm64_clang_14_debug +++ b/cmake/profiles/experimental/macos_arm64_clang_14_debug @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=armv8 -arch_build=armv8 compiler=apple-clang -compiler.version=14.0 +compiler.version=14 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/macos_arm64_clang_14_release b/cmake/profiles/experimental/macos_arm64_clang_14_release index 8768c4f67f..b944fe3347 100644 --- a/cmake/profiles/experimental/macos_arm64_clang_14_release +++ b/cmake/profiles/experimental/macos_arm64_clang_14_release @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=armv8 -arch_build=armv8 compiler=apple-clang -compiler.version=14.0 +compiler.version=14 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/macos_x64_clang_14_debug b/cmake/profiles/experimental/macos_x64_clang_14_debug index e2ae677c67..45a838776a 100644 --- a/cmake/profiles/experimental/macos_x64_clang_14_debug +++ b/cmake/profiles/experimental/macos_x64_clang_14_debug @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=x86_64 -arch_build=x86_64 compiler=apple-clang -compiler.version=14.0 +compiler.version=14 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/macos_x64_clang_14_release b/cmake/profiles/experimental/macos_x64_clang_14_release index d613bc4cdc..caf3d2c890 100644 --- a/cmake/profiles/experimental/macos_x64_clang_14_release +++ b/cmake/profiles/experimental/macos_x64_clang_14_release @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=x86_64 -arch_build=x86_64 compiler=apple-clang -compiler.version=14.0 +compiler.version=14 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/readme.txt b/cmake/profiles/experimental/readme.txt index d9f25e44bc..8a322f1e79 100644 --- a/cmake/profiles/experimental/readme.txt +++ b/cmake/profiles/experimental/readme.txt @@ -1,7 +1,10 @@ -There are very few binary packages for gcc 12 and clang 14 on ConanCenter. +There are very few binary packages for gcc 12+ and clang 14+ on ConanCenter. +The supported platforms are listed here: https://github.com/conan-io/conan-center-index/issues/25691#issuecomment-2429167255 -Test using this command: +This command shows which packages are "Missing" and need to be built from sources: -conan install . --profile cmake/profiles/experimental/linux_x64_gcc_12_release + conan graph explain --profile:all cmake/profiles/experimental/linux_x64_gcc_12_release . -It shows which packages need "Download" of binaries or "Build" from sources. +This command shows if binaries are missing for a particular package: + + conan graph explain --profile:all cmake/profiles/experimental/linux_x64_gcc_12_release --requires=grpc/x.y.z diff --git a/cmake/profiles/experimental/windows_msvc_17_debug b/cmake/profiles/experimental/windows_msvc_17_debug deleted file mode 100644 index 685e16b406..0000000000 --- a/cmake/profiles/experimental/windows_msvc_17_debug +++ /dev/null @@ -1,12 +0,0 @@ -[settings] -os=Windows -os_build=Windows -arch=x86_64 -arch_build=x86_64 -compiler=Visual Studio -compiler.version=17 -compiler.runtime=MDd -build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/experimental/windows_msvc_17_release b/cmake/profiles/experimental/windows_msvc_17_release deleted file mode 100644 index b753317e04..0000000000 --- a/cmake/profiles/experimental/windows_msvc_17_release +++ /dev/null @@ -1,12 +0,0 @@ -[settings] -os=Windows -os_build=Windows -arch=x86_64 -arch_build=x86_64 -compiler=Visual Studio -compiler.version=17 -compiler.runtime=MD -build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/linux_x64_clang_13_debug b/cmake/profiles/linux_x64_clang_16_debug similarity index 50% rename from cmake/profiles/linux_x64_clang_13_debug rename to cmake/profiles/linux_x64_clang_16_debug index 46160e3509..aadab8042d 100644 --- a/cmake/profiles/linux_x64_clang_13_debug +++ b/cmake/profiles/linux_x64_clang_16_debug @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=clang -compiler.version=13 +compiler.version=16 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/linux_x64_clang_13_release b/cmake/profiles/linux_x64_clang_16_release similarity index 51% rename from cmake/profiles/linux_x64_clang_13_release rename to cmake/profiles/linux_x64_clang_16_release index 250efe7c4a..3164500a5a 100644 --- a/cmake/profiles/linux_x64_clang_13_release +++ b/cmake/profiles/linux_x64_clang_16_release @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=clang -compiler.version=13 +compiler.version=16 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/linux_x64_gcc_11_debug b/cmake/profiles/linux_x64_gcc_11_debug index 21378fb239..d627ca292d 100644 --- a/cmake/profiles/linux_x64_gcc_11_debug +++ b/cmake/profiles/linux_x64_gcc_11_debug @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=gcc compiler.version=11 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] diff --git a/cmake/profiles/linux_x64_gcc_11_release b/cmake/profiles/linux_x64_gcc_11_release index ee38ba1656..3b7c771b9b 100644 --- a/cmake/profiles/linux_x64_gcc_11_release +++ b/cmake/profiles/linux_x64_gcc_11_release @@ -1,12 +1,8 @@ [settings] os=Linux -os_build=Linux arch=x86_64 -arch_build=x86_64 compiler=gcc compiler.version=11 compiler.libcxx=libstdc++11 +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] diff --git a/cmake/profiles/macos_arm64_clang_13_debug b/cmake/profiles/macos_arm64_clang_13_debug index e34ebb4768..20e6dfa5d4 100644 --- a/cmake/profiles/macos_arm64_clang_13_debug +++ b/cmake/profiles/macos_arm64_clang_13_debug @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=armv8 -arch_build=armv8 compiler=apple-clang -compiler.version=13.0 +compiler.version=13 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/macos_arm64_clang_13_release b/cmake/profiles/macos_arm64_clang_13_release index 0b8b38afc9..d7b3ae5d37 100644 --- a/cmake/profiles/macos_arm64_clang_13_release +++ b/cmake/profiles/macos_arm64_clang_13_release @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=armv8 -arch_build=armv8 compiler=apple-clang -compiler.version=13.0 +compiler.version=13 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/macos_x64_clang_13_debug b/cmake/profiles/macos_x64_clang_13_debug index 45783f26b3..5c47f39831 100644 --- a/cmake/profiles/macos_x64_clang_13_debug +++ b/cmake/profiles/macos_x64_clang_13_debug @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=x86_64 -arch_build=x86_64 compiler=apple-clang -compiler.version=13.0 +compiler.version=13 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/macos_x64_clang_13_release b/cmake/profiles/macos_x64_clang_13_release index 7346e17a7f..fa07d48c4a 100644 --- a/cmake/profiles/macos_x64_clang_13_release +++ b/cmake/profiles/macos_x64_clang_13_release @@ -1,12 +1,8 @@ [settings] os=Macos -os_build=Macos arch=x86_64 -arch_build=x86_64 compiler=apple-clang -compiler.version=13.0 +compiler.version=13 compiler.libcxx=libc++ +compiler.cppstd=17 build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/wasi_release b/cmake/profiles/wasi_release index 31ae7ca3b1..e986e45afa 100644 --- a/cmake/profiles/wasi_release +++ b/cmake/profiles/wasi_release @@ -5,8 +5,5 @@ compiler=clang compiler.version=14 compiler.libcxx=libc++ build_type=Release -[options] -[build_requires] -[env] -CC=/opt/wasi-sdk/bin/clang -CXX=/opt/wasi-sdk/bin/clang++ +[conf] +tools.build:compiler_executables={'c': '/opt/wasi-sdk/bin/clang', 'cpp': '/opt/wasi-sdk/bin/clang++'} diff --git a/cmake/profiles/windows_msvc_16_debug b/cmake/profiles/windows_msvc_16_debug deleted file mode 100644 index 99fa4f1b73..0000000000 --- a/cmake/profiles/windows_msvc_16_debug +++ /dev/null @@ -1,12 +0,0 @@ -[settings] -os=Windows -os_build=Windows -arch=x86_64 -arch_build=x86_64 -compiler=Visual Studio -compiler.version=16 -compiler.runtime=MDd -build_type=Debug -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/windows_msvc_16_release b/cmake/profiles/windows_msvc_16_release deleted file mode 100644 index e52961d8e8..0000000000 --- a/cmake/profiles/windows_msvc_16_release +++ /dev/null @@ -1,12 +0,0 @@ -[settings] -os=Windows -os_build=Windows -arch=x86_64 -arch_build=x86_64 -compiler=Visual Studio -compiler.version=16 -compiler.runtime=MD -build_type=Release -[options] -[build_requires] -[env] \ No newline at end of file diff --git a/cmake/profiles/windows_msvc_193_debug b/cmake/profiles/windows_msvc_193_debug new file mode 100644 index 0000000000..86bf46cfe9 --- /dev/null +++ b/cmake/profiles/windows_msvc_193_debug @@ -0,0 +1,9 @@ +[settings] +os=Windows +arch=x86_64 +compiler=msvc +compiler.version=193 +compiler.runtime=dynamic +compiler.runtime_type=Release +compiler.cppstd=14 +build_type=Debug diff --git a/cmake/profiles/windows_msvc_193_release b/cmake/profiles/windows_msvc_193_release new file mode 100644 index 0000000000..14b080f211 --- /dev/null +++ b/cmake/profiles/windows_msvc_193_release @@ -0,0 +1,9 @@ +[settings] +os=Windows +arch=x86_64 +compiler=msvc +compiler.version=193 +compiler.runtime=dynamic +compiler.runtime_type=Release +compiler.cppstd=14 +build_type=Release diff --git a/cmake/setup/compiler_install.sh b/cmake/setup/compiler_install.sh index a0e903f50a..1f3712363c 100755 --- a/cmake/setup/compiler_install.sh +++ b/cmake/setup/compiler_install.sh @@ -6,13 +6,22 @@ set -e set -o pipefail +script_dir=$(dirname "${BASH_SOURCE[0]}") +project_dir="$script_dir/../.." + function install_gcc { GCC_VERSION="$1" echo "Installing GCC $GCC_VERSION..." sudo apt-get update - sudo apt-get install -y gcc-$GCC_VERSION g++-$GCC_VERSION - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 100 --slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION + sudo apt-get install -y g++-$GCC_VERSION + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 100 \ + --slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100 + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100 + sudo update-alternatives --set gcc /usr/bin/gcc-$GCC_VERSION + sudo update-alternatives --set cc /usr/bin/gcc + sudo update-alternatives --set c++ /usr/bin/g++ } # libc++ is an alternative standard library needed for coroutines support on Clang @@ -22,22 +31,32 @@ function install_clang { echo "Installing clang $CLANG_VERSION..." sudo apt-get update - package_available=$(apt list llvm-$CLANG_VERSION 2>/dev/null | grep llvm-$CLANG_VERSION) - - if [[ -n "$package_available" ]]; then - echo "The package llvm-$CLANG_VERSION is available in apt repositories" - sudo apt-get install -y llvm-$CLANG_VERSION libc++-$CLANG_VERSION-dev libc++abi-$CLANG_VERSION-dev clang-$CLANG_VERSION lld-$CLANG_VERSION + if apt-cache show clang-$CLANG_VERSION > /dev/null 2>&1 + then + echo "Installing from the default apt repositories" + sudo apt-get install -y clang-$CLANG_VERSION \ + libc++-$CLANG_VERSION-dev libc++abi-$CLANG_VERSION-dev \ + lld-$CLANG_VERSION else - echo "Package llvm-$CLANG_VERSION not available, attempting to install using llvm.sh script" - sudo ../../third_party/llvm/llvm.sh $CLANG_VERSION + echo "Installing from apt.llvm.org using llvm.sh script" + sudo "$project_dir/third_party/llvm/llvm.sh" $CLANG_VERSION fi - sudo ln -sfv /usr/bin/clang-$CLANG_VERSION /usr/bin/clang - sudo ln -sfv /usr/bin/clang++-$CLANG_VERSION /usr/bin/clang++ - sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 - sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 - sudo update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-$CLANG_VERSION 100 - sudo update-alternatives --install /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-$CLANG_VERSION 100 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-$CLANG_VERSION 100 \ + --slave /usr/bin/clang++ clang++ /usr/bin/clang++-$CLANG_VERSION \ + --slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-$CLANG_VERSION \ + --slave /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-$CLANG_VERSION + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 + sudo update-alternatives --set clang /usr/bin/clang-$CLANG_VERSION + sudo update-alternatives --set cc /usr/bin/clang + sudo update-alternatives --set c++ /usr/bin/clang++ + + # alias gcc to clang + # this is useful for scripts having gcc hardcoded (such as GMP autotools build) + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/clang 10 \ + --slave /usr/bin/g++ g++ /usr/bin/clang++ + sudo update-alternatives --set gcc /usr/bin/clang } if [[ -n "$1" ]] @@ -64,3 +83,7 @@ case "$compiler_id" in install_clang "$version" ;; esac + +update-alternatives --display cc +update-alternatives --display c++ +update-alternatives --display gcc diff --git a/conanfile.py b/conanfile.py index 87338153df..9a1f8fd352 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,11 +1,11 @@ # Copyright 2023 The Silkworm Authors - +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at - +# # http://www.apache.org/licenses/LICENSE-2.0 - +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ class SilkwormRecipe(ConanFile): settings = 'os', 'compiler', 'build_type', 'arch' - generators = 'cmake_find_package' + generators = 'CMakeDeps' def requirements(self): self.requires('catch2/3.6.0') @@ -32,10 +32,10 @@ def requirements(self): self.requires('abseil/20240116.2') self.requires('asio-grpc/2.9.2') self.requires('benchmark/1.6.1') - self.requires('boost/1.83.0') + self.requires('boost/1.83.0', override=True) self.requires('cli11/2.2.0') self.requires('gmp/6.2.1') - self.requires('grpc/1.67.1') + self.requires('grpc/1.67.1', override=True) self.requires('gtest/1.12.1') self.requires('jwt-cpp/0.6.0') self.requires('libtorrent/2.0.10') @@ -51,19 +51,23 @@ def requirements(self): def configure(self): self.options['asio-grpc'].local_allocator = 'boost_container' - # Conan Center has Windows binaries built only with msvc16 and mimalloc built only with option override=False. - # In order to build mimalloc with override=True we could switch to msvc17 compiler but this would trigger a full - # rebuild from sources of all dependencies increasing build time a lot, so we prefer to keep mimalloc override - # disabled on Windows. - # The same applies also for boost with option asio_no_deprecated, so we skip configuration entirely on Windows. - if self.settings.os == 'Windows': - return + if (self.settings.os == 'Linux') and (self.settings.compiler == 'clang'): + self.options['grpc'].with_libsystemd = False # Disable Catch2 version 3.x.x signal handling on WASM if self.settings.arch == 'wasm': self.options['catch2'].no_posix_signals = True + self.configure_boost() + + def configure_boost(self): + # on Windows rebuilding boost from sources increases the build time a lot, so we skip configuration + # hoping it doesn't break with asio_no_deprecated = False + if self.settings.os == 'Windows': + return + self.options['boost'].asio_no_deprecated = True + if self.settings.os == 'Macos': cmake_osx_deployment_target = '10.14' os_version_min_flag = f'-mmacosx-version-min={cmake_osx_deployment_target}' diff --git a/docs/fuzzer.md b/docs/fuzzer.md index 06d2206821..8a8553ce65 100644 --- a/docs/fuzzer.md +++ b/docs/fuzzer.md @@ -6,7 +6,7 @@ To build the fuzzer use the following: ```bash mkdir build cd build -cmake ../project -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=linux_x64_clang_13_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON +cmake ../project -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON cmake --build --target rpcdaemon_fuzzer_test cmake –-build --target rpcdaemon_fuzzer_diagnostics ``` diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index aebddddfda..3e6284645c 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -6,7 +6,7 @@ FROM cimg/python:3.12.0 as base # 1 Install dependencies RUN sudo apt-get update RUN sudo apt install -y python3-pip -RUN sudo pip3 install conan==1.64.1 chardet +RUN sudo pip3 install conan==2.10.2 chardet RUN sudo apt-get update # 2 Get repo and submodules @@ -22,7 +22,7 @@ RUN cmake/setup/compiler_install.sh clang 16 # 4 Build all targets WORKDIR /app/build -RUN cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_13_debug +RUN cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake WORKDIR /app/project RUN cmake --build /app/build -j4 @@ -48,7 +48,7 @@ RUN git pull origin ${BRANCH} # Rebuild all targets RUN echo "Rebuilding" WORKDIR /app/build -RUN sudo cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_13_debug +RUN sudo cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake WORKDIR /app/project RUN sudo cmake --build /app/build -j4 @@ -64,7 +64,7 @@ RUN sudo cmake --build /app/build -j4 # RUN for file in ~/artifacts/*; do sed -i 's/^>> //' "$file"; done # # Rebuild fuzzer # WORKDIR /app/build -# RUN sudo cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_13_debug -DSILKWORM_FUZZING=ON +# RUN sudo cmake ../project -DCMAKE_BUILD_TYPE=Debug -DCONAN_PROFILE=linux_x64_clang_16_release -DCMAKE_TOOLCHAIN_FILE=../project/cmake/toolchain/clang_libcxx.cmake -DSILKWORM_FUZZER=ON # WORKDIR /app/project # RUN sudo cmake --build /app/build -j4 --target rpcdaemon_fuzzer_test # # Run fuzzer diff --git a/third_party/cmake-conan/conan_provider.cmake b/third_party/cmake-conan/conan_provider.cmake index 0afa940abf..59a58ed700 100644 --- a/third_party/cmake-conan/conan_provider.cmake +++ b/third_party/cmake-conan/conan_provider.cmake @@ -489,11 +489,11 @@ function(conan_install) string(JSON conan_generators_folder GET "${conan_stdout}" graph nodes 0 generators_folder) cmake_path(CONVERT ${conan_generators_folder} TO_CMAKE_PATH_LIST conan_generators_folder) - message(STATUS "CMake-Conan: CONAN_GENERATORS_FOLDER=${conan_generators_folder}") + message(VERBOSE "CMake-Conan: CONAN_GENERATORS_FOLDER=${conan_generators_folder}") set_property(GLOBAL PROPERTY CONAN_GENERATORS_FOLDER "${conan_generators_folder}") # reconfigure on conanfile changes string(JSON conanfile GET "${conan_stdout}" graph nodes 0 label) - message(STATUS "CMake-Conan: CONANFILE=${CMAKE_SOURCE_DIR}/${conanfile}") + message(VERBOSE "CMake-Conan: CONANFILE=${CMAKE_SOURCE_DIR}/${conanfile}") set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/${conanfile}") # success set_property(GLOBAL PROPERTY CONAN_INSTALL_SUCCESS TRUE) @@ -562,7 +562,7 @@ macro(conan_provide_dependency method package_name) # SILKWORM-PATCH: find_program(CONAN_COMMAND "conan" REQUIRED) conan_get_version(${CONAN_COMMAND} CONAN_CURRENT_VERSION) conan_version_check(MINIMUM ${CONAN_MINIMUM_VERSION} CURRENT ${CONAN_CURRENT_VERSION}) - message(STATUS "CMake-Conan: first find_package() found. Installing dependencies with Conan") + message(VERBOSE "CMake-Conan: first find_package() found. Installing dependencies with Conan") if("default" IN_LIST CONAN_HOST_PROFILE OR "default" IN_LIST CONAN_BUILD_PROFILE) conan_profile_detect_default() endif() @@ -587,10 +587,10 @@ macro(conan_provide_dependency method package_name) endif() get_property(_multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(NOT _multiconfig_generator) - message(STATUS "CMake-Conan: Installing single configuration ${CMAKE_BUILD_TYPE}") + message(VERBOSE "CMake-Conan: Installing single configuration ${CMAKE_BUILD_TYPE}") conan_install(${_host_profile_flags} ${_build_profile_flags} ${CONAN_INSTALL_ARGS} ${generator}) else() - message(STATUS "CMake-Conan: Installing both Debug and Release") + message(VERBOSE "CMake-Conan: Installing both Debug and Release") conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Release ${CONAN_INSTALL_ARGS} ${generator}) conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=Debug ${CONAN_INSTALL_ARGS} ${generator}) endif() @@ -599,7 +599,6 @@ macro(conan_provide_dependency method package_name) unset(_multiconfig_generator) unset(_conan_install_success) else() - message(STATUS "CMake-Conan: find_package(${ARGV1}) found, 'conan install' already ran") unset(_conan_install_success) endif() diff --git a/third_party/erigon-mdbx-go/CMakeLists.txt b/third_party/erigon-mdbx-go/CMakeLists.txt index d3cc4d9812..70fb7fa952 100644 --- a/third_party/erigon-mdbx-go/CMakeLists.txt +++ b/third_party/erigon-mdbx-go/CMakeLists.txt @@ -15,7 +15,20 @@ ]] set(MDBX_ENABLE_TESTS OFF) + +# reduce the log verbosity of mdbx-go/mdbxdist/CMakeLists.txt +if(NOT CMAKE_MESSAGE_LOG_LEVEL) + set(CMAKE_MESSAGE_LOG_LEVEL_EMPTY YES) + set(CMAKE_MESSAGE_LOG_LEVEL NOTICE) +endif() + add_subdirectory(mdbx-go/mdbxdist) + +# restore the log verbosity +if(CMAKE_MESSAGE_LOG_LEVEL_EMPTY) + unset(CMAKE_MESSAGE_LOG_LEVEL) +endif() + target_compile_definitions(mdbx-static PUBLIC CONSTEXPR_ASSERT=assert) if(MDBX_BUILD_TOOLS) diff --git a/third_party/gmp/CMakeLists.txt b/third_party/gmp/CMakeLists.txt index 4f8196fb0d..7f7c99ef4a 100644 --- a/third_party/gmp/CMakeLists.txt +++ b/third_party/gmp/CMakeLists.txt @@ -14,6 +14,20 @@ limitations under the License. ]] +function(expand_config_gen_expr expr build_type var) + string(REGEX MATCH ":[^>]+" VALUE "${expr}") + string(REPLACE ":" "" VALUE "${VALUE}") + set(${var} + "${VALUE}" + PARENT_SCOPE + ) +endfunction() + +if(GMP_LIBRARY STREQUAL "GMP_LIBRARY-NOTFOUND") + unset(GMP_LIBRARY CACHE) + unset(GMP_INCLUDE_DIR CACHE) +endif() + if(DEFINED GMP_LIBRARY) add_library(gmplib STATIC IMPORTED) set_target_properties(gmplib PROPERTIES IMPORTED_LOCATION "${GMP_LIBRARY}") @@ -24,15 +38,17 @@ if(DEFINED GMP_LIBRARY) endif() else() find_package(gmp REQUIRED) - add_custom_target(gmplib DEPENDS gmp::GMP) + add_custom_target(gmplib DEPENDS gmp::gmp) # derive the path variables from the package for intx, libff - get_target_property(GMP_INCLUDE_DIR gmp::GMP INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(GMP_INCLUDE_DIR_EXPR gmp::libgmp INTERFACE_INCLUDE_DIRECTORIES) + expand_config_gen_expr("${GMP_INCLUDE_DIR_EXPR}" ${CMAKE_BUILD_TYPE} GMP_INCLUDE_DIR) set(GMP_INCLUDE_DIR "${GMP_INCLUDE_DIR}" CACHE PATH "" ) - get_target_property(GMP_LIBRARY_DIR gmp::GMP INTERFACE_LINK_DIRECTORIES) + get_target_property(GMP_LIBRARY_DIR_EXPR gmp::libgmp INTERFACE_LINK_DIRECTORIES) + expand_config_gen_expr("${GMP_LIBRARY_DIR_EXPR}" ${CMAKE_BUILD_TYPE} GMP_LIBRARY_DIR) find_library( GMP_LIBRARY gmp PATHS "${GMP_LIBRARY_DIR}" REQUIRED diff --git a/third_party/libff/CMakeLists.txt b/third_party/libff/CMakeLists.txt index 33519aaace..ee2088e14d 100644 --- a/third_party/libff/CMakeLists.txt +++ b/third_party/libff/CMakeLists.txt @@ -20,4 +20,16 @@ set(CURVE ) option(WITH_PROCPS "" OFF) option(IS_LIBFF_PARENT "" OFF) + +# reduce the log verbosity of libff/CMakeLists.txt +if(NOT CMAKE_MESSAGE_LOG_LEVEL) + set(CMAKE_MESSAGE_LOG_LEVEL_EMPTY YES) + set(CMAKE_MESSAGE_LOG_LEVEL NOTICE) +endif() + add_subdirectory(libff) + +# restore the log verbosity +if(CMAKE_MESSAGE_LOG_LEVEL_EMPTY) + unset(CMAKE_MESSAGE_LOG_LEVEL) +endif() diff --git a/third_party/llvm/README.md b/third_party/llvm/README.md index 295543f26f..9651564720 100644 --- a/third_party/llvm/README.md +++ b/third_party/llvm/README.md @@ -10,4 +10,8 @@ To re-compile, run the following commands: The problem with the standard build delivered by the `compiler_install.sh` is that the libFuzzer is linked against the libstdc++ library. This is not compatible with the libc++ library used by the Silkworm project. Therefore, we need to re-compile the libFuzzer library. To prevent the lengthy recompliation of the whole LLVM project, we deliver the pre-compiled libFuzzer library in this repository. -The similar issue has been in https://github.com/google/oss-fuzz/issues/2328. \ No newline at end of file +The similar issue has been in https://github.com/google/oss-fuzz/issues/2328. + +Update llvm.sh using: + + curl -O https://apt.llvm.org/llvm.sh