Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ jobs:
config:
- name: Linux
os: ubuntu-18.04
packages: python3-zmq qttools5-dev qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
packages: python3-zmq qttools5-dev qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev libgmp-dev cargo
cc: gcc
cxx: g++

- name: macOS
os: macos-10.15
packages: python3 autoconf automake berkeley-db4 libtool boost miniupnpc libnatpmp pkg-config qt5 zmq libevent qrencode gmp libsodium rust
packages: python3 autoconf automake berkeley-db4 libtool boost miniupnpc libnatpmp pkg-config qt5 zmq libevent qrencode gmp rust
cc: $(brew --prefix llvm)/bin/clang
cxx: $(brew --prefix llvm)/bin/clang++

Expand All @@ -93,11 +93,17 @@ jobs:
sudo apt-add-repository "ppa:ondrej/php" -y
sudo apt-get --yes update
sudo apt-get install --no-install-recommends --no-upgrade -qq "$APT_BASE" ${{ matrix.config.packages }}
sudo dpkg --remove --force-depends libsodium-dev
fi
if [[ ${{ matrix.config.os }} = macos* ]]; then
brew install "$APT_BASE" ${{ matrix.config.packages }}
brew uninstall --ignore-dependencies libsodium
fi

echo "Installing libsodium.."
sudo ./contrib/install_sodium.sh `pwd`
echo "libsodium install finished.."

- name: Prepare ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
Expand All @@ -118,8 +124,8 @@ jobs:
CC=${{ matrix.config.cc }}
CXX=${{ matrix.config.cxx }}
if [[ ${{ matrix.config.os }} = macos* ]]; then
export CPPFLAGS="-I/usr/local/Cellar/gmp/6.2.1/include"
export LDFLAGS="-L/usr/local/Cellar/gmp/6.2.1/lib"
export CPPFLAGS="-I/usr/local/Cellar/gmp/6.2.1/include -I/usr/local/include"
export LDFLAGS="-L/usr/local/Cellar/gmp/6.2.1/lib -L/usr/local/lib"
fi
export CC
export CXX
Expand Down Expand Up @@ -303,7 +309,16 @@ jobs:
- name: x86_64 Linux [GOAL:install] [bionic] [no depends only system libs]
os: ubuntu-18.04
host: x86_64-unknown-linux-gnu
apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libgmp-dev libsodium-dev cargo
apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libgmp-dev cargo
unit_tests: true
no_depends: 1
goal: install
BITCOIN_CONFIG: "--enable-zmq --with-incompatible-bdb --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER"

- name: x86_64 Linux [GOAL:install] [focal] [no depends only system libs]
os: ubuntu-20.04
host: x86_64-unknown-linux-gnu
apt_get: python3-zmq qtbase5-dev qttools5-dev-tools libqt5svg5-dev libqt5charts5-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libsodium1.0.17-dev libzmq3-dev libqrencode-dev libgmp-dev cargo
unit_tests: true
no_depends: 1
goal: install
Expand All @@ -323,7 +338,7 @@ jobs:
- name: macOS 10.15 [GOAL:deploy] [native macOS using syslibs no unit or functional tests]
os: macos-10.15
host: x86_64-apple-darwin19.6.0
brew_install: autoconf automake ccache berkeley-db4 libtool boost miniupnpc pkg-config python3 qt5 zmq libevent qrencode gmp libsodium rust librsvg
brew_install: autoconf automake ccache berkeley-db4 libtool boost miniupnpc pkg-config python3 qt5 zmq libevent qrencode gmp rust librsvg
unit_tests: false
functional_tests: false
no_depends: 1
Expand All @@ -340,6 +355,7 @@ jobs:
run: |
if [[ ${{ matrix.config.os }} = ubuntu* ]]; then
sudo apt-add-repository "ppa:ondrej/php" -y
sudo apt-add-repository "ppa:fuzzbawls/libsodium1.0.17" -y
sudo apt-get --yes update
sudo apt-get install --no-install-recommends --no-upgrade -qq "$APT_BASE" ${{ matrix.config.apt_get }}
fi
Expand All @@ -348,6 +364,21 @@ jobs:
pip3 install ds_store mac_alias
fi

if [ "${{ matrix.config.no_depends }}" = 1 ]; then
if [ "${{ matrix.config.os }}" != "ubuntu-20.04" ] && "${{ matrix.config.os }}" != "macos-10.15" ]; then
sudo dpkg --remove --force-depends libsodium-dev
fi

if [[ ${{ matrix.config.os }} = macos* ]]; then
brew install "$APT_BASE" ${{ matrix.config.packages }}
brew uninstall --ignore-dependencies libsodium
fi

echo "Installing libsodium.."
sudo ./contrib/install_sodium.sh `pwd`
echo "libsodium install finished.."
fi

