From cfd0072859cf1bdff8ff265ea75c3bbc4fd99ff9 Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Tue, 31 Aug 2021 07:54:23 +0100 Subject: [PATCH 01/27] Use C++17 --- ci/test/00_setup_env_mac.sh | 4 ++-- configure.ac | 6 ++++-- depends/README.md | 2 +- depends/hosts/darwin.mk | 4 ++-- depends/packages/bdb.mk | 2 +- depends/packages/boost.mk | 2 +- depends/packages/zeromq.mk | 2 +- doc/dependencies.md | 4 ++-- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ci/test/00_setup_env_mac.sh b/ci/test/00_setup_env_mac.sh index 1da55be1dd..0dc6ec594e 100644 --- a/ci/test/00_setup_env_mac.sh +++ b/ci/test/00_setup_env_mac.sh @@ -6,9 +6,9 @@ export LC_ALL=C.UTF-8 -export HOST=x86_64-apple-darwin14 +export HOST=x86_64-apple-darwin18 export PACKAGES="cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python3-dev python3-setuptools" -export OSX_SDK=10.11 +export OSX_SDK=10.14 export RUN_UNIT_TESTS=false export RUN_FUNCTIONAL_TESTS=false export GOAL="deploy" diff --git a/configure.ac b/configure.ac index fd6027de8a..855d6d680c 100644 --- a/configure.ac +++ b/configure.ac @@ -61,8 +61,10 @@ case $host in lt_cv_deplibs_check_method="pass_all" ;; esac -dnl Require C++11 compiler (no GNU extensions) -AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory], [nodefault]) + +dnl Require C++17 compiler (no GNU extensions) +AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory]) + dnl Check if -latomic is required for CHECK_ATOMIC diff --git a/depends/README.md b/depends/README.md index 69bc2a0222..e18ba57967 100644 --- a/depends/README.md +++ b/depends/README.md @@ -25,7 +25,7 @@ Common `host-platform-triplets` for cross compilation are: - `i686-pc-linux-gnu` for Linux 32 bit - `x86_64-pc-linux-gnu` for x86 Linux - `x86_64-w64-mingw32` for Win64 -- `x86_64-apple-darwin14` for macOS +- `x86_64-apple-darwin18` for macOS - `arm-linux-gnueabihf` for Linux ARM 32 bit - `aarch64-linux-gnu` for Linux ARM 64 bit - `riscv32-linux-gnu` for Linux RISC-V 32 bit diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index a1c943d60b..4ea119af28 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -1,5 +1,5 @@ -OSX_MIN_VERSION=10.10 -OSX_SDK_VERSION=10.11 +OSX_MIN_VERSION=10.14 +OSX_SDK_VERSION=10.14 OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk LD64_VERSION=253.9 darwin_CC=clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk index 6cdb79592b..f983c754ab 100644 --- a/depends/packages/bdb.mk +++ b/depends/packages/bdb.mk @@ -9,7 +9,7 @@ define $(package)_set_vars $(package)_config_opts=--disable-shared --enable-cxx --disable-replication $(package)_config_opts_mingw32=--enable-mingw $(package)_config_opts_linux=--with-pic -$(package)_cxxflags=-std=c++11 +$(package)_cxxflags=-std=c++17 $(package)_cppflags_mingw32=-DUNICODE -D_UNICODE endef diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index c84c5d0ab1..ad25069f51 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -20,7 +20,7 @@ $(package)_archiver_$(host_os)=$($(package)_ar) $(package)_toolset_darwin=darwin $(package)_archiver_darwin=$($(package)_libtool) $(package)_config_libraries=chrono,filesystem,system,thread,test -$(package)_cxxflags=-std=c++11 -fvisibility=hidden +$(package)_cxxflags=-std=c++17 -fvisibility=hidden $(package)_cxxflags_linux=-fPIC endef diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index 9ac037ebb5..f9b26a1bf3 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -10,7 +10,7 @@ define $(package)_set_vars $(package)_config_opts += --without-libsodium --without-libgssapi_krb5 --without-pgm --without-norm --without-vmci $(package)_config_opts += --disable-libunwind --disable-radix-tree --without-gcov $(package)_config_opts_linux=--with-pic - $(package)_cxxflags=-std=c++11 + $(package)_cxxflags=-std=c++17 endef define $(package)_preprocess_cmds diff --git a/doc/dependencies.md b/doc/dependencies.md index 70bc5e6ed3..e0f13c9a59 100644 --- a/doc/dependencies.md +++ b/doc/dependencies.md @@ -7,11 +7,11 @@ These are the dependencies currently used by Bitcoin Core. You can find instruct | --- | --- | --- | --- | --- | --- | | Berkeley DB | [4.8.30](https://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index.html) | 4.8.x | No | | | | Boost | [1.70.0](https://www.boost.org/users/download/) | [1.47.0](https://github.com/bitcoin/bitcoin/pull/8920) | No | | | -| Clang | | [3.3+](https://releases.llvm.org/download.html) (C++11 support) | | | | +| Clang | | [5.0+](https://releases.llvm.org/download.html) (C++17 support) | | | | | Expat | [2.2.7](https://libexpat.github.io/) | | No | Yes | | | fontconfig | [2.12.1](https://www.freedesktop.org/software/fontconfig/release/) | | No | Yes | | | FreeType | [2.7.1](https://download.savannah.gnu.org/releases/freetype) | | No | | | -| GCC | | [4.8+](https://gcc.gnu.org/) (C++11 support) | | | | +| GCC | | [7+](https://gcc.gnu.org/) (C++17 support) | | | | | HarfBuzz-NG | | | | | | | libevent | [2.1.8-stable](https://github.com/libevent/libevent/releases) | 2.0.22 | No | | | | libpng | | | | | [Yes](https://github.com/bitcoin/bitcoin/blob/master/depends/packages/qt.mk) | From 33921c9873fc0795b8fbb61f2b8b04157c43c692 Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Tue, 31 Aug 2021 08:18:47 +0100 Subject: [PATCH 02/27] Update build and make span for C++17 --- build-aux/m4/ax_cxx_compile_stdcxx.m4 | 351 +++++++++++++++++++++++--- src/span.h | 19 ++ 2 files changed, 336 insertions(+), 34 deletions(-) diff --git a/build-aux/m4/ax_cxx_compile_stdcxx.m4 b/build-aux/m4/ax_cxx_compile_stdcxx.m4 index f147cee3b1..f0a3badf59 100644 --- a/build-aux/m4/ax_cxx_compile_stdcxx.m4 +++ b/build-aux/m4/ax_cxx_compile_stdcxx.m4 @@ -45,9 +45,9 @@ dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl - m4_if([$1], [11], [], - [$1], [14], [], - [$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])], + m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], + [$1], [14], [ax_cxx_compile_alternatives="14 1y"], + [$1], [17], [ax_cxx_compile_alternatives="17 1z"], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], @@ -57,26 +57,13 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], [$3], [optional], [ax_cxx_compile_cxx$1_required=false], [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) - m4_if([$4], [], [ax_cxx_compile_cxx$1_try_default=true], - [$4], [default], [ax_cxx_compile_cxx$1_try_default=true], - [$4], [nodefault], [ax_cxx_compile_cxx$1_try_default=false], - [m4_fatal([invalid fourth argument `$4' to AX_CXX_COMPILE_STDCXX])]) AC_LANG_PUSH([C++])dnl ac_success=no - m4_if([$4], [nodefault], [], [dnl - AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, - ax_cv_cxx_compile_cxx$1, - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [ax_cv_cxx_compile_cxx$1=yes], - [ax_cv_cxx_compile_cxx$1=no])]) - if test x$ax_cv_cxx_compile_cxx$1 = xyes; then - ac_success=yes - fi]) - m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then - for switch in -std=gnu++$1 -std=gnu++0x; do + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, @@ -102,22 +89,27 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl dnl HP's aCC needs +std=c++11 according to: dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf dnl Cray's crayCC needs "-h std=c++11" - for switch in -std=c++$1 -std=c++0x +std=c++$1 "-h std=c++$1"; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, - $cachevar, - [ac_save_CXX="$CXX" - CXX="$CXX $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXX="$ac_save_CXX"]) - if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break fi - ac_success=yes + done + if test x$ac_success = xyes; then break fi done @@ -154,6 +146,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 +) dnl Tests for new features in C++11 @@ -191,11 +188,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -524,7 +523,7 @@ namespace cxx14 } - namespace test_digit_seperators + namespace test_digit_separators { constexpr auto ten_million = 100'000'000; @@ -566,3 +565,287 @@ namespace cxx14 #endif // __cplusplus >= 201402L ]]) + + +dnl Tests for new features in C++17 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. +#ifndef __cplusplus +#error "This is not a C++ compiler" +#elif __cplusplus < 201703L +#error "This is not a C++17 compiler" +#else +#include +#include +#include +namespace cxx17 +{ + namespace test_constexpr_lambdas + { + constexpr int foo = [](){return 42;}(); + } + namespace test::nested_namespace::definitions + { + } + namespace test_fold_expression + { + template + int multiply(Args... args) + { + return (args * ... * 1); + } + template + bool all(Args... args) + { + return (args && ...); + } + } + namespace test_extended_static_assert + { + static_assert (true); + } + namespace test_auto_brace_init_list + { + auto foo = {5}; + auto bar {5}; + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + namespace test_typename_in_template_template_parameter + { + template typename X> struct D; + } + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + int f1() + { + return 42; + } + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + } + namespace test_extended_aggregate_initialization + { + struct base1 + { + int b1, b2 = 42; + }; + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + struct derived : base1, base2 + { + int d; + }; + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + } + namespace test_general_range_based_for_loop + { + struct iter + { + int i; + int& operator* () + { + return i; + } + const int& operator* () const + { + return i; + } + iter& operator++() + { + ++i; + return *this; + } + }; + struct sentinel + { + int i; + }; + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + struct range + { + iter begin() const + { + return {0}; + } + sentinel end() const + { + return {5}; + } + }; + void f() + { + range r {}; + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + } + namespace test_lambda_capture_asterisk_this_by_value + { + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + } + namespace test_enum_class_construction + { + enum class byte : unsigned char + {}; + byte foo {42}; + } + namespace test_constexpr_if + { + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + } + namespace test_selection_statement_with_initializer + { + int f() + { + return 13; + } + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + switch (auto i = f(); i + 4) + { + case 17: + return 2; + default: + return 1; + } + } + } + namespace test_template_argument_deduction_for_class_templates + { + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + T1 m1; + T2 m2; + }; + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + } + namespace test_non_type_auto_template_parameters + { + template + struct B + {}; + B<5> b1; + B<'a'> b2; + } + namespace test_structured_bindings + { + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + auto f1() -> int(&)[2] + { + return arr; + } + auto f2() -> std::pair& + { + return pr; + } + struct S + { + int x1 : 2; + volatile double y1; + }; + S f3() + { + return {}; + } + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + } + namespace test_exception_spec_type_system + { + struct Good {}; + struct Bad {}; + void g1() noexcept; + void g2(); + template + Bad + f(T*, T*); + template + Good + f(T1*, T2*); + static_assert (std::is_same_v); + } + namespace test_inline_variables + { + template void f(T) + {} + template inline T g(T) + { + return T{}; + } + template<> inline void f<>(int) + {} + template<> int g<>(int) + { + return 5; + } + } +} // namespace cxx17 +#endif // __cplusplus < 201703L +]]) + diff --git a/src/span.h b/src/span.h index 594dd0c241..d1ba93fb11 100644 --- a/src/span.h +++ b/src/span.h @@ -24,6 +24,23 @@ class Span constexpr Span(C* data, std::ptrdiff_t size) noexcept : m_data(data), m_size(size) {} constexpr Span(C* data, C* end) noexcept : m_data(data), m_size(end - data) {} + /** Implicit conversion of spans between compatible types. + * + * Specifically, if a pointer to an array of type O can be implicitly converted to a pointer to an array of type + * C, then permit implicit conversion of Span to Span. This matches the behavior of the corresponding + * C++20 std::span constructor. + * + * For example this means that a Span can be converted into a Span. + */ + template ::value, int>::type = 0> + constexpr Span(const Span& other) noexcept : m_data(other.m_data), m_size(other.m_size) {} + + /** Default copy constructor. */ + constexpr Span(const Span&) noexcept = default; + + /** Default assignment operator. */ + Span& operator=(const Span& other) noexcept = default; + constexpr C* data() const noexcept { return m_data; } constexpr C* begin() const noexcept { return m_data; } constexpr C* end() const noexcept { return m_data + m_size; } @@ -41,6 +58,8 @@ class Span friend constexpr bool operator<=(const Span& a, const Span& b) noexcept { return !(b < a); } friend constexpr bool operator>(const Span& a, const Span& b) noexcept { return (b < a); } friend constexpr bool operator>=(const Span& a, const Span& b) noexcept { return !(a < b); } + + template friend class Span; }; /** Create a span to a container exposing data() and size(). From 12a52b581ba5e3889df63d9949c5ea7f25f37b33 Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Tue, 31 Aug 2021 08:42:27 +0100 Subject: [PATCH 03/27] Update SDK in make.sh --- make.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/make.sh b/make.sh index f98d89118e..77cf1df16d 100755 --- a/make.sh +++ b/make.sh @@ -22,7 +22,7 @@ setup_vars() { # shellcheck disable=SC2206 # This intentionally word-splits the array as env arg can only be strings. - # Other options available: x86_64-w64-mingw32 x86_64-apple-darwin11 + # Other options available: x86_64-w64-mingw32 x86_64-apple-darwin18 TARGETS=(${TARGETS:-"x86_64-pc-linux-gnu"}) } @@ -167,7 +167,7 @@ docker_build() { echo "> docker-build"; for target in "${targets[@]}"; do - if [[ "$target" == "x86_64-apple-darwin11" ]]; then + if [[ "$target" == "x86_64-apple-darwin18" ]]; then pkg_ensure_mac_sdk fi local img="${img_prefix}-${target}:${img_version}" @@ -340,7 +340,7 @@ pkg_install_deps() { } pkg_ensure_mac_sdk() { - local sdk_name="MacOSX10.11.sdk" + local sdk_name="MacOSX10.14.sdk" local pkg="${sdk_name}.tar.xz" echo "> ensuring mac sdk" @@ -349,7 +349,7 @@ pkg_ensure_mac_sdk() { pushd ./depends/SDKs >/dev/null if [[ ! -d "$sdk_name" ]]; then if [[ ! -f "${pkg}" ]]; then - wget https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.11.sdk.tar.xz + wget https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.14.sdk.tar.xz fi tar -xvf "${pkg}" fi From 906cc125b7647ea7ed4a7b2cd44eb632baa67007 Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Tue, 31 Aug 2021 08:53:31 +0100 Subject: [PATCH 04/27] dockerfile to darwin18 --- ...ple-darwin11.dockerfile => x86_64-apple-darwin18.dockerfile} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename contrib/dockerfiles/{x86_64-apple-darwin11.dockerfile => x86_64-apple-darwin18.dockerfile} (98%) diff --git a/contrib/dockerfiles/x86_64-apple-darwin11.dockerfile b/contrib/dockerfiles/x86_64-apple-darwin18.dockerfile similarity index 98% rename from contrib/dockerfiles/x86_64-apple-darwin11.dockerfile rename to contrib/dockerfiles/x86_64-apple-darwin18.dockerfile index c42737cae4..10c17fab2a 100644 --- a/contrib/dockerfiles/x86_64-apple-darwin11.dockerfile +++ b/contrib/dockerfiles/x86_64-apple-darwin18.dockerfile @@ -1,4 +1,4 @@ -ARG TARGET=x86_64-apple-darwin11 +ARG TARGET=x86_64-apple-darwin18 # ----------- FROM ubuntu:18.04 as builder-base From e6a2c3d09a2ae922688c744e1552692bb7dcff63 Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Tue, 31 Aug 2021 08:57:27 +0100 Subject: [PATCH 05/27] macOS build targets --- .github/workflows/dev-builds.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dev-builds.yaml b/.github/workflows/dev-builds.yaml index 1e354b982f..dc1ec6600b 100644 --- a/.github/workflows/dev-builds.yaml +++ b/.github/workflows/dev-builds.yaml @@ -94,10 +94,10 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f - name: Build and package - run: TARGETS="x86_64-apple-darwin11" ./make.sh docker-release-git + run: TARGETS="x86_64-apple-darwin18" ./make.sh docker-release-git - - name: Publish artifact - x86_64-apple-darwin11 + - name: Publish artifact - x86_64-apple-darwin18 uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 with: - name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin11 - path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin11.tar.gz + name: defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin18 + path: ./build/defichain-${{ env.BUILD_VERSION }}-x86_64-apple-darwin18.tar.gz From 8362aa6ef04fd9f216f31839daac493ddb587783 Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Tue, 31 Aug 2021 10:12:19 +0100 Subject: [PATCH 06/27] XCode build --- ci/test/00_setup_env_mac.sh | 3 +- ci/test/05_before_script.sh | 11 ++++--- depends/hosts/darwin.mk | 9 ++++-- depends/packages/native_cctools.mk | 52 ++++++++++++++++++------------ make.sh | 8 ++--- 5 files changed, 51 insertions(+), 32 deletions(-) diff --git a/ci/test/00_setup_env_mac.sh b/ci/test/00_setup_env_mac.sh index 0dc6ec594e..e6bfbd6169 100644 --- a/ci/test/00_setup_env_mac.sh +++ b/ci/test/00_setup_env_mac.sh @@ -8,7 +8,8 @@ export LC_ALL=C.UTF-8 export HOST=x86_64-apple-darwin18 export PACKAGES="cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python3-dev python3-setuptools" -export OSX_SDK=10.14 +export XCODE_VERSION=11.3.1 +export XCODE_BUILD_ID=11C505 export RUN_UNIT_TESTS=false export RUN_FUNCTIONAL_TESTS=false export GOAL="deploy" diff --git a/ci/test/05_before_script.sh b/ci/test/05_before_script.sh index 202b7ef3b7..7b97902919 100755 --- a/ci/test/05_before_script.sh +++ b/ci/test/05_before_script.sh @@ -10,11 +10,14 @@ DOCKER_EXEC echo \> \$HOME/.defi # Make sure default datadir does not exist and mkdir -p depends/SDKs depends/sdk-sources -if [ -n "$OSX_SDK" ] && [ ! -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then - curl --location --fail $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -o depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz +OSX_SDK_BASENAME="Xcode-${XCODE_VERSION}-${XCODE_BUILD_ID}-extracted-SDK-with-libcxx-headers.tar.gz" +OSX_SDK_PATH="${DEPENDS_DIR}/sdk-sources/${OSX_SDK_BASENAME}" + +if [ -n "$XCODE_VERSION" ] && [ ! -f "$OSX_SDK_PATH" ]; then + curl --location --fail "${SDK_URL}/${OSX_SDK_BASENAME}" -o "$OSX_SDK_PATH" fi -if [ -n "$OSX_SDK" ] && [ -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then - tar -C depends/SDKs -xf depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz +if [ -n "$XCODE_VERSION" ] && [ -f "$OSX_SDK_PATH" ]; then + DOCKER_EXEC tar -C "${DEPENDS_DIR}/SDKs" -xf "$OSX_SDK_PATH" fi if [[ $HOST = *-mingw32 ]]; then DOCKER_EXEC update-alternatives --set $HOST-g++ \$\(which $HOST-g++-posix\) diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index 4ea119af28..b14ce09cb8 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -1,7 +1,10 @@ OSX_MIN_VERSION=10.14 -OSX_SDK_VERSION=10.14 -OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk -LD64_VERSION=253.9 +OSX_SDK_VERSION=10.15.1 +XCODE_VERSION=11.3.1 +XCODE_BUILD_ID=11C505 +OSX_SDK=$(SDK_PATH)/Xcode-$(XCODE_VERSION)-$(XCODE_BUILD_ID)-extracted-SDK-with-libcxx-headers +LD64_VERSION=530 + darwin_CC=clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) darwin_CXX=clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -stdlib=libc++ diff --git a/depends/packages/native_cctools.mk b/depends/packages/native_cctools.mk index a065256c1c..74c32c4e38 100644 --- a/depends/packages/native_cctools.mk +++ b/depends/packages/native_cctools.mk @@ -1,45 +1,55 @@ package=native_cctools -$(package)_version=807d6fd1be5d2224872e381870c0a75387fe05e6 -$(package)_download_path=https://github.com/theuni/cctools-port/archive +$(package)_version=4da2f3b485bcf4cef526f30c0b8c0bcda99cdbb4 +$(package)_download_path=https://github.com/tpoechtrager/cctools-port/archive $(package)_file_name=$($(package)_version).tar.gz -$(package)_sha256_hash=a09c9ba4684670a0375e42d9d67e7f12c1f62581a27f28f7c825d6d7032ccc6a +$(package)_sha256_hash=a2d491c0981cef72fee2b833598f20f42a6c44a7614a61c439bda93d56446fec $(package)_build_subdir=cctools -$(package)_clang_version=3.7.1 -$(package)_clang_download_path=https://llvm.org/releases/$($(package)_clang_version) +$(package)_clang_version=8.0.0 +$(package)_clang_download_path=https://releases.llvm.org/$($(package)_clang_version) $(package)_clang_download_file=clang+llvm-$($(package)_clang_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz $(package)_clang_file_name=clang-llvm-$($(package)_clang_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz -$(package)_clang_sha256_hash=99b28a6b48e793705228a390471991386daa33a9717cd9ca007fcdde69608fd9 +$(package)_clang_sha256_hash=9ef854b71949f825362a119bf2597f744836cb571131ae6b721cd102ffea8cd0 + +$(package)_libtapi_version=3efb201881e7a76a21e0554906cf306432539cef +$(package)_libtapi_download_path=https://github.com/tpoechtrager/apple-libtapi/archive +$(package)_libtapi_download_file=$($(package)_libtapi_version).tar.gz +$(package)_libtapi_file_name=$($(package)_libtapi_version).tar.gz +$(package)_libtapi_sha256_hash=380c1ca37cfa04a8699d0887a8d3ee1ad27f3d08baba78887c73b09485c0fbd3 + $(package)_extra_sources=$($(package)_clang_file_name) +$(package)_extra_sources += $($(package)_libtapi_file_name) define $(package)_fetch_cmds $(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ -$(call fetch_file,$(package),$($(package)_clang_download_path),$($(package)_clang_download_file),$($(package)_clang_file_name),$($(package)_clang_sha256_hash)) +$(call fetch_file,$(package),$($(package)_clang_download_path),$($(package)_clang_download_file),$($(package)_clang_file_name),$($(package)_clang_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_libtapi_download_path),$($(package)_libtapi_download_file),$($(package)_libtapi_file_name),$($(package)_libtapi_sha256_hash)) endef define $(package)_extract_cmds mkdir -p $($(package)_extract_dir) && \ echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ echo "$($(package)_clang_sha256_hash) $($(package)_source_dir)/$($(package)_clang_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_libtapi_sha256_hash) $($(package)_source_dir)/$($(package)_libtapi_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ - mkdir -p toolchain/bin toolchain/lib/clang/3.5/include && \ + mkdir -p toolchain/bin toolchain/lib/clang/$($(package)_clang_version)/include && \ + mkdir -p libtapi && \ + tar --no-same-owner --strip-components=1 -C libtapi -xf $($(package)_source_dir)/$($(package)_libtapi_file_name) && \ tar --no-same-owner --strip-components=1 -C toolchain -xf $($(package)_source_dir)/$($(package)_clang_file_name) && \ rm -f toolchain/lib/libc++abi.so* && \ - echo "#!/bin/sh" > toolchain/bin/$(host)-dsymutil && \ - echo "exit 0" >> toolchain/bin/$(host)-dsymutil && \ - chmod +x toolchain/bin/$(host)-dsymutil && \ tar --no-same-owner --strip-components=1 -xf $($(package)_source) endef define $(package)_set_vars -$(package)_config_opts=--target=$(host) --disable-lto-support -$(package)_ldflags+=-Wl,-rpath=\\$$$$$$$$\$$$$$$$$ORIGIN/../lib -$(package)_cc=$($(package)_extract_dir)/toolchain/bin/clang -$(package)_cxx=$($(package)_extract_dir)/toolchain/bin/clang++ + $(package)_config_opts=--target=$(host) --disable-lto-support --with-libtapi=$($(package)_extract_dir) + $(package)_ldflags+=-Wl,-rpath=\\$$$$$$$$\$$$$$$$$ORIGIN/../lib + $(package)_cc=$($(package)_extract_dir)/toolchain/bin/clang + $(package)_cxx=$($(package)_extract_dir)/toolchain/bin/clang++ endef define $(package)_preprocess_cmds - cd $($(package)_build_subdir); ./autogen.sh && \ - sed -i.old "/define HAVE_PTHREADS/d" ld64/src/ld/InputFiles.h + CC=$($(package)_cc) CXX=$($(package)_cxx) INSTALLPREFIX=$($(package)_extract_dir) ./libtapi/build.sh && \ + CC=$($(package)_cc) CXX=$($(package)_cxx) INSTALLPREFIX=$($(package)_extract_dir) ./libtapi/install.sh && \ + sed -i.old "/define HAVE_PTHREADS/d" $($(package)_build_subdir)/ld64/src/ld/InputFiles.h endef define $(package)_config_cmds @@ -52,6 +62,9 @@ endef define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install && \ + mkdir -p $($(package)_staging_prefix_dir)/lib/ && \ + cd $($(package)_extract_dir) && \ + cp lib/libtapi.so.6 $($(package)_staging_prefix_dir)/lib/ && \ cd $($(package)_extract_dir)/toolchain && \ mkdir -p $($(package)_staging_prefix_dir)/lib/clang/$($(package)_clang_version)/include && \ mkdir -p $($(package)_staging_prefix_dir)/bin $($(package)_staging_prefix_dir)/include && \ @@ -59,7 +72,6 @@ define $(package)_stage_cmds cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin/ &&\ cp lib/libLTO.so $($(package)_staging_prefix_dir)/lib/ && \ cp -rf lib/clang/$($(package)_clang_version)/include/* $($(package)_staging_prefix_dir)/lib/clang/$($(package)_clang_version)/include/ && \ - cp bin/llvm-dsymutil $($(package)_staging_prefix_dir)/bin/$(host)-dsymutil && \ - if `test -d include/c++/`; then cp -rf include/c++/ $($(package)_staging_prefix_dir)/include/; fi && \ - if `test -d lib/c++/`; then cp -rf lib/c++/ $($(package)_staging_prefix_dir)/lib/; fi + cp bin/dsymutil $($(package)_staging_prefix_dir)/bin/$(host)-dsymutil endef + diff --git a/make.sh b/make.sh index 77cf1df16d..40299dac8d 100755 --- a/make.sh +++ b/make.sh @@ -340,8 +340,8 @@ pkg_install_deps() { } pkg_ensure_mac_sdk() { - local sdk_name="MacOSX10.14.sdk" - local pkg="${sdk_name}.tar.xz" + local sdk_name="Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers" + local pkg="${sdk_name}.tar.gz" echo "> ensuring mac sdk" @@ -349,9 +349,9 @@ pkg_ensure_mac_sdk() { pushd ./depends/SDKs >/dev/null if [[ ! -d "$sdk_name" ]]; then if [[ ! -f "${pkg}" ]]; then - wget https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.14.sdk.tar.xz + wget https://bitcoincore.org/depends-sources/sdks/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz fi - tar -xvf "${pkg}" + tar -zxvf "${pkg}" fi rm "${pkg}" 2>/dev/null || true popd >/dev/null From 5e740129bda925dc84a4a8547bca3fec75137a39 Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Tue, 31 Aug 2021 11:06:25 +0100 Subject: [PATCH 07/27] Remove MakeUnique --- src/Makefile.am | 1 - src/bench/coin_selection.cpp | 4 +-- src/chainparamsbase.cpp | 9 +++-- src/flushablestorage.h | 8 ++--- src/httprpc.cpp | 2 +- src/index/blockfilterindex.cpp | 4 +-- src/index/txindex.cpp | 2 +- src/init.cpp | 26 +++++++-------- src/interfaces/chain.cpp | 8 ++--- src/interfaces/handler.cpp | 3 +- src/masternodes/icxorder.cpp | 14 ++++---- src/masternodes/rpc_accounts.cpp | 4 +-- src/masternodes/tokens.cpp | 4 +-- src/net.cpp | 6 ++-- src/script/descriptor.cpp | 46 +++++++++++++------------- src/test/allocator_tests.cpp | 3 +- src/test/anchor_tests.cpp | 2 +- src/test/checkqueue_tests.cpp | 15 ++++----- src/test/dbwrapper_tests.cpp | 5 ++- src/test/denialofservice_tests.cpp | 23 ++++++------- src/test/fuzz/fuzz.cpp | 3 +- src/test/net_tests.cpp | 7 ++-- src/test/setup_common.cpp | 17 +++++----- src/txmempool.cpp | 2 +- src/util/memory.h | 19 ----------- src/util/system.cpp | 2 +- src/util/system.h | 1 - src/validation.cpp | 4 +-- src/wallet/db.cpp | 6 ++-- src/wallet/db.h | 6 ++-- src/wallet/load.cpp | 2 +- src/wallet/rpcdump.cpp | 4 +-- src/wallet/test/coinselector_tests.cpp | 2 +- src/wallet/test/wallet_tests.cpp | 2 +- src/wallet/wallet.cpp | 4 +-- 35 files changed, 120 insertions(+), 150 deletions(-) delete mode 100644 src/util/memory.h diff --git a/src/Makefile.am b/src/Makefile.am index 0bc3a6518e..5e1aa47277 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -245,7 +245,6 @@ DEFI_CORE_H = \ util/error.h \ util/fees.h \ util/system.h \ - util/memory.h \ util/moneystr.h \ util/rbf.h \ util/string.h \ diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index 2f8c97c477..f2e3eab542 100644 --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -16,7 +16,7 @@ static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector(&wallet, MakeTransactionRef(std::move(tx)))); + wtxs.push_back(std::make_unique(&wallet, MakeTransactionRef(std::move(tx)))); } // Simple benchmark for wallet coin selection. Note that it maybe be necessary @@ -70,7 +70,7 @@ static void add_coin(const CAmount& nValue, int nInput, std::vector CMutableTransaction tx; tx.vout.resize(nInput + 1); tx.vout[nInput].nValue = nValue; - std::unique_ptr wtx = MakeUnique(&testWallet, MakeTransactionRef(std::move(tx))); + std::unique_ptr wtx = std::make_unique(&testWallet, MakeTransactionRef(std::move(tx))); set.emplace_back(COutput(wtx.get(), nInput, 0, true, true, true).GetInputCoin(), 0, true, 0, 0); wtxn.emplace_back(std::move(wtx)); } diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index 95b7836b52..fc2526f43e 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -7,7 +7,6 @@ #include #include -#include #include @@ -37,13 +36,13 @@ const CBaseChainParams& BaseParams() std::unique_ptr CreateBaseChainParams(const std::string& chain) { if (chain == CBaseChainParams::MAIN) - return MakeUnique("", 8554); + return std::make_unique("", 8554); else if (chain == CBaseChainParams::TESTNET) - return MakeUnique("testnet3", 18554); + return std::make_unique("testnet3", 18554); else if (chain == CBaseChainParams::DEVNET) - return MakeUnique("devnet", 20554); + return std::make_unique("devnet", 20554); else if (chain == CBaseChainParams::REGTEST) - return MakeUnique("regtest", 19554); + return std::make_unique("regtest", 19554); else throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain)); } diff --git a/src/flushablestorage.h b/src/flushablestorage.h index c9a9ffcea1..b5352ce4e2 100644 --- a/src/flushablestorage.h +++ b/src/flushablestorage.h @@ -166,7 +166,7 @@ class CStorageLevelDB : public CStorageKV { return batch.SizeEstimate(); } std::unique_ptr NewIterator() override { - return MakeUnique(std::unique_ptr(db.NewIterator())); + return std::make_unique(std::unique_ptr(db.NewIterator())); } void Compact(const TBytes& begin, const TBytes& end) { db.CompactRange(refTBytes(begin), refTBytes(end)); @@ -317,7 +317,7 @@ class CFlushableStorageKV : public CStorageKV { return memusage::DynamicUsage(changed); } std::unique_ptr NewIterator() override { - return MakeUnique(db.NewIterator(), changed); + return std::make_unique(db.NewIterator(), changed); } MapKV& GetRaw() { @@ -427,8 +427,8 @@ class CStorageIteratorWrapper { // Creates an iterator to single level key value storage template CStorageIteratorWrapper NewKVIterator(const KeyType& key, MapKV& map) { - auto emptyParent = MakeUnique(); - auto flushableIterator = MakeUnique(std::move(emptyParent), map); + auto emptyParent = std::make_unique(); + auto flushableIterator = std::make_unique(std::move(emptyParent), map); CStorageIteratorWrapper it{std::move(flushableIterator)}; it.Seek(key); return it; diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 8dfc133351..bde55e7f42 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -277,7 +277,7 @@ bool StartHTTPRPC() } struct event_base* eventBase = EventBase(); assert(eventBase); - httpRPCTimerInterface = MakeUnique(eventBase); + httpRPCTimerInterface = std::make_unique(eventBase); RPCSetTimerInterface(httpRPCTimerInterface.get()); return true; } diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp index f45cd06e41..849bbb5159 100644 --- a/src/index/blockfilterindex.cpp +++ b/src/index/blockfilterindex.cpp @@ -107,8 +107,8 @@ BlockFilterIndex::BlockFilterIndex(BlockFilterType filter_type, fs::create_directories(path); m_name = filter_name + " block filter index"; - m_db = MakeUnique(path / "db", n_cache_size, f_memory, f_wipe); - m_filter_fileseq = MakeUnique(std::move(path), "fltr", FLTR_FILE_CHUNK_SIZE); + m_db = std::make_unique(path / "db", n_cache_size, f_memory, f_wipe); + m_filter_fileseq = std::make_unique(std::move(path), "fltr", FLTR_FILE_CHUNK_SIZE); } bool BlockFilterIndex::Init() diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp index cca08fd0f9..6ad9230cc1 100644 --- a/src/index/txindex.cpp +++ b/src/index/txindex.cpp @@ -225,7 +225,7 @@ bool TxIndex::DB::MigrateData(CBlockTreeDB& block_tree_db, const CBlockLocator& } TxIndex::TxIndex(size_t n_cache_size, bool f_memory, bool f_wipe) - : m_db(MakeUnique(n_cache_size, f_memory, f_wipe)) + : m_db(std::make_unique(n_cache_size, f_memory, f_wipe)) {} TxIndex::~TxIndex() {} diff --git a/src/init.cpp b/src/init.cpp index 989450937f..894e900327 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1258,7 +1258,7 @@ bool AppInitLockDataDirectory() void SetupAnchorSPVDatabases(bool resync) { // Close and open database panchors.reset(); - panchors = MakeUnique(nDefaultDbCache << 20, false, gArgs.GetBoolArg("-spv", true) && resync); + panchors = std::make_unique(nDefaultDbCache << 20, false, gArgs.GetBoolArg("-spv", true) && resync); // load anchors after spv due to spv (and spv height) not set before (no last height yet) if (gArgs.GetBoolArg("-spv", true)) { @@ -1267,11 +1267,11 @@ void SetupAnchorSPVDatabases(bool resync) { // Open database based on network if (Params().NetworkIDString() == "regtest") { - spv::pspv = MakeUnique(); + spv::pspv = std::make_unique(); } else if (Params().NetworkIDString() == "test" || Params().NetworkIDString() == "devnet") { - spv::pspv = MakeUnique(false, nMinDbCache << 20, false, resync); + spv::pspv = std::make_unique(false, nMinDbCache << 20, false, resync); } else { - spv::pspv = MakeUnique(true, nMinDbCache << 20, false, resync); + spv::pspv = std::make_unique(true, nMinDbCache << 20, false, resync); } } } @@ -1384,7 +1384,7 @@ bool AppInitMain(InitInterfaces& interfaces) // need to reindex later. assert(!g_banman); - g_banman = MakeUnique(GetDataDir() / "banlist.dat", &uiInterface, gArgs.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME)); + g_banman = std::make_unique(GetDataDir() / "banlist.dat", &uiInterface, gArgs.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME)); assert(!g_connman); g_connman = std::unique_ptr(new CConnman(GetRand(std::numeric_limits::max()), GetRand(std::numeric_limits::max()))); @@ -1543,7 +1543,7 @@ bool AppInitMain(InitInterfaces& interfaces) try { LOCK(cs_main); // This statement makes ::ChainstateActive() usable. - g_chainstate = MakeUnique(); + g_chainstate = std::make_unique(); UnloadBlockIndex(); // new CBlockTreeDB tries to delete the existing file, which @@ -1608,9 +1608,9 @@ bool AppInitMain(InitInterfaces& interfaces) }); pcustomcsDB.reset(); - pcustomcsDB = MakeUnique(GetDataDir() / "enhancedcs", nCustomCacheSize, false, fReset || fReindexChainState); + pcustomcsDB = std::make_unique(GetDataDir() / "enhancedcs", nCustomCacheSize, false, fReset || fReindexChainState); pcustomcsview.reset(); - pcustomcsview = MakeUnique(*pcustomcsDB.get()); + pcustomcsview = std::make_unique(*pcustomcsDB.get()); if (!fReset && !fReindexChainState) { if (!pcustomcsDB->IsEmpty() && pcustomcsview->GetDbVersion() != CCustomCSView::DbVersion) { strLoadError = _("Account database is unsuitable").translated; @@ -1624,11 +1624,11 @@ bool AppInitMain(InitInterfaces& interfaces) // make account history db paccountHistoryDB.reset(); if (gArgs.GetBoolArg("-acindex", DEFAULT_ACINDEX)) { - paccountHistoryDB = MakeUnique(GetDataDir() / "history", nCustomCacheSize, false, fReset || fReindexChainState); + paccountHistoryDB = std::make_unique(GetDataDir() / "history", nCustomCacheSize, false, fReset || fReindexChainState); } pburnHistoryDB.reset(); - pburnHistoryDB = MakeUnique(GetDataDir() / "burn", nCustomCacheSize, false, fReset || fReindexChainState); + pburnHistoryDB = std::make_unique(GetDataDir() / "burn", nCustomCacheSize, false, fReset || fReindexChainState); // If necessary, upgrade from older database format. // This is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate @@ -1745,7 +1745,7 @@ bool AppInitMain(InitInterfaces& interfaces) // ********************************************************* Step 8: start indexers if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { - g_txindex = MakeUnique(nTxIndexCache, false, fReindex); + g_txindex = std::make_unique(nTxIndexCache, false, fReindex); g_txindex->Start(); } @@ -1767,9 +1767,9 @@ bool AppInitMain(InitInterfaces& interfaces) LOCK(cs_main); panchorauths.reset(); - panchorauths = MakeUnique(); + panchorauths = std::make_unique(); panchorAwaitingConfirms.reset(); - panchorAwaitingConfirms = MakeUnique(); + panchorAwaitingConfirms = std::make_unique(); SetupAnchorSPVDatabases(gArgs.GetBoolArg("-spv_resync", fReindex || fReindexChainState)); // Check if DB version changed diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp index 70a76e5091..fe6f0688f8 100644 --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -250,7 +250,7 @@ class ChainImpl : public Chain public: std::unique_ptr lock() override { - return MakeUnique(::cs_main); + return std::make_unique(::cs_main); } bool findBlock(const uint256& hash, CBlock* block, int64_t* time, int64_t* time_max) override { @@ -365,7 +365,7 @@ class ChainImpl : public Chain } std::unique_ptr handleNotifications(Notifications& notifications) override { - return MakeUnique(*this, notifications); + return std::make_unique(*this, notifications); } void waitForNotificationsIfNewBlocksConnected(const uint256& old_tip) override { @@ -379,7 +379,7 @@ class ChainImpl : public Chain } std::unique_ptr handleRpc(const CRPCCommand& command) override { - return MakeUnique(command); + return std::make_unique(command); } bool rpcEnableDeprecated(const std::string& method) override { return IsDeprecatedRPCEnabled(method); } void rpcRunLater(const std::string& name, std::function fn, int64_t seconds) override @@ -397,6 +397,6 @@ class ChainImpl : public Chain }; } // namespace -std::unique_ptr MakeChain() { return MakeUnique(); } +std::unique_ptr MakeChain() { return std::make_unique(); } } // namespace interfaces diff --git a/src/interfaces/handler.cpp b/src/interfaces/handler.cpp index 0262ec712f..eb3d257328 100644 --- a/src/interfaces/handler.cpp +++ b/src/interfaces/handler.cpp @@ -4,7 +4,6 @@ #include -#include #include #include @@ -26,7 +25,7 @@ class HandlerImpl : public Handler std::unique_ptr MakeHandler(boost::signals2::connection connection) { - return MakeUnique(std::move(connection)); + return std::make_unique(std::move(connection)); } } // namespace interfaces diff --git a/src/masternodes/icxorder.cpp b/src/masternodes/icxorder.cpp index e68827062d..1f84d4abd3 100644 --- a/src/masternodes/icxorder.cpp +++ b/src/masternodes/icxorder.cpp @@ -46,7 +46,7 @@ std::unique_ptr CICXOrderView::GetICXOrderByCreati { auto order = ReadBy(txid); if (order) - return MakeUnique(*order); + return std::make_unique(*order); return {}; } @@ -138,7 +138,7 @@ std::unique_ptr CICXOrderView::GetICXMakeOffer { auto makeoffer = ReadBy(txid); if (makeoffer) - return MakeUnique(*makeoffer); + return std::make_unique(*makeoffer); return {}; } @@ -214,7 +214,7 @@ std::unique_ptr CICXOrderView::GetICXSubmi { auto submitdfchtlc = ReadBy(txid); if (submitdfchtlc) - return MakeUnique(*submitdfchtlc); + return std::make_unique(*submitdfchtlc); return {}; } @@ -292,7 +292,7 @@ std::unique_ptr CICXOrderView::GetICXSubmi { auto submitexthtlc = ReadBy(txid); if (submitexthtlc) - return MakeUnique(*submitexthtlc); + return std::make_unique(*submitexthtlc); return {}; } @@ -370,7 +370,7 @@ std::unique_ptr CICXOrderView::GetICXClaimD { auto claimdfchtlc = ReadBy(txid); if (claimdfchtlc) - return MakeUnique(*claimdfchtlc); + return std::make_unique(*claimdfchtlc); return {}; } @@ -398,7 +398,7 @@ std::unique_ptr CICXOrderView::GetICXCloseOrd { auto closeorderImpl = ReadBy(txid); if (closeorderImpl) - return MakeUnique(*closeorderImpl); + return std::make_unique(*closeorderImpl); return {}; } @@ -417,7 +417,7 @@ std::unique_ptr CICXOrderView::GetICXCloseOff { auto closeofferImpl = ReadBy(txid); if (closeofferImpl) - return MakeUnique(*closeofferImpl); + return std::make_unique(*closeofferImpl); return {}; } diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index 86e49cac26..74d05a5379 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -1086,7 +1086,7 @@ UniValue listaccounthistory(const JSONRPCRequest& request) { std::unique_ptr reverter; if (!noRewards) { - reverter = MakeUnique(view, key.owner, valueLazy.get().diff); + reverter = std::make_unique(view, key.owner, valueLazy.get().diff); } bool accountRecord = true; @@ -1468,7 +1468,7 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { std::unique_ptr reverter; if (!noRewards) { - reverter = MakeUnique(view, key.owner, value.diff); + reverter = std::make_unique(view, key.owner, value.diff); } if (CustomTxType::None != txType && value.category != uint8_t(txType)) { diff --git a/src/masternodes/tokens.cpp b/src/masternodes/tokens.cpp index 7f4478e255..8f9f79ed8d 100644 --- a/src/masternodes/tokens.cpp +++ b/src/masternodes/tokens.cpp @@ -29,7 +29,7 @@ std::string trim_ws(std::string const & str) std::unique_ptr CTokensView::GetToken(DCT_ID id) const { if (auto tokenImpl = ReadBy(id)) { - return MakeUnique(*tokenImpl); + return std::make_unique(*tokenImpl); } return {}; @@ -71,7 +71,7 @@ std::unique_ptr CTokensView::GetTokenGuessId(const std::string & str, DC auto pair = GetTokenByCreationTx(tx); if (pair) { id = pair->first; - return MakeUnique(pair->second); + return std::make_unique(pair->second); } } else { auto pair = GetToken(key); diff --git a/src/net.cpp b/src/net.cpp index 5f1cbe3470..b92bc6e755 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2236,11 +2236,11 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions) if (semOutbound == nullptr) { // initialize semaphore - semOutbound = MakeUnique(std::min((nMaxOutbound + nMaxFeeler), nMaxConnections)); + semOutbound = std::make_unique(std::min((nMaxOutbound + nMaxFeeler), nMaxConnections)); } if (semAddnode == nullptr) { // initialize semaphore - semAddnode = MakeUnique(nMaxAddnode); + semAddnode = std::make_unique(nMaxAddnode); } // @@ -2641,7 +2641,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; hashContinue = uint256(); filterInventoryKnown.reset(); - pfilter = MakeUnique(); + pfilter = std::make_unique(); for (const std::string &msg : getAllNetMessageTypes()) mapRecvBytesPerMsgCmd[msg] = 0; diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index df38354f4d..9f74f79b78 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -727,7 +727,7 @@ std::unique_ptr ParsePubkeyInner(const Span& sp, boo CPubKey pubkey(data); if (pubkey.IsFullyValid()) { if (permit_uncompressed || pubkey.IsCompressed()) { - return MakeUnique(pubkey); + return std::make_unique(pubkey); } else { error = "Uncompressed keys are not allowed"; return nullptr; @@ -741,7 +741,7 @@ std::unique_ptr ParsePubkeyInner(const Span& sp, boo if (permit_uncompressed || key.IsCompressed()) { CPubKey pubkey = key.GetPubKey(); out.keys.emplace(pubkey.GetID(), key); - return MakeUnique(pubkey); + return std::make_unique(pubkey); } else { error = "Uncompressed keys are not allowed"; return nullptr; @@ -768,7 +768,7 @@ std::unique_ptr ParsePubkeyInner(const Span& sp, boo extpubkey = extkey.Neuter(); out.keys.emplace(extpubkey.pubkey.GetID(), extkey.key); } - return MakeUnique(extpubkey, std::move(path), type); + return std::make_unique(extpubkey, std::move(path), type); } /** Parse a public key including origin information (if enabled). */ @@ -802,7 +802,7 @@ std::unique_ptr ParsePubkey(const Span& sp, bool per if (!ParseKeyPath(slash_split, info.path, error)) return nullptr; auto provider = ParsePubkeyInner(origin_split[1], permit_uncompressed, out, error); if (!provider) return nullptr; - return MakeUnique(std::move(info), std::move(provider)); + return std::make_unique(std::move(info), std::move(provider)); } /** Parse a script in a particular context. */ @@ -812,17 +812,17 @@ std::unique_ptr ParseScript(Span& sp, ParseScriptCon if (Func("pk", expr)) { auto pubkey = ParsePubkey(expr, ctx != ParseScriptContext::P2WSH, out, error); if (!pubkey) return nullptr; - return MakeUnique(std::move(pubkey)); + return std::make_unique(std::move(pubkey)); } if (Func("pkh", expr)) { auto pubkey = ParsePubkey(expr, ctx != ParseScriptContext::P2WSH, out, error); if (!pubkey) return nullptr; - return MakeUnique(std::move(pubkey)); + return std::make_unique(std::move(pubkey)); } if (ctx == ParseScriptContext::TOP && Func("combo", expr)) { auto pubkey = ParsePubkey(expr, true, out, error); if (!pubkey) return nullptr; - return MakeUnique(std::move(pubkey)); + return std::make_unique(std::move(pubkey)); } else if (ctx != ParseScriptContext::TOP && Func("combo", expr)) { error = "Cannot have combo in non-top level"; return nullptr; @@ -869,12 +869,12 @@ std::unique_ptr ParseScript(Span& sp, ParseScriptCon return nullptr; } } - return MakeUnique(thres, std::move(providers)); + return std::make_unique(thres, std::move(providers)); } if (ctx != ParseScriptContext::P2WSH && Func("wpkh", expr)) { auto pubkey = ParsePubkey(expr, false, out, error); if (!pubkey) return nullptr; - return MakeUnique(std::move(pubkey)); + return std::make_unique(std::move(pubkey)); } else if (ctx == ParseScriptContext::P2WSH && Func("wpkh", expr)) { error = "Cannot have wpkh within wsh"; return nullptr; @@ -882,7 +882,7 @@ std::unique_ptr ParseScript(Span& sp, ParseScriptCon if (ctx == ParseScriptContext::TOP && Func("sh", expr)) { auto desc = ParseScript(expr, ParseScriptContext::P2SH, out, error); if (!desc || expr.size()) return nullptr; - return MakeUnique(std::move(desc)); + return std::make_unique(std::move(desc)); } else if (ctx != ParseScriptContext::TOP && Func("sh", expr)) { error = "Cannot have sh in non-top level"; return nullptr; @@ -890,7 +890,7 @@ std::unique_ptr ParseScript(Span& sp, ParseScriptCon if (ctx != ParseScriptContext::P2WSH && Func("wsh", expr)) { auto desc = ParseScript(expr, ParseScriptContext::P2WSH, out, error); if (!desc || expr.size()) return nullptr; - return MakeUnique(std::move(desc)); + return std::make_unique(std::move(desc)); } else if (ctx == ParseScriptContext::P2WSH && Func("wsh", expr)) { error = "Cannot have wsh within wsh"; return nullptr; @@ -901,7 +901,7 @@ std::unique_ptr ParseScript(Span& sp, ParseScriptCon error = "Address is not valid"; return nullptr; } - return MakeUnique(std::move(dest)); + return std::make_unique(std::move(dest)); } if (ctx == ParseScriptContext::TOP && Func("raw", expr)) { std::string str(expr.begin(), expr.end()); @@ -910,7 +910,7 @@ std::unique_ptr ParseScript(Span& sp, ParseScriptCon return nullptr; } auto bytes = ParseHex(str); - return MakeUnique(CScript(bytes.begin(), bytes.end())); + return std::make_unique(CScript(bytes.begin(), bytes.end())); } if (ctx == ParseScriptContext::P2SH) { error = "A function is needed within P2SH"; @@ -925,10 +925,10 @@ std::unique_ptr ParseScript(Span& sp, ParseScriptCon std::unique_ptr InferPubkey(const CPubKey& pubkey, ParseScriptContext, const SigningProvider& provider) { - std::unique_ptr key_provider = MakeUnique(pubkey); + std::unique_ptr key_provider = std::make_unique(pubkey); KeyOriginInfo info; if (provider.GetKeyOrigin(pubkey.GetID(), info)) { - return MakeUnique(std::move(info), std::move(key_provider)); + return std::make_unique(std::move(info), std::move(key_provider)); } return key_provider; } @@ -941,7 +941,7 @@ std::unique_ptr InferScript(const CScript& script, ParseScriptCo if (txntype == TX_PUBKEY) { CPubKey pubkey(data[0].begin(), data[0].end()); if (pubkey.IsValid()) { - return MakeUnique(InferPubkey(pubkey, ctx, provider)); + return std::make_unique(InferPubkey(pubkey, ctx, provider)); } } if (txntype == TX_PUBKEYHASH) { @@ -949,7 +949,7 @@ std::unique_ptr InferScript(const CScript& script, ParseScriptCo CKeyID keyid(hash); CPubKey pubkey; if (provider.GetPubKey(keyid, pubkey)) { - return MakeUnique(InferPubkey(pubkey, ctx, provider)); + return std::make_unique(InferPubkey(pubkey, ctx, provider)); } } if (txntype == TX_WITNESS_V0_KEYHASH && ctx != ParseScriptContext::P2WSH) { @@ -957,7 +957,7 @@ std::unique_ptr InferScript(const CScript& script, ParseScriptCo CKeyID keyid(hash); CPubKey pubkey; if (provider.GetPubKey(keyid, pubkey)) { - return MakeUnique(InferPubkey(pubkey, ctx, provider)); + return std::make_unique(InferPubkey(pubkey, ctx, provider)); } } if (txntype == TX_MULTISIG) { @@ -966,7 +966,7 @@ std::unique_ptr InferScript(const CScript& script, ParseScriptCo CPubKey pubkey(data[i].begin(), data[i].end()); providers.push_back(InferPubkey(pubkey, ctx, provider)); } - return MakeUnique((int)data[0][0], std::move(providers)); + return std::make_unique((int)data[0][0], std::move(providers)); } if (txntype == TX_SCRIPTHASH && ctx == ParseScriptContext::TOP) { uint160 hash(data[0]); @@ -974,7 +974,7 @@ std::unique_ptr InferScript(const CScript& script, ParseScriptCo CScript subscript; if (provider.GetCScript(scriptid, subscript)) { auto sub = InferScript(subscript, ParseScriptContext::P2SH, provider); - if (sub) return MakeUnique(std::move(sub)); + if (sub) return std::make_unique(std::move(sub)); } } if (txntype == TX_WITNESS_V0_SCRIPTHASH && ctx != ParseScriptContext::P2WSH) { @@ -983,18 +983,18 @@ std::unique_ptr InferScript(const CScript& script, ParseScriptCo CScript subscript; if (provider.GetCScript(scriptid, subscript)) { auto sub = InferScript(subscript, ParseScriptContext::P2WSH, provider); - if (sub) return MakeUnique(std::move(sub)); + if (sub) return std::make_unique(std::move(sub)); } } CTxDestination dest; if (ExtractDestination(script, dest)) { if (GetScriptForDestination(dest) == script) { - return MakeUnique(std::move(dest)); + return std::make_unique(std::move(dest)); } } - return MakeUnique(script); + return std::make_unique(script); } diff --git a/src/test/allocator_tests.cpp b/src/test/allocator_tests.cpp index dd83ac695d..7315a4e72b 100644 --- a/src/test/allocator_tests.cpp +++ b/src/test/allocator_tests.cpp @@ -2,7 +2,6 @@ // Distributed under the MIT software license, see the accompanying // file LICENSE or http://www.opensource.org/licenses/mit-license.php. -#include #include #include @@ -163,7 +162,7 @@ class TestLockedPageAllocator: public LockedPageAllocator BOOST_AUTO_TEST_CASE(lockedpool_tests_mock) { // Test over three virtual arenas, of which one will succeed being locked - std::unique_ptr x = MakeUnique(3, 1); + std::unique_ptr x = std::make_unique(3, 1); LockedPool pool(std::move(x)); BOOST_CHECK(pool.stats().total == 0); BOOST_CHECK(pool.stats().locked == 0); diff --git a/src/test/anchor_tests.cpp b/src/test/anchor_tests.cpp index f3aa4ced84..d6f246b857 100644 --- a/src/test/anchor_tests.cpp +++ b/src/test/anchor_tests.cpp @@ -13,7 +13,7 @@ struct SpvTestingSetup : public TestingSetup { SpvTestingSetup() : TestingSetup(CBaseChainParams::MAIN) { - spv::pspv = MakeUnique(); + spv::pspv = std::make_unique(); } ~SpvTestingSetup() { diff --git a/src/test/checkqueue_tests.cpp b/src/test/checkqueue_tests.cpp index 43260047d4..2dbf469f05 100644 --- a/src/test/checkqueue_tests.cpp +++ b/src/test/checkqueue_tests.cpp @@ -2,7 +2,6 @@ // Distributed under the MIT software license, see the accompanying // file LICENSE or http://www.opensource.org/licenses/mit-license.php. -#include #include #include #include @@ -147,7 +146,7 @@ typedef CCheckQueue FrozenCleanup_Queue; */ static void Correct_Queue_range(std::vector range) { - auto small_queue = MakeUnique(QUEUE_BATCH_SIZE); + auto small_queue = std::make_unique(QUEUE_BATCH_SIZE); boost::thread_group tg; for (auto x = 0; x < nScriptCheckThreads; ++x) { tg.create_thread([&]{small_queue->Thread();}); @@ -211,7 +210,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Correct_Random) /** Test that failing checks are caught */ BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure) { - auto fail_queue = MakeUnique(QUEUE_BATCH_SIZE); + auto fail_queue = std::make_unique(QUEUE_BATCH_SIZE); boost::thread_group tg; for (auto x = 0; x < nScriptCheckThreads; ++x) { @@ -244,7 +243,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure) // future blocks, ie, the bad state is cleared. BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure) { - auto fail_queue = MakeUnique(QUEUE_BATCH_SIZE); + auto fail_queue = std::make_unique(QUEUE_BATCH_SIZE); boost::thread_group tg; for (auto x = 0; x < nScriptCheckThreads; ++x) { tg.create_thread([&]{fail_queue->Thread();}); @@ -272,7 +271,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure) // more than once as well BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck) { - auto queue = MakeUnique(QUEUE_BATCH_SIZE); + auto queue = std::make_unique(QUEUE_BATCH_SIZE); boost::thread_group tg; for (auto x = 0; x < nScriptCheckThreads; ++x) { tg.create_thread([&]{queue->Thread();}); @@ -308,7 +307,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck) // time could leave the data hanging across a sequence of blocks. BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory) { - auto queue = MakeUnique(QUEUE_BATCH_SIZE); + auto queue = std::make_unique(QUEUE_BATCH_SIZE); boost::thread_group tg; for (auto x = 0; x < nScriptCheckThreads; ++x) { tg.create_thread([&]{queue->Thread();}); @@ -339,7 +338,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory) // have been destructed BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup) { - auto queue = MakeUnique(QUEUE_BATCH_SIZE); + auto queue = std::make_unique(QUEUE_BATCH_SIZE); boost::thread_group tg; bool fails = false; for (auto x = 0; x < nScriptCheckThreads; ++x) { @@ -383,7 +382,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup) /** Test that CCheckQueueControl is threadsafe */ BOOST_AUTO_TEST_CASE(test_CheckQueueControl_Locks) { - auto queue = MakeUnique(QUEUE_BATCH_SIZE); + auto queue = std::make_unique(QUEUE_BATCH_SIZE); { boost::thread_group tg; std::atomic nThreads {0}; diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp index 2ca4e82474..5073f82bdb 100644 --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -127,7 +126,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate) create_directories(ph); // Set up a non-obfuscated wrapper to write some initial data. - std::unique_ptr dbw = MakeUnique(ph, (1 << 10), false, false, false); + std::unique_ptr dbw = std::make_unique(ph, (1 << 10), false, false, false); char key = 'k'; uint256 in = InsecureRand256(); uint256 res; @@ -168,7 +167,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex) create_directories(ph); // Set up a non-obfuscated wrapper to write some initial data. - std::unique_ptr dbw = MakeUnique(ph, (1 << 10), false, false, false); + std::unique_ptr dbw = std::make_unique(ph, (1 << 10), false, false, false); char key = 'k'; uint256 in = InsecureRand256(); uint256 res; diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp index 8e31d110b5..40a2b65b7c 100644 --- a/src/test/denialofservice_tests.cpp +++ b/src/test/denialofservice_tests.cpp @@ -12,7 +12,6 @@ #include