diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e32944c81a..e08f04143c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,13 +20,13 @@ jobs: - os: ubuntu-22.04 cxx: "clang++-15" link: "dynamic" - optimization: "debug" + optimization: "size" assert: "debug" coverage: "nocov" boost: "--build-boost" icu: "" cc: "clang-15" - flags: "-Og -fPIE" + flags: "-Os -fPIE" options: "--enable-isystem --enable-avx2 --enable-sse4" packager: "apt" packages: "" @@ -62,14 +62,14 @@ jobs: - os: ubuntu-22.04 cxx: "g++-11" link: "static" - optimization: "size" + optimization: "debug" assert: "ndebug" coverage: "cov" boost: "--build-boost" icu: "--build-icu --with-icu" cc: "gcc-11" - flags: "-Os -g --coverage -fPIE" - options: "--enable-isystem" + flags: "-Og -g --coverage -fPIE" + options: "--enable-isystem --enable-avx512" packager: "apt" packages: "lcov" @@ -113,7 +113,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Prepare toolchain [generic] run: | @@ -134,7 +134,7 @@ jobs: shell: bash run: | WORKSPACE_SUBPATH="${GITHUB_WORKSPACE%libbitcoin-system}" - echo "LIBBITCOIN_SRC_PATH=${WORKSPACE_SUBPATH}" >> $GITHUB_ENV + echo "LIBBITCOIN_SRC_PATH=$WORKSPACE_SUBPATH" >> $GITHUB_ENV if [[ ${{ matrix.assert }} == 'ndebug' ]]; then echo "ASSERT_NDEBUG=--enable-ndebug" >> $GITHUB_ENV else @@ -146,7 +146,7 @@ jobs: echo "LINKAGE=--disable-shared" >> $GITHUB_ENV fi if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LDFLAGS=-Wl,-rpath,${WORKSPACE_SUBPATH}prefix/lib" >> $GITHUB_ENV + echo "LDFLAGS=-Wl,-rpath,$WORKSPACE_SUBPATH/prefix/lib" >> $GITHUB_ENV fi - name: Display Compiler details @@ -243,13 +243,13 @@ jobs: - os: ubuntu-22.04 cxx: "clang++-15" link: "dynamic" - optimization: "debug" + optimization: "size" assert: "debug" coverage: "nocov" boost: "--build-boost" icu: "" cc: "clang-15" - flags: "-Og -fPIE" + flags: "-Os -fPIE" options: "-Denable-avx2=on -Denable-sse4=on" packager: "apt" packages: "" @@ -285,14 +285,14 @@ jobs: - os: ubuntu-22.04 cxx: "g++-11" link: "static" - optimization: "size" + optimization: "debug" assert: "ndebug" coverage: "nocov" boost: "--build-boost" icu: "--build-icu --with-icu" cc: "gcc-11" - flags: "-Os -fPIE" - options: "" + flags: "-Og -fPIE" + options: "-Denable-avx512=on" packager: "apt" packages: "" @@ -336,7 +336,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Prepare toolchain [generic] run: | @@ -357,7 +357,7 @@ jobs: shell: bash run: | WORKSPACE_SUBPATH="${GITHUB_WORKSPACE%libbitcoin-system}" - echo "LIBBITCOIN_SRC_PATH=${WORKSPACE_SUBPATH}" >> $GITHUB_ENV + echo "LIBBITCOIN_SRC_PATH=$WORKSPACE_SUBPATH" >> $GITHUB_ENV if [[ ${{ matrix.packager }} == 'brew' ]]; then echo "CMAKE_LIBRARY_PATH=/usr/local/lib" >> $GITHUB_ENV fi @@ -372,7 +372,7 @@ jobs: echo "LINKAGE=--disable-shared" >> $GITHUB_ENV fi if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LDFLAGS=-Wl,-rpath,${WORKSPACE_SUBPATH}prefix/lib" >> $GITHUB_ENV + echo "LDFLAGS=-Wl,-rpath,$WORKSPACE_SUBPATH/prefix/lib" >> $GITHUB_ENV fi - name: Display Compiler details @@ -480,13 +480,13 @@ jobs: preset: "nix-gnu-debug-shared-without_icu" cxx: "clang++-15" link: "dynamic" - optimization: "debug" + optimization: "size" assert: "debug" coverage: "nocov" boost: "--build-boost" icu: "" cc: "clang-15" - flags: "-Og -fPIE" + flags: "-Os -fPIE" options: "-Denable-avx2=on -Denable-sse4=on" packager: "apt" packages: "" @@ -533,7 +533,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Prepare toolchain [generic] run: | @@ -554,7 +554,7 @@ jobs: shell: bash run: | WORKSPACE_SUBPATH="${GITHUB_WORKSPACE%libbitcoin-system}" - echo "LIBBITCOIN_SRC_PATH=${WORKSPACE_SUBPATH}" >> $GITHUB_ENV + echo "LIBBITCOIN_SRC_PATH=$WORKSPACE_SUBPATH" >> $GITHUB_ENV if [[ ${{ matrix.packager }} == 'brew' ]]; then echo "CMAKE_LIBRARY_PATH=/usr/local/lib" >> $GITHUB_ENV fi @@ -569,7 +569,7 @@ jobs: echo "LINKAGE=--disable-shared" >> $GITHUB_ENV fi if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LDFLAGS=-Wl,-rpath,${WORKSPACE_SUBPATH}prefix/${{ matrix.preset }}/lib" >> $GITHUB_ENV + echo "LDFLAGS=-Wl,-rpath,$WORKSPACE_SUBPATH/prefix/${{ matrix.preset }}/lib" >> $GITHUB_ENV fi - name: Display Compiler details @@ -706,7 +706,7 @@ jobs: msbuild-architecture: x64 - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Initialize SDK shell: powershell diff --git a/builds/cmake/CMakeLists.txt b/builds/cmake/CMakeLists.txt index 7aeff4b5bb..20876439c1 100644 --- a/builds/cmake/CMakeLists.txt +++ b/builds/cmake/CMakeLists.txt @@ -7,7 +7,7 @@ # libbitcoin-system project configuration. #------------------------------------------------------------------------------ -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) project(libbitcoin-system LANGUAGES C CXX) @@ -18,7 +18,6 @@ include(CheckIncludeFiles) include(CheckSymbolExists) include(CheckCXXCompilerFlag) include(CheckCXXSourceCompiles) -include(CheckLinkerFlag) set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -98,14 +97,6 @@ else() message( FATAL_ERROR "Compiler does not support -Wno-deprecated-copy" ) endif() -# Suppress warning for ignored attributes (arising on template arguments). -check_cxx_compiler_flag( "-Wno-ignored-attributes" HAS_FLAG_WNO-IGNORED-ATTRIBUTES ) -if ( HAS_FLAG_WNO-IGNORED-ATTRIBUTES ) - add_compile_options( "-Wno-ignored-attributes" ) -else() - message( FATAL_ERROR "Compiler does not support -Wno-ignored-attributes" ) -endif() - # Allow use of C99 'long long' type. check_cxx_compiler_flag( "-Wno-long-long" HAS_FLAG_WNO-LONG-LONG ) if ( HAS_FLAG_WNO-LONG-LONG ) @@ -335,7 +326,11 @@ set( boost_system_LIBS "-lboost_system" ) set( boost_thread_LIBS "-lboost_thread" ) set( boost_unit_test_framework_LIBS "-lboost_unit_test_framework" ) -set( Boost_LIBRARY_DIR $,"${Boost_LIBRARY_DIR_RELEASE}","${Boost_LIBRARY_DIR_DEBUG}">) +if (enable-ndebug) + set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_DEBUG}" ) +else () + set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_RELEASE}" ) +endif() set( boost_CPPFLAGS "-I${Boost_INCLUDE_DIR}" ) set( boost_LDFLAGS "-L${Boost_LIBRARY_DIR}" ) @@ -378,92 +373,81 @@ endif() #------------------------------------------------------------------------------ find_package( Secp256K1 0.1.0.20 REQUIRED ) -# Define project common includes for build. -#------------------------------------------------------------------------------ -if (BUILD_SHARED_LIBS) - set( icu_i18n_FOR_BUILD_INCLUDE_DIRS ${icu_i18n_INCLUDE_DIRS} CACHE STRING "Placeholder" ) - set( secp256k1_FOR_BUILD_INCLUDE_DIRS ${secp256k1_INCLUDE_DIRS} CACHE STRING "Placeholder" ) -else() - set( icu_i18n_FOR_BUILD_INCLUDE_DIRS ${icu_i18n_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) - set( secp256k1_FOR_BUILD_INCLUDE_DIRS ${secp256k1_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) -endif() - # Define project common includes directories #------------------------------------------------------------------------------ -include_directories( SYSTEM - ${Boost_INCLUDE_DIR} - ${pthread_INCLUDE_DIRS} - ${rt_INCLUDE_DIRS} - ${icu_i18n_FOR_BUILD_INCLUDE_DIRS} - ${dl_INCLUDE_DIRS} - ${secp256k1_FOR_BUILD_INCLUDE_DIRS} ) - -# Define project common library directories for build. -#------------------------------------------------------------------------------ if (BUILD_SHARED_LIBS) - set( icu_i18n_FOR_BUILD_LIBRARY_DIRS ${icu_i18n_LIBRARY_DIRS} CACHE STRING "Placeholder" ) - set( secp256k1_FOR_BUILD_LIBRARY_DIRS ${secp256k1_LIBRARY_DIRS} CACHE STRING "Placeholder" ) + include_directories( SYSTEM + ${Boost_INCLUDE_DIR} + ${pthread_INCLUDE_DIRS} + ${rt_INCLUDE_DIRS} + ${icu_i18n_INCLUDE_DIRS} + ${dl_INCLUDE_DIRS} + ${secp256k1_INCLUDE_DIRS} ) else() - set( icu_i18n_FOR_BUILD_LIBRARY_DIRS ${icu_i18n_STATIC_LIBRARY_DIRS} CACHE STRING "Placeholder" ) - set( secp256k1_FOR_BUILD_LIBRARY_DIRS ${secp256k1_STATIC_LIBRARY_DIRS} CACHE STRING "Placeholder" ) + include_directories( SYSTEM + ${Boost_INCLUDE_DIR} + ${pthread_INCLUDE_DIRS} + ${rt_INCLUDE_DIRS} + ${icu_i18n_STATIC_INCLUDE_DIRS} + ${dl_INCLUDE_DIRS} + ${secp256k1_STATIC_INCLUDE_DIRS} ) endif() # Define project common library directories #------------------------------------------------------------------------------ -link_directories( - ${Boost_LIBRARY_DIRS} - ${pthread_LIBRARY_DIRS} - ${rt_LIBRARY_DIRS} - ${icu_i18n_FOR_BUILD_LIBRARY_DIRS} - ${dl_LIBRARY_DIRS} - ${secp256k1_FOR_BUILD_LIBRARY_DIRS} ) - -# Define project common linker flags. -#------------------------------------------------------------------------------ -check_linker_flag(CXX "-no_fixup_chains" "no_fixup_chains_FOUND") - -if (no_fixup_chains_FOUND) - add_link_options("-no_fixup_chains") -endif() - -check_linker_flag(CXX "-fstack-protector" "fstack_protector_FOUND") - -if (fstack_protector_FOUND) - add_link_options("-fstack-protector") -endif() - -check_linker_flag(CXX "-fstack-protector-all" "fstack_protector_all_FOUND") - -if (fstack_protector_all_FOUND) - add_link_options("-fstack-protector-all") +if (BUILD_SHARED_LIBS) + link_directories( + ${Boost_LIBRARY_DIRS} + ${pthread_LIBRARY_DIRS} + ${rt_LIBRARY_DIRS} + ${icu_i18n_LIBRARY_DIRS} + ${dl_LIBRARY_DIRS} + ${secp256k1_LIBRARY_DIRS} ) +else() + link_directories( + ${Boost_LIBRARY_DIRS} + ${pthread_LIBRARY_DIRS} + ${rt_LIBRARY_DIRS} + ${icu_i18n_STATIC_LIBRARY_DIRS} + ${dl_LIBRARY_DIRS} + ${secp256k1_STATIC_LIBRARY_DIRS} ) endif() - -# Define common library usage for build. +# Define project common libraries/linker flags. #------------------------------------------------------------------------------ if (BUILD_SHARED_LIBS) - set( icu_i18n_FOR_BUILD_LIBRARIES ${icu_i18n_LIBRARIES} CACHE STRING "Placeholder" ) - set( secp256k1_FOR_BUILD_LIBRARIES ${secp256k1_LIBRARIES} CACHE STRING "Placeholder" ) + link_libraries( + "-fstack-protector" + "-fstack-protector-all" + ${Boost_CHRONO_LIBRARY} + ${Boost_IOSTREAMS_LIBRARY} + ${Boost_JSON_LIBRARY} + ${Boost_LOCALE_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_SYSTEM_LIBRARY} + ${Boost_THREAD_LIBRARY} + ${pthread_LIBRARIES} + ${rt_LIBRARIES} + ${icu_i18n_LIBRARIES} + ${dl_LIBRARIES} + ${secp256k1_LIBRARIES} ) else() - set( icu_i18n_FOR_BUILD_LIBRARIES ${icu_i18n_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) - set( secp256k1_FOR_BUILD_LIBRARIES ${secp256k1_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) -endif() - -# Define project common libraries. -#------------------------------------------------------------------------------ -link_libraries( - ${Boost_CHRONO_LIBRARY} - ${Boost_IOSTREAMS_LIBRARY} - ${Boost_JSON_LIBRARY} - ${Boost_LOCALE_LIBRARY} - ${Boost_PROGRAM_OPTIONS_LIBRARY} - ${Boost_SYSTEM_LIBRARY} - ${Boost_THREAD_LIBRARY} - ${pthread_LIBRARIES} - ${rt_LIBRARIES} - ${icu_i18n_FOR_BUILD_LIBRARIES} - ${dl_LIBRARIES} - ${secp256k1_FOR_BUILD_LIBRARIES} ) + link_libraries( + "-fstack-protector" + "-fstack-protector-all" + ${Boost_CHRONO_LIBRARY} + ${Boost_IOSTREAMS_LIBRARY} + ${Boost_JSON_LIBRARY} + ${Boost_LOCALE_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_SYSTEM_LIBRARY} + ${Boost_THREAD_LIBRARY} + ${pthread_LIBRARIES} + ${rt_LIBRARIES} + ${icu_i18n_STATIC_LIBRARIES} + ${dl_LIBRARIES} + ${secp256k1_STATIC_LIBRARIES} ) +endif() add_definitions( ${icu} ) @@ -614,56 +598,63 @@ add_library( ${CANONICAL_LIB_NAME} "../../src/words/catalogs/electrum_v1.cpp" "../../src/words/catalogs/mnemonic.cpp" ) -# ${CANONICAL_LIB_NAME} project specific include directory normalization for build. +# ${CANONICAL_LIB_NAME} project specific include directories. #------------------------------------------------------------------------------ if (BUILD_SHARED_LIBS) - set( icu_i18n_FOR_BUILD_INCLUDE_DIRS ${icu_i18n_INCLUDE_DIRS} CACHE STRING "Placeholder" ) - set( secp256k1_FOR_BUILD_INCLUDE_DIRS ${secp256k1_INCLUDE_DIRS} CACHE STRING "Placeholder" ) + target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE + "../../include" + ${Boost_INCLUDE_DIR} + ${pthread_INCLUDE_DIRS} + ${rt_INCLUDE_DIRS} + ${icu_i18n_INCLUDE_DIRS} + ${dl_INCLUDE_DIRS} + ${secp256k1_INCLUDE_DIRS} ) else() - set( icu_i18n_FOR_BUILD_INCLUDE_DIRS ${icu_i18n_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) - set( secp256k1_FOR_BUILD_INCLUDE_DIRS ${secp256k1_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) + target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE + "../../include" + ${Boost_INCLUDE_DIR} + ${pthread_INCLUDE_DIRS} + ${rt_INCLUDE_DIRS} + ${icu_i18n_STATIC_INCLUDE_DIRS} + ${dl_INCLUDE_DIRS} + ${secp256k1_STATIC_INCLUDE_DIRS} ) endif() -# ${CANONICAL_LIB_NAME} project specific include directories. -#------------------------------------------------------------------------------ -target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE - "../../include" - ${Boost_INCLUDE_DIR} - ${pthread_INCLUDE_DIRS} - ${rt_INCLUDE_DIRS} - ${icu_i18n_FOR_BUILD_INCLUDE_DIRS} - ${dl_INCLUDE_DIRS} - ${secp256k1_FOR_BUILD_INCLUDE_DIRS} ) - target_include_directories( ${CANONICAL_LIB_NAME} PUBLIC "../../include" ) -# ${CANONICAL_LIB_NAME} project specific libraries noramalization for build. +# ${CANONICAL_LIB_NAME} project specific libraries/linker flags. #------------------------------------------------------------------------------ if (BUILD_SHARED_LIBS) - set( icu_i18n_FOR_BUILD_LIBRARIES ${icu_i18n_LIBRARIES} CACHE STRING "Placeholder" ) - set( secp256k1_FOR_BUILD_LIBRARIES ${secp256k1_LIBRARIES} CACHE STRING "Placeholder" ) + target_link_libraries( ${CANONICAL_LIB_NAME} + ${Boost_CHRONO_LIBRARY} + ${Boost_IOSTREAMS_LIBRARY} + ${Boost_JSON_LIBRARY} + ${Boost_LOCALE_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_SYSTEM_LIBRARY} + ${Boost_THREAD_LIBRARY} + ${pthread_LIBRARIES} + ${rt_LIBRARIES} + ${icu_i18n_LIBRARIES} + ${dl_LIBRARIES} + ${secp256k1_LIBRARIES} ) else() - set( icu_i18n_FOR_BUILD_LIBRARIES ${icu_i18n_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) - set( secp256k1_FOR_BUILD_LIBRARIES ${secp256k1_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) + target_link_libraries( ${CANONICAL_LIB_NAME} + ${Boost_CHRONO_LIBRARY} + ${Boost_IOSTREAMS_LIBRARY} + ${Boost_JSON_LIBRARY} + ${Boost_LOCALE_LIBRARY} + ${Boost_PROGRAM_OPTIONS_LIBRARY} + ${Boost_SYSTEM_LIBRARY} + ${Boost_THREAD_LIBRARY} + ${pthread_LIBRARIES} + ${rt_LIBRARIES} + ${icu_i18n_STATIC_LIBRARIES} + ${dl_LIBRARIES} + ${secp256k1_STATIC_LIBRARIES} ) endif() -# ${CANONICAL_LIB_NAME} project specific libraries/linker flags. -#------------------------------------------------------------------------------ -target_link_libraries( ${CANONICAL_LIB_NAME} - ${Boost_CHRONO_LIBRARY} - ${Boost_IOSTREAMS_LIBRARY} - ${Boost_JSON_LIBRARY} - ${Boost_LOCALE_LIBRARY} - ${Boost_PROGRAM_OPTIONS_LIBRARY} - ${Boost_SYSTEM_LIBRARY} - ${Boost_THREAD_LIBRARY} - ${pthread_LIBRARIES} - ${rt_LIBRARIES} - ${icu_i18n_FOR_BUILD_LIBRARIES} - ${dl_LIBRARIES} - ${secp256k1_FOR_BUILD_LIBRARIES} ) - # Define libbitcoin-system-examples project. #------------------------------------------------------------------------------ if (with-examples) diff --git a/configure.ac b/configure.ac index d0ee1cf59d..6b40067ebe 100644 --- a/configure.ac +++ b/configure.ac @@ -249,24 +249,12 @@ AS_CASE([${CC}], [*], [AX_CHECK_COMPILE_FLAG([-Wno-deprecated-copy], [CXXFLAGS="$CXXFLAGS -Wno-deprecated-copy"])]) -# Suppress warning for ignored attributes (arising on template arguments). -#------------------------------------------------------------------------------ -AS_CASE([${CC}], [*], - [AX_CHECK_COMPILE_FLAG([-Wno-ignored-attributes], - [CXXFLAGS="$CXXFLAGS -Wno-ignored-attributes"])]) - # Conflict in stdlib under clang. Enabled in clang only. #------------------------------------------------------------------------------ AS_CASE([${CC}], [*clang*], [AX_CHECK_COMPILE_FLAG([-Wno-mismatched-tags], [CXXFLAGS="$CXXFLAGS -Wno-mismatched-tags"])]) -# Address -undefined dynamic_lookup MacOS error. -#------------------------------------------------------------------------------ -AS_CASE([${CC}], [*], - [AX_CHECK_LINK_FLAG([-no_fixup_chains], - [LDFLAGS="$LDFLAGS -no_fixup_chains"])]) - # Protect stack. #------------------------------------------------------------------------------ AS_CASE([${CC}], [*],