Adding boost as a submodule rather than requiring it to be provided externally.

The boost libs are now statically linked to the nano targets so dynamic linking related functionality has been removed.
Adding several target link references that were missing but not apparent when using the unified boost install directories
Linking to boost stacktrace basic as this is the main functionality we use.
Windows Event Log support has been disabled as there is a compatibility issue with GitHub builders
Windows cryptopp ASM has been disabled since CMake isn't assembling .asm files for unknown reasons.
Added boost_checkout_lite.sh script which can be used to do a minimal clone of the boost submodule after it's been added but not yet initialized.
This commit is contained in:
clemahieu 2023-01-13 12:37:09 +00:00
commit 9b2d4a6709
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
19 changed files with 171 additions and 212 deletions

3
.gitmodules vendored
View file

@ -26,3 +26,6 @@
[submodule "diskhash"]
path = diskhash
url = https://github.com/nanocurrency/diskhash.git
[submodule "boost"]
path = boost
url = https://github.com/boostorg/boost.git

View file

@ -9,11 +9,6 @@ if(CMAKE_VERSION VERSION_GREATER 3.13 OR CMAKE_VERSION VERSION_EQUAL 3.13)
cmake_policy(SET CMP0077 NEW)
endif()
if(CMAKE_VERSION VERSION_LESS 3.13)
# compatibility for boost import targets use bundled 3.13 FindBoost.cmake
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/legacyModules")
endif()
# compatibility for osx sierra and on needs to be set before project
set(CMAKE_OSX_DEPLOYMENT_TARGET
10.14
@ -65,8 +60,7 @@ else()
endif()
if(APPLE)
set(CMAKE_INSTALL_RPATH
"@executable_path/../Frameworks;@executable_path/../boost/lib")
set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks")
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
endif()
@ -129,16 +123,6 @@ set(NANO_ROCKSDB_TOOLS
OFF
CACHE BOOL "")
option(NANO_STACKTRACE_BACKTRACE
"Use BOOST_STACKTRACE_USE_BACKTRACE in stacktraces, for POSIX" OFF)
if(NANO_STACKTRACE_BACKTRACE)
add_definitions(-DNANO_STACKTRACE_BACKTRACE=1)
if(BACKTRACE_INCLUDE)
add_definitions(
-DBOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE=${BACKTRACE_INCLUDE})
endif()
endif()
if(${NANO_TIMED_LOCKS} GREATER 0)
add_definitions(-DNANO_TIMED_LOCKS=${NANO_TIMED_LOCKS})
add_definitions(-DNANO_TIMED_LOCKS_FILTER=${NANO_TIMED_LOCKS_FILTER})
@ -360,35 +344,110 @@ else()
endif()
include_directories(${CMAKE_SOURCE_DIR})
if(WIN32
AND NANO_TEST
AND NANO_SHARED_BOOST)
message(
SEND_ERROR
" Linking errors occur if NANO_SHARED_BOOST is used with tests on Windows"
" Disable NANO_SHARED_BOOST or NANO_TEST on Windows")
set(NANO_SHARED_BOOST)
endif()
set(NANO_SHARED_BOOST
OFF
CACHE BOOL "Build Nano with shared boost")
if(NANO_SHARED_BOOST)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_NO_BOOST_CMAKE ON)
add_definitions(-DBOOST_ALL_DYN_LINK)
else()
set(Boost_USE_STATIC_LIBS ON)
endif()
set(Boost_USE_MULTITHREADED ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
find_package(Boost 1.81.0 REQUIRED COMPONENTS filesystem log log_setup thread
program_options system)
set(Boost_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/boost/libs/config/include)
set(BOOST_MODULE_LIBS
algorithm
align
any
array
asio
assert
atomic
beast
bind
chrono
circular_buffer
concept_check
config
container
container_hash
context
conversion
core
coroutine
date_time
describe
detail
dll
dynamic_bitset
endian
exception
filesystem
foreach
format
function
function_types
functional
fusion
integer
interprocess
intrusive
io
iostreams
iterator
lexical_cast
property_tree
log
logic
math
move
mp11
mpl
multi_index
multiprecision
numeric/conversion
optional
parameter
phoenix
pool
predef
preprocessor
process
program_options
proto
random
range
ratio
rational
regex
serialization
smart_ptr
spirit
stacktrace
static_assert
static_string
system
thread
throw_exception
tokenizer
tuple
type_index
type_traits
typeof
unordered
utility
variant
variant2
winapi)
add_definitions(-DBOOST_ALL_NO_LIB) # Disable automatic boost linking
foreach(lib IN LISTS BOOST_MODULE_LIBS)
add_subdirectory(boost/libs/${lib} EXCLUDE_FROM_ALL)
endforeach()
include_directories(${BOOST_LIBRARY_INCLUDES})
add_library(Boost::stacktrace ALIAS boost_stacktrace_basic)
add_definitions(-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED)
# Workaround for GitHub builders which do not appear to have the Windows Message
# Compiler mc.exe
add_definitions(-DBOOST_LOG_WITHOUT_EVENT_LOG)
# Workaround for missing reference errata in the boost property_tree module
target_link_libraries(boost_property_tree INTERFACE Boost::any)
target_link_libraries(boost_property_tree INTERFACE Boost::format)
target_link_libraries(boost_property_tree INTERFACE Boost::multi_index)
# diskhash
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
@ -457,11 +516,8 @@ set(USE_INTERMEDIATE_OBJECTS_TARGET
CACHE BOOL "")
set(CRYPTOPP_EXTRA "")
if(WIN32)
set(CRYPTOPP_EXTRA crypto/cryptopp/x64dll.asm crypto/cryptopp/x64masm.asm)
enable_language(ASM)
enable_language(ASM_MASM)
# similar to SSE2 settings
add_definitions(-DCRYPTOPP_DISABLE_SSSE3 -DCRYPTOPP_DISABLE_AESNI)
add_definitions(-DCRYPTOPP_DISABLE_ASM -DCRYPTOPP_DISABLE_SSSE3
-DCRYPTOPP_DISABLE_AESNI)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64"
AND (NANO_SIMD_OPTIMIZATIONS OR RAIBLOCKS_SIMD_OPTIMIZATIONS))
set(CRYPTOPP_EXTRA
@ -585,7 +641,6 @@ if(NANO_FUZZER_TEST)
endif()
if(NANO_TEST OR RAIBLOCKS_TEST)
find_package(Boost 1.81.0 REQUIRED COMPONENTS coroutine context)
if(WIN32)
if(MSVC_VERSION)
if(MSVC_VERSION GREATER_EQUAL 1910)
@ -756,16 +811,6 @@ if(NANO_GUI OR RAIBLOCKS_GUI)
DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Frameworks)
install(FILES "${Qt5_DIR}/../../../plugins/platforms/libqcocoa.dylib"
DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/PlugIns/platforms)
if(NANO_SHARED_BOOST)
foreach(boost_lib IN LISTS Boost_LIBRARIES)
string(REGEX MATCH "(.+/.*boost_[^-]+)" boost_lib_name ${boost_lib})
set(boost_dll "${CMAKE_MATCH_1}")
if(${boost_dll} MATCHES "boost")
install(FILES ${boost_dll}
DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/boost/lib)
endif()
endforeach(boost_lib)
endif()
install(FILES Nano.icns
DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Resources)
elseif(WIN32)
@ -794,25 +839,6 @@ if(NANO_GUI OR RAIBLOCKS_GUI)
get_filename_component(Qt5_bin_DIR ${Qt5_DIR}/../../../bin ABSOLUTE)
install(TARGETS nano_wallet DESTINATION .)
install(TARGETS nano_wallet_com DESTINATION .)
if(NANO_SHARED_BOOST)
foreach(boost_lib IN LISTS Boost_LIBRARIES)
if(${CMAKE_BUILD_TYPE} MATCHES "Rel")
string(REGEX MATCH "(.+/.*boost_[^-]+-.+-mt-x64.+\)(.lib|a)"
boost_lib_name ${boost_lib})
set(boost_dll "${CMAKE_MATCH_1}.dll")
if(${boost_dll} MATCHES "boost")
install(FILES ${boost_dll} DESTINATION .)
endif()
else()
string(REGEX MATCH "(.+/.*boost_[^-]+-.+-mt-.+-x64.+\)(.lib|a)"
boost_lib_name ${boost_lib})
set(boost_dll "${CMAKE_MATCH_1}.dll")
if(${boost_dll} MATCHES "boost")
install(FILES ${boost_dll} DESTINATION .)
endif()
endif()
endforeach(boost_lib)
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${WIN_REDIST} DESTINATION .)
install(FILES ${Qt5_bin_DIR}/libGLESv2.dll DESTINATION .)
install(FILES ${Qt5_bin_DIR}/Qt5Core.dll DESTINATION .)
@ -826,15 +852,6 @@ if(NANO_GUI OR RAIBLOCKS_GUI)
"qt5-default | qtbase5-dev, qtchooser, qt5-qmake, qtbase5-dev-tools")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "russel@nano.org")
install(TARGETS nano_wallet RUNTIME DESTINATION ./bin)
if(NANO_SHARED_BOOST)
foreach(boost_lib IN LISTS Boost_LIBRARIES)
string(REGEX MATCH "(.+/.*boost_[^-]+)" boost_lib_name ${boost_lib})
set(boost_dll "${CMAKE_MATCH_1}.${Boost_VERSION_STRING}")
if(${boost_dll} MATCHES "boost")
install(FILES ${boost_dll} DESTINATION ./lib)
endif()
endforeach(boost_lib)
endif()
set(DEBIAN_POSTINST postinst.in)
set(DEBIAN_POSTRM postrm.in)

