From 0617dc221dfae1e3628f97ef3ac8ef396da4d31d Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Thu, 16 Jan 2025 16:10:30 -0500 Subject: [PATCH] fix: Use consistent CMake settings for all modules (#5228) * Resolves an issue introduced in #5111, which inadvertently removed the -Wno-maybe-uninitialized compiler option from some xrpl.libxrpl modules. This resulted in new "may be used uninitialized" build warnings, first noticed in the "protocol" module. When compiling with derr=TRUE, those warnings became errors, which made the build fail. * Github CI actions will build with the assert and werr options turned on. This will cause CI jobs to fail if a developer introduces a new compiler warning, or causes an assert to fail in release builds. * Includes the OS and compiler version in the linux dependencies jobs in the "check environment" step. * Translates the `unity` build option into `CMAKE_UNITY_BUILD` setting. --- cmake/RippledCore.cmake | 43 ++++------------------- cmake/RippledInterface.cmake | 7 +++- cmake/RippledSettings.cmake | 1 + src/xrpld/app/paths/detail/DirectStep.cpp | 2 +- 4 files changed, 15 insertions(+), 38 deletions(-) diff --git a/cmake/RippledCore.cmake b/cmake/RippledCore.cmake index 123822558..d9ac6f80f 100644 --- a/cmake/RippledCore.cmake +++ b/cmake/RippledCore.cmake @@ -9,6 +9,7 @@ include(target_protobuf_sources) # define a bunch of `static const` variables with the same names, # so we just build them as a separate library. add_library(xrpl.libpb) +set_target_properties(xrpl.libpb PROPERTIES UNITY_BUILD OFF) target_protobuf_sources(xrpl.libpb xrpl/proto LANGUAGE cpp IMPORT_DIRS include/xrpl/proto @@ -49,17 +50,22 @@ target_link_libraries(xrpl.libpb # TODO: Clean up the number of library targets later. add_library(xrpl.imports.main INTERFACE) -target_link_libraries(xrpl.imports.main INTERFACE + +target_link_libraries(xrpl.imports.main + INTERFACE LibArchive::LibArchive OpenSSL::Crypto Ripple::boost + wasmedge::wasmedge Ripple::opts Ripple::syslibs absl::random_random date::date ed25519::ed25519 secp256k1::secp256k1 + xrpl.libpb xxHash::xxhash + $<$:antithesis-sdk-cpp> ) include(add_module) @@ -104,9 +110,6 @@ target_link_libraries(xrpl.libxrpl.server PUBLIC xrpl.libxrpl.protocol) add_library(xrpl.libxrpl) set_target_properties(xrpl.libxrpl PROPERTIES OUTPUT_NAME xrpl) -if(unity) - set_target_properties(xrpl.libxrpl PROPERTIES UNITY_BUILD ON) -endif() # Try to find the ACL library find_library(ACL_LIBRARY NAMES acl) @@ -145,40 +148,8 @@ target_link_modules(xrpl PUBLIC # $ # $) -target_compile_definitions(xrpl.libxrpl - PUBLIC - BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT - BOOST_CONTAINER_FWD_BAD_DEQUE - HAS_UNCAUGHT_EXCEPTIONS=1) - -target_compile_options(xrpl.libxrpl - PUBLIC - $<$:-Wno-maybe-uninitialized> - $<$:-DENABLE_VOIDSTAR> -) - -target_link_libraries(xrpl.libxrpl - PUBLIC - LibArchive::LibArchive - OpenSSL::Crypto - Ripple::boost - wasmedge::wasmedge - Ripple::opts - Ripple::syslibs - absl::random_random - date::date - ed25519::ed25519 - secp256k1::secp256k1 - xrpl.libpb - xxHash::xxhash - $<$:antithesis-sdk-cpp> -) - if(xrpld) add_executable(rippled) - if(unity) - set_target_properties(rippled PROPERTIES UNITY_BUILD ON) - endif() if(tests) target_compile_definitions(rippled PUBLIC ENABLE_TESTS) endif() diff --git a/cmake/RippledInterface.cmake b/cmake/RippledInterface.cmake index ec7dd7416..93a973ac7 100644 --- a/cmake/RippledInterface.cmake +++ b/cmake/RippledInterface.cmake @@ -7,6 +7,9 @@ add_library (Ripple::opts ALIAS opts) target_compile_definitions (opts INTERFACE BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS + BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT + BOOST_CONTAINER_FWD_BAD_DEQUE + HAS_UNCAUGHT_EXCEPTIONS=1 $<$: BOOST_ASIO_NO_DEPRECATED BOOST_FILESYSTEM_NO_DEPRECATED @@ -18,10 +21,12 @@ target_compile_definitions (opts > $<$:BEAST_NO_UNIT_TEST_INLINE=1> $<$:BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES=1> - $<$:RIPPLE_SINGLE_IO_SERVICE_THREAD=1>) + $<$:RIPPLE_SINGLE_IO_SERVICE_THREAD=1> + $<$:ENABLE_VOIDSTAR>) target_compile_options (opts INTERFACE $<$,$>:-Wsuggest-override> + $<$:-Wno-maybe-uninitialized> $<$:-fno-omit-frame-pointer> $<$,$>:-g --coverage -fprofile-abs-path> $<$,$>:-g --coverage> diff --git a/cmake/RippledSettings.cmake b/cmake/RippledSettings.cmake index 3eeebed42..58877e188 100644 --- a/cmake/RippledSettings.cmake +++ b/cmake/RippledSettings.cmake @@ -17,6 +17,7 @@ if(unity) if(NOT is_ci) set(CMAKE_UNITY_BUILD_BATCH_SIZE 15 CACHE STRING "") endif() + set(CMAKE_UNITY_BUILD ON CACHE BOOL "Do a unity build") endif() if(is_clang AND is_linux) option(voidstar "Enable Antithesis instrumentation." OFF) diff --git a/src/xrpld/app/paths/detail/DirectStep.cpp b/src/xrpld/app/paths/detail/DirectStep.cpp index 0c9879306..88cc03287 100644 --- a/src/xrpld/app/paths/detail/DirectStep.cpp +++ b/src/xrpld/app/paths/detail/DirectStep.cpp @@ -336,7 +336,7 @@ DirectIPaymentStep::quality(ReadView const& sb, QualityDirection qDir) const if (!sle) return QUALITY_ONE; - auto const& field = [this, qDir]() -> SF_UINT32 const& { + auto const& field = [&, this]() -> SF_UINT32 const& { if (qDir == QualityDirection::in) { // compute dst quality in