- name: depends cache files
if: matrix.config.no_depends != 1
uses: actions/cache@v2
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ set(UTIL_SOURCES
./src/compat/strnlen.cpp
./src/compat/glibc_sanity.cpp
./src/compat/glibcxx_sanity.cpp
./src/sapling/sodium_sanity.cpp
./src/chainparamsbase.cpp
./src/clientversion.cpp
./src/fs.cpp
Expand Down
29 changes: 27 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ if test x$use_pkgconfig = xyes; then
if test x$TARGET_OS != xwindows; then
PKG_CHECK_MODULES([EVENT_PTHREADS], [libevent_pthreads],, [AC_MSG_ERROR(libevent_pthreads not found.)])
fi
PKG_CHECK_MODULES([SODIUM], [libsodium],, [AC_MSG_ERROR(libsodium not found.)])
PKG_CHECK_MODULES([SODIUM], [libsodium], [have_sodium=yes], [AC_MSG_ERROR(libsodium not found.)])
fi

if test "x$use_zmq" = "xyes"; then
Expand All @@ -1188,7 +1188,7 @@ else
if test x$TARGET_OS != xwindows; then
AC_CHECK_LIB([event_pthreads],[main],EVENT_PTHREADS_LIBS=-levent_pthreads,AC_MSG_ERROR(libevent_pthreads missing))
fi
AC_CHECK_HEADER([sodium/core.h],, AC_MSG_ERROR(libsodium headers missing),)
AC_CHECK_HEADER([sodium/core.h], [have_sodium=yes], AC_MSG_ERROR(libsodium headers missing),)
AC_CHECK_LIB([sodium],[main],SODIUM_LIBS=-lsodium,AC_MSG_ERROR(libsodium missing))
fi

Expand Down Expand Up @@ -1223,6 +1223,31 @@ else
fi
fi

dnl check for supported sodium library version
if test x$have_sodium != xno; then
AC_MSG_CHECKING([whether libsodium library version is supported])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
#include <sodium.h>
]], [[
#if SODIUM_LIBRARY_VERSION_MAJOR <= 10
// Everything is okay
#elif SODIUM_LIBRARY_VERSION_MAJOR == 10
#if SODIUM_LIBRARY_VERSION_MINOR == 0
// Everything is okay
#else
# error libsodium library minor version is unsupported
#endif
#else
# error libsodium library major version is unsupported
#endif
]])],[
AC_MSG_RESULT(yes)
],[
AC_MSG_RESULT(no)
AC_MSG_ERROR([libsodium library version > 10.1 is unsupported.])
])
fi

dnl gmp check
GMP_CHECK
if test x"$has_gmp" != x"yes"; then
Expand Down
157 changes: 16 additions & 141 deletions contrib/cmake/FindSodium.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,123 +86,6 @@ if (UNIX)
find_library(sodium_LIBRARY_RELEASE NAMES ${${XPREFIX}_LIBRARIES}
HINTS ${${XPREFIX}_LIBRARY_DIRS}
)


########################################################################
# Windows
elseif (WIN32)
set(sodium_DIR "$ENV{sodium_DIR}" CACHE FILEPATH "sodium install directory")
mark_as_advanced(sodium_DIR)

find_path(sodium_INCLUDE_DIR sodium.h
HINTS ${sodium_DIR}
PATH_SUFFIXES include
)