1
boost Submodule

@ -0,0 +1 @@
Subproject commit da041154c6bac1a4aa98254a7d6819059e8ac0b0

19
boost_checkout_lite.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/bash
#set -x
#Check out boost submodule with minimum set of modules to reduce size
# flattened boost libs dependency list
dependencies=("algorithm" "align" "any" "array" "asio" "assert" "atomic" "beast" "bind" "chrono" "circular_buffer" "concept_check" "config" "container" "container_hash" "context" "conversion" "core" "coroutine" "date_time" "describe" "detail" "dll" "dynamic_bitset" "endian" "exception" "filesystem" "foreach" "format" "function" "function_types" "functional" "fusion" "integer" "interprocess" "intrusive" "io" "iostreams" "iterator" "lexical_cast" "log" "logic" "math" "move" "mp11" "mpl" "multi_index" "multiprecision" "numeric_conversion" "optional" "parameter" "phoenix" "pool" "predef" "preprocessor" "process" "program_options" "property_tree" "proto" "random" "range" "ratio" "rational" "regex" "serialization" "smart_ptr" "spirit" "stacktrace" "static_assert" "static_string" "system" "thread" "throw_exception" "tokenizer" "tuple" "type_index" "type_traits" "typeof" "unordered" "utility" "variant" "variant2" "winapi")
git submodule init boost
cd boost
# deactivate all boost submodules
git submodule foreach 'git config submodule.$sm_path.active false'
# selectivly activate required dependencies
for i in ${dependencies[@]}
do
git config submodule.$i.active true
done
cd ..
# Update all submodules recursivly. Deactivated modules will be skipped by --recursive
git submodule update --jobs 16 --recursive --recommend-shallow --single-branch