if (MSVC)
# detect target architecture
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" [=[
#if defined _M_IX86
#error ARCH_VALUE x86_32
#elif defined _M_X64
#error ARCH_VALUE x86_64
#endif
#error ARCH_VALUE unknown
]=])
try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp"
OUTPUT_VARIABLE _COMPILATION_LOG
)
string(REGEX REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*" "\\1" _TARGET_ARCH "${_COMPILATION_LOG}")

# construct library path
if (_TARGET_ARCH STREQUAL "x86_32")
string(APPEND _PLATFORM_PATH "Win32")
elseif(_TARGET_ARCH STREQUAL "x86_64")
string(APPEND _PLATFORM_PATH "x64")
else()
message(FATAL_ERROR "the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake.")
endif()
string(APPEND _PLATFORM_PATH "/$$CONFIG$$")

if (MSVC_VERSION LESS 1900)
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
else()
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
endif()
string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")

if (sodium_USE_STATIC_LIBS)
string(APPEND _PLATFORM_PATH "/static")
else()
string(APPEND _PLATFORM_PATH "/dynamic")
endif()

string(REPLACE "$$CONFIG$$" "Debug" _DEBUG_PATH_SUFFIX "${_PLATFORM_PATH}")
string(REPLACE "$$CONFIG$$" "Release" _RELEASE_PATH_SUFFIX "${_PLATFORM_PATH}")

find_library(sodium_LIBRARY_DEBUG libsodium.lib
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
)
find_library(sodium_LIBRARY_RELEASE libsodium.lib
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
)
if (NOT sodium_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
find_library(sodium_DLL_DEBUG libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
)
find_library(sodium_DLL_RELEASE libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK})
endif()

elseif(_GCC_COMPATIBLE)
if (sodium_USE_STATIC_LIBS)
find_library(sodium_LIBRARY_DEBUG libsodium.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib
)
find_library(sodium_LIBRARY_RELEASE libsodium.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib
)
else()
find_library(sodium_LIBRARY_DEBUG libsodium.dll.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib
)
find_library(sodium_LIBRARY_RELEASE libsodium.dll.a
HINTS ${sodium_DIR}
PATH_SUFFIXES lib
)

file(GLOB _DLL
LIST_DIRECTORIES false
RELATIVE "${sodium_DIR}/bin"
"${sodium_DIR}/bin/libsodium*.dll"
)
find_library(sodium_DLL_DEBUG ${_DLL} libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES bin
)
find_library(sodium_DLL_RELEASE ${_DLL} libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES bin
)
endif()
else()
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
endif()


########################################################################
# unsupported
else()
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
endif()
Expand All @@ -213,12 +96,25 @@ endif()

# extract sodium version
if (sodium_INCLUDE_DIR)
set(_VERSION_HEADER "${_INCLUDE_DIR}/sodium/version.h")
if (EXISTS _VERSION_HEADER)
set(_VERSION_HEADER "${sodium_INCLUDE_DIR}/sodium/version.h")
if (EXISTS "${_VERSION_HEADER}")
file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT)
string(REGEX REPLACE ".*#[ \t]*define[ \t]*SODIUM_VERSION_STRING[ \t]*\"([^\n]*)\".*" "\\1"
sodium_VERSION "${_VERSION_HEADER_CONTENT}")
set(sodium_VERSION "${sodium_VERSION}" PARENT_SCOPE)
set(sodium_VERSION "${sodium_VERSION}")
message(STATUS "Found libsodium version ${sodium_VERSION}")

# extract the sodium library version
string(REGEX REPLACE ".*#[ \t]*define[ \t]*SODIUM_LIBRARY_VERSION_MAJOR[ \t]*([^\n]*).*" "\\1"
sodium_LIBRARY_VERSION_MAJOR "${_VERSION_HEADER_CONTENT}")
string(REGEX REPLACE ".*#[ \t]*define[ \t]*SODIUM_LIBRARY_VERSION_MINOR[ \t]*([^\n]*).*" "\\1"
sodium_LIBRARY_VERSION_MINOR "${_VERSION_HEADER_CONTENT}")
set(sodium_LIBRARY_VERSION "${sodium_LIBRARY_VERSION_MAJOR}.${sodium_LIBRARY_VERSION_MINOR}")
message(STATUS "libsodium library version found: ${sodium_LIBRARY_VERSION}")
if (${sodium_LIBRARY_VERSION} VERSION_GREATER "10.0")
message(FATAL_ERROR "Unsupported libsodium library version ${sodium_LIBRARY_VERSION}!")
endif()

endif()
endif()

Expand All @@ -243,10 +139,6 @@ endif()
mark_as_advanced(sodium_INCLUDE_DIR)
mark_as_advanced(sodium_LIBRARY_DEBUG)
mark_as_advanced(sodium_LIBRARY_RELEASE)
if (WIN32)
mark_as_advanced(sodium_DLL_DEBUG)
mark_as_advanced(sodium_DLL_RELEASE)
endif()

# create imported target
if(sodium_USE_STATIC_LIBS)
Expand All @@ -273,22 +165,5 @@ else()
IMPORTED_LOCATION "${sodium_LIBRARY_RELEASE}"
IMPORTED_LOCATION_DEBUG "${sodium_LIBRARY_DEBUG}"
)
elseif (WIN32)
set_target_properties(sodium PROPERTIES
IMPORTED_IMPLIB "${sodium_LIBRARY_RELEASE}"
IMPORTED_IMPLIB_DEBUG "${sodium_LIBRARY_DEBUG}"
)
if (NOT (sodium_DLL_DEBUG MATCHES ".*-NOTFOUND"))
set_target_properties(sodium PROPERTIES
IMPORTED_LOCATION_DEBUG "${sodium_DLL_DEBUG}"
)
endif()
if (NOT (sodium_DLL_RELEASE MATCHES ".*-NOTFOUND"))
set_target_properties(sodium PROPERTIES
IMPORTED_LOCATION_RELWITHDEBINFO "${sodium_DLL_RELEASE}"
IMPORTED_LOCATION_MINSIZEREL "${sodium_DLL_RELEASE}"
IMPORTED_LOCATION_RELEASE "${sodium_DLL_RELEASE}"
)
endif()
endif()
endif()
Loading