View file

@ -26,4 +26,4 @@ set exit_code=%errorlevel%
goto exit
:exit
exit /B %exit_code%
exit /B %exit_code%

View file

@ -12,7 +12,6 @@ if (${env:artifact} -eq 1) {
else {
$env:NETWORK_CFG = "live"
}
$env:NANO_SHARED_BOOST = "ON"
$env:NANO_TEST = "-DNANO_TEST=OFF"
$env:CI_TAG = ${env:TAG}
if ([string]::IsNullOrEmpty(${env:VERSION_PRE_RELEASE})) {
@ -27,10 +26,9 @@ else {
if ( ${env:RELEASE} -eq "true" -or ${env:TEST_USE_ROCKSDB} -eq 1 ) {
$env:BUILD_TYPE = "RelWithDebInfo"
}
else {
else {
$env:BUILD_TYPE = "Debug"
}
$env:NANO_SHARED_BOOST = "OFF"
$env:NETWORK_CFG = "dev"
$env:NANO_TEST = "-DNANO_TEST=ON"
$env:CI = '-DCI_TEST="1"'
@ -40,9 +38,6 @@ else {
mkdir build
Push-Location build
#accessibility of Boost dlls for generating config samples
$ENV:PATH = "$ENV:PATH;$ENV:BOOST_ROOT\lib64-msvc-14.2"
& ..\ci\actions\windows\configure.bat
if (${LastExitCode} -ne 0) {
throw "Failed to configure"
@ -65,4 +60,4 @@ if (${LastExitCode} -ne 0) {
throw "Failed to Pass Test ${env:RUN}"
}
Pop-Location
Pop-Location

View file

@ -15,13 +15,10 @@ cmake .. ^
-DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^
-DACTIVE_NETWORK=nano_%NETWORK_CFG%_network ^
-DNANO_SIMD_OPTIMIZATIONS=TRUE ^
-Dgtest_force_shared_crt=on ^
-DBoost_NO_SYSTEM_PATHS=TRUE ^
-DBoost_NO_BOOST_CMAKE=TRUE ^
-DNANO_SHARED_BOOST=%NANO_SHARED_BOOST%
-Dgtest_force_shared_crt=on
set exit_code=%errorlevel%
if %exit_code% neq 0 goto exit
:exit
exit /B %exit_code%
exit /B %exit_code%

View file

@ -13,7 +13,7 @@ function Get-RedirectedUri {
.NOTES
Code from: Redone per issue #2896 in core https://github.com/PowerShell/PowerShell/issues/2896
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
@ -31,7 +31,7 @@ function Get-RedirectedUri {
# This is for Powershell core
$redirectUri = $request.BaseResponse.RequestMessage.RequestUri.AbsoluteUri
}
$retry = $false
}
catch {
@ -44,12 +44,10 @@ function Get-RedirectedUri {
}
}
} while ($retry)
$redirectUri
}
}
$boost_url = Get-RedirectedUri "https://repo.nano.org/artifacts/boost-msvc14.2-1.70-full.zip"
$BOOST_ROOT = "c:\local\boost_1_70_0"
$qt5_root = "c:\qt"
$qt5base_url = Get-RedirectedUri "https://repo.nano.org/artifacts/5.13.1-0-201909031231qtbase-Windows-Windows_10-MSVC2017-Windows-Windows_10-X86_64.7z"
$qt5winextra_url = Get-RedirectedUri "https://repo.nano.org/artifacts/5.13.1-0-201909031231qtwinextras-Windows-Windows_10-MSVC2017-Windows-Windows_10-X86_64.7z"
@ -62,10 +60,3 @@ mkdir $qt5_root
Push-Location $qt5_root
7z x "${env:TMP}\qt5*.7z" -aoa
Pop-Location
mkdir $BOOST_ROOT
Write-Output "BOOST_ROOT=$BOOST_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
(New-Object System.Net.WebClient).DownloadFile($boost_url, "${env:TMP}\boost-msvc.zip")
Push-Location $BOOST_ROOT
7z x "${env:TMP}\boost-msvc.zip" -aoa

View file

@ -93,11 +93,14 @@ target_link_libraries(
ipc_flatbuffers_lib
${CRYPTOPP_LIBRARY}
${CMAKE_DL_LIBS}
Boost::program_options)
if(NANO_STACKTRACE_BACKTRACE)
target_link_libraries(nano_lib backtrace)
endif()
Boost::asio
Boost::circular_buffer
Boost::dll
Boost::log_setup
Boost::log
Boost::multiprecision
Boost::program_options
Boost::stacktrace)
target_compile_definitions(
nano_lib

View file

@ -4,42 +4,21 @@
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#include <cstddef>
#include <fstream>
#include <iostream>
#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#endif
#include <boost/stacktrace.hpp>
#include <cstddef>
#include <fstream>
#include <iostream>
#include <limits>
#include <sstream>
#include <string_view>
#include <thread>
// Some builds (mac) fail due to "Boost.Stacktrace requires `_Unwind_Backtrace` function".
#ifndef _WIN32
#ifdef NANO_STACKTRACE_BACKTRACE
#define BOOST_STACKTRACE_USE_BACKTRACE
#endif
#ifndef _GNU_SOURCE
#define BEFORE_GNU_SOURCE 0
#define _GNU_SOURCE
#else
#define BEFORE_GNU_SOURCE 1
#endif
#endif
// On Windows this include defines min/max macros, so keep below other includes
// to reduce conflicts with other std functions
#include <boost/stacktrace.hpp>
#ifndef _WIN32
#if !BEFORE_GNU_SOURCE
#undef _GNU_SOURCE
#endif
#endif
#ifndef _WIN32
#include <sys/resource.h>
#endif

View file

@ -1,10 +1,3 @@
add_executable(load_test entry.cpp)
target_link_libraries(
load_test
node
secure
test_common
gtest
Boost::coroutine
Boost::context)
target_link_libraries(load_test node secure test_common gtest)

View file

@ -1,10 +1,13 @@
add_executable(nano_node daemon.cpp daemon.hpp entry.cpp)
target_link_libraries(nano_node node rpc secure argon2 ${PLATFORM_LIBS})
if(NANO_STACKTRACE_BACKTRACE)
target_link_libraries(nano_node backtrace)
endif()
target_link_libraries(
nano_node
Boost::process
node
rpc
secure
argon2
${PLATFORM_LIBS})
target_compile_definitions(
nano_node PRIVATE -DTAG_VERSION_STRING=${TAG_VERSION_STRING}

View file

@ -15,6 +15,12 @@
#include <boost/lexical_cast.hpp>
#include <boost/program_options.hpp>
#include <boost/range/adaptor/reversed.hpp>
#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#endif
#include <boost/stacktrace.hpp>
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
@ -23,25 +29,6 @@
#include <argon2.h>
// Some builds (mac) fail due to "Boost.Stacktrace requires `_Unwind_Backtrace` function".
#ifndef _WIN32
#ifdef NANO_STACKTRACE_BACKTRACE
#define BOOST_STACKTRACE_USE_BACKTRACE
#endif
#ifndef _GNU_SOURCE
#define BEFORE_GNU_SOURCE 0
#define _GNU_SOURCE
#else
#define BEFORE_GNU_SOURCE 1
#endif
#endif
#include <boost/stacktrace.hpp>
#ifndef _WIN32
#if !BEFORE_GNU_SOURCE
#undef _GNU_SOURCE
#endif
#endif
namespace
{
class uint64_from_hex // For use with boost::lexical_cast to read hexadecimal strings

View file

@ -234,10 +234,12 @@ target_link_libraries(
libminiupnpc-static
argon2
lmdb
Boost::beast
Boost::filesystem
Boost::log_setup
Boost::log
Boost::program_options
Boost::stacktrace
Boost::system
Boost::thread
rocksdb
@ -245,10 +247,6 @@ target_link_libraries(
${CMAKE_DL_LIBS}
${psapi_lib})
if(NANO_STACKTRACE_BACKTRACE)
target_link_libraries(node backtrace)
endif()
target_compile_definitions(
node PRIVATE -DTAG_VERSION_STRING=${TAG_VERSION_STRING}
-DGIT_COMMIT_HASH=${GIT_COMMIT_HASH})

View file

@ -8,26 +8,12 @@
#include <boost/format.hpp>
// Some builds (mac) fail due to "Boost.Stacktrace requires `_Unwind_Backtrace` function".
#ifndef _WIN32
#ifdef NANO_STACKTRACE_BACKTRACE
#define BOOST_STACKTRACE_USE_BACKTRACE
#endif
#ifndef _GNU_SOURCE
#define BEFORE_GNU_SOURCE 0
#define _GNU_SOURCE
#else
#define BEFORE_GNU_SOURCE 1
#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#endif
// On Windows this include defines min/max macros, so keep below other includes
// to reduce conflicts with other std functions
#include <boost/stacktrace.hpp>
#ifndef _WIN32
#if !BEFORE_GNU_SOURCE
#undef _GNU_SOURCE
#endif
#endif
namespace
{

View file

@ -12,7 +12,6 @@
#include <boost/log/utility/setup/file.hpp>
#ifdef BOOST_WINDOWS
#include <boost/log/sinks/event_log_backend.hpp>
#else
#define BOOST_LOG_USE_NATIVE_SYSLOG
#include <boost/log/sinks/syslog_backend.hpp>
@ -37,20 +36,6 @@ void nano::logging::init (boost::filesystem::path const & application_path_a)
}
#ifdef BOOST_WINDOWS
if (nano::event_log_reg_entry_exists () || nano::is_windows_elevated ())
{
static auto event_sink = boost::make_shared<boost::log::sinks::synchronous_sink<boost::log::sinks::simple_event_log_backend>> (boost::log::keywords::log_name = "Nano", boost::log::keywords::log_source = "Nano");
event_sink->set_formatter (format);
// Currently only mapping sys log errors
boost::log::sinks::event_log::custom_event_type_mapping<nano::severity_level> mapping ("Severity");
mapping[nano::severity_level::error] = boost::log::sinks::event_log::error;
event_sink->locked_backend ()->set_event_type_mapper (mapping);
// Only allow messages or error or greater severity to the event log
event_sink->set_filter (severity >= nano::severity_level::error);
boost::log::core::get ()->add_sink (event_sink);
}
#else
static auto sys_sink = boost::make_shared<boost::log::sinks::synchronous_sink<boost::log::sinks::syslog_backend>> (boost::log::keywords::facility = boost::log::sinks::syslog::user, boost::log::keywords::use_impl = boost::log::sinks::syslog::impl_types::native);
sys_sink->set_formatter (format);

View file

@ -15,4 +15,4 @@ add_library(
rpc_request_processor.hpp
rpc_request_processor.cpp)
target_link_libraries(rpc nano_lib ${OPENSSL_LIBRARIES})
target_link_libraries(rpc Boost::beast nano_lib ${OPENSSL_LIBRARIES})

View file

@ -60,6 +60,7 @@ target_link_libraries(
ed25519
crypto_lib
lmdb
Boost::iostreams
Boost::system
Boost::filesystem)

View file

@ -15,6 +15,7 @@
#include <boost/property_tree/ptree_fwd.hpp>
#include <boost/variant/variant.hpp>
#include <array>
#include <unordered_map>
namespace boost