From c748b9dd386ce33a7135df5004c763805600e3fe Mon Sep 17 00:00:00 2001 From: renium9 Date: Sun, 18 Mar 2018 03:21:09 +0900 Subject: [PATCH] Add patches for Mac --- zcutil/mac-10.11.diff | 102 +++++++++++ zcutil/mac-build.diff | 405 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 507 insertions(+) create mode 100644 zcutil/mac-10.11.diff create mode 100644 zcutil/mac-build.diff diff --git a/zcutil/mac-10.11.diff b/zcutil/mac-10.11.diff new file mode 100644 index 000000000..ebeb014f2 --- /dev/null +++ b/zcutil/mac-10.11.diff @@ -0,0 +1,102 @@ +diff --git a/depends/Makefile b/depends/Makefile +index 897c4ad..4486101 100644 +--- a/depends/Makefile ++++ b/depends/Makefile +@@ -99,8 +99,8 @@ $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) + $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id) + $(AT)@mkdir -p $(@D) + $(AT)sed -e 's|@HOST@|$(host)|' \ +- -e 's|@CC@|$(toolchain_path)$(host_CC)|' \ +- -e 's|@CXX@|$(toolchain_path)$(host_CXX)|' \ ++ -e 's|@CC@|/usr/local/opt/llvm/bin/clang|' \ ++ -e 's|@CXX@|/usr/local/opt/llvm/bin/clang++|' \ + -e 's|@AR@|$(toolchain_path)$(host_AR)|' \ + -e 's|@RANLIB@|$(toolchain_path)$(host_RANLIB)|' \ + -e 's|@NM@|$(toolchain_path)$(host_NM)|' \ +diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk +index 4e58bec..15545b4 100644 +--- a/depends/hosts/darwin.mk ++++ b/depends/hosts/darwin.mk +@@ -2,8 +2,8 @@ OSX_MIN_VERSION=10.8 + OSX_SDK_VERSION=10.11 + 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) +-darwin_CXX=clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -stdlib=libc++ ++darwin_CC=/usr/local/opt/llvm/bin/clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) ++darwin_CXX=/usr/local/opt/llvm/bin/clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -stdlib=libc++ + + darwin_CFLAGS=-pipe + darwin_CXXFLAGS=$(darwin_CFLAGS) +diff --git a/src/snark/src/common/profiling.cpp b/src/snark/src/common/profiling.cpp +index d227203..18f3194 100644 +--- a/src/snark/src/common/profiling.cpp ++++ b/src/snark/src/common/profiling.cpp +@@ -25,7 +25,12 @@ + #ifndef NO_PROCPS + #include + #endif +- ++#ifdef __MACH__ ++#include ++#include ++#include ++#include ++#endif + namespace libsnark { + + long long get_nsec_time() +@@ -37,12 +42,22 @@ long long get_nsec_time() + /* Return total CPU time consumsed by all threads of the process, in nanoseconds. */ + long long get_nsec_cpu_time() + { +- ::timespec ts; ++ ::timespec ts; ++#ifdef __MACH__ ++ clock_serv_t cclock; ++ mach_timespec_t mts; ++ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); ++ clock_get_time(cclock, &mts); ++ mach_port_deallocate(mach_task_self(), cclock); ++ ts.tv_sec = mts.tv_sec; ++ ts.tv_nsec = mts.tv_nsec; ++#else + if ( ::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) ) +- throw ::std::runtime_error("clock_gettime(CLOCK_PROCESS_CPUTIME_ID) failed"); +- // If we expected this to work, don't silently ignore failures, because that would hide the problem and incur an unnecessarily system-call overhead. So if we ever observe this exception, we should probably add a suitable #ifdef . +- //TODO: clock_gettime(CLOCK_PROCESS_CPUTIME_ID) is not supported by native Windows. What about Cygwin? Should we #ifdef on CLOCK_PROCESS_CPUTIME_ID or on __linux__? +- return ts.tv_sec * 1000000000ll + ts.tv_nsec; ++ throw ::std::runtime_error("clock_gettime(CLOCK_PROCESS_CPUTIME_ID) failed"); ++ // If we expected this to work, don't silently ignore failures, because that would hide the problem and incur an unnecessarily system-call overhead. So if we ever observe this exception, we should probably add a suitable #ifdef . ++ //TODO: clock_gettime(CLOCK_PROCESS_CPUTIME_ID) is not supported by native Windows. What about Cygwin? Should we #ifdef on CLOCK_PROCESS_CPUTIME_ID or on __linux__? ++#endif ++ return ts.tv_sec * 1000000000ll + ts.tv_nsec; + } + + long long start_time, last_time; +diff --git a/zcutil/build.sh b/zcutil/build.sh +index 33baeae..93f6df8 100755 +--- a/zcutil/build.sh ++++ b/zcutil/build.sh +@@ -35,10 +35,10 @@ fi + + # Allow override to $CC and $CXX for porters. Most users will not need it. + if [[ -z "${CC-}" ]]; then +- CC=gcc ++ CC=/usr/local/opt/llvm/bin/clang + fi + if [[ -z "${CXX-}" ]]; then +- CXX=g++ ++ CXX=/usr/local/opt/llvm/bin/clang++ + fi + + if [ "x$*" = 'x--help' ] +@@ -130,7 +130,7 @@ eval "$CXX" --version + as --version + ld -v + +-HOST="$HOST" BUILD="$BUILD" NO_RUST="$RUST_ARG" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 ++CC="$CC" CXX="$CXX" HOST="$HOST" BUILD="$BUILD" NO_RUST="$RUST_ARG" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 + ./autogen.sh + CC="$CC" CXX="$CXX" ./configure --prefix="${PREFIX}" --host="$HOST" --build="$BUILD" "$RUST_ARG" "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" "$LIBS_ARG" --enable-werror CXXFLAGS='-Wno-undefined-var-template -g' + diff --git a/zcutil/mac-build.diff b/zcutil/mac-build.diff new file mode 100644 index 000000000..3a480e77b --- /dev/null +++ b/zcutil/mac-build.diff @@ -0,0 +1,405 @@ +diff --git a/configure.ac b/configure.ac +index aedf8f4d3..11fe4fb0b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -188,9 +188,10 @@ fi + ERROR_CXXFLAGS= + if test "x$enable_werror" = "xyes"; then + if test "x$CXXFLAG_WERROR" = "x"; then +- AC_MSG_ERROR("enable-werror set but -Werror is not usable") ++ AC_MSG_WARN("enable-werror set but -Werror is not usable") ++ else ++ ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror" + fi +- ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror" + fi + + if test "x$CXXFLAGS_overridden" = "xno"; then +@@ -454,14 +455,22 @@ if test x$use_hardening != xno; then + HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2" + ],[AC_MSG_ERROR(Cannot enable -D_FORTIFY_SOURCE=2)]) + +- +- if test x$TARGET_OS != xwindows; then +- # All windows code is PIC, forcing it on just adds useless compile warnings ++ if test x$BUILD_OS != xdarwin; then + AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)]) + AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)]) +- ++ else ++ AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_WARN(Cannot enable RELRO)]) ++ AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_WARN(Cannot enable BIND_NOW)]) ++ fi ++ if test x$TARGET_OS != xwindows; then ++ # All windows code is PIC, forcing it on just adds useless compile warnings + AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"],[AC_MSG_ERROR(Cannot enable -fPIE)]) +- AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],[AC_MSG_ERROR(Cannot enable -pie)]) ++ ++ if test x$BUILD_OS = xdarwin; then ++ AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],[AC_MSG_WARN(Cannot enable -pie)]) ++ else ++ AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],[AC_MSG_ERROR(Cannot enable -pie)]) ++ fi + else + # These are only available on Windows. + AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"],[AC_MSG_ERROR(Cannot enable --dynamicbase)]) +@@ -720,6 +729,9 @@ fi + AX_CHECK_COMPILE_FLAG([-fwrapv],[CXXFLAGS="$CXXFLAGS -fwrapv"]) + AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing],[CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"]) + AX_CHECK_COMPILE_FLAG([-Wno-builtin-declaration-mismatch],[CXXFLAGS="$CXXFLAGS -Wno-builtin-declaration-mismatch"],,[[$CXXFLAG_WERROR]]) ++if test x$BUILD_OS = xdarwin; then ++ AX_CHECK_COMPILE_FLAG([-Wno-undefined-var-template],[CXXFLAGS="$CXXFLAGS -Wno-undefined-var-template"],,[[$CXXFLAG_WERROR]]) ++fi + + LIBZCASH_LIBS="-lgmp -lgmpxx -lboost_system-mt -lcrypto -lsodium $RUST_LIBS" + +diff --git a/src/Makefile.am b/src/Makefile.am +index ffde9b8e6..22a8ec98e 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -529,7 +529,9 @@ libzcash_a_SOURCES = \ + zcash/circuit/prfs.tcc \ + zcash/circuit/utils.tcc + +-libzcash_a_CPPFLAGS = -DMULTICORE -fopenmp -fPIC -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS $(HARDENED_CPPFLAGS) -pipe -O1 -g -Wstack-protector -fstack-protector-all -fPIE -fvisibility=hidden -DSTATIC $(BITCOIN_INCLUDES) ++libzcash_a_CPPFLAGS = -fPIC -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS $(HARDENED_CPPFLAGS) -pipe -O1 -g -Wstack-protector -fstack-protector-all -fPIE -fvisibility=hidden -DSTATIC $(BITCOIN_INCLUDES) ++ ++libzcash_a_CPPFLAGS := $(libzcash_a_CPPFLAGS) -fPIC -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS $(HARDENED_CPPFLAGS) -pipe -O1 -g -Wstack-protector -fstack-protector-all -fPIE -fvisibility=hidden -DSTATIC $(BITCOIN_INCLUDES) + + libzcash_a_CXXFLAGS = $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing + +@@ -560,10 +562,10 @@ if GLIBC_BACK_COMPAT + libzcashconsensus_la_SOURCES += compat/glibc_compat.cpp + endif + +-libzcashconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) +-libzcashconsensus_la_LIBADD = $(LIBSECP256K1) ++libzcashconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) -L$(srcdir) ++libzcashconsensus_la_LIBADD = $(LIBSECP256K1) -lboost_system -lsodium -lzcash -lbitcoin_common + libzcashconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL +-libzcashconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) ++libzcashconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -DNO_UTIL_LOG + + endif + # +diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include +index eaad8a79f..9bf298105 100644 +--- a/src/Makefile.gtest.include ++++ b/src/Makefile.gtest.include +@@ -46,7 +46,11 @@ zcash_gtest_SOURCES += \ + wallet/gtest/test_wallet.cpp + endif + +-zcash_gtest_CPPFLAGS = $(AM_CPPFLAGS) -DMULTICORE -fopenmp -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DSTATIC $(BITCOIN_INCLUDES) ++zcash_gtest_CPPFLAGS = $(AM_CPPFLAGS) ++if HAVE_OPENMP ++zcash_gtest_CPPFLAGS += -DMULTICORE -fopenmp ++endif ++zcash_gtest_CPPFLAGS += -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DSTATIC $(BITCOIN_INCLUDES) + zcash_gtest_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) + + zcash_gtest_LDADD = -lgtest -lgmock $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \ +diff --git a/src/Makefile.test.include b/src/Makefile.test.include +index 582ecb577..6db88b5c0 100644 +--- a/src/Makefile.test.include ++++ b/src/Makefile.test.include +@@ -99,7 +99,12 @@ BITCOIN_TESTS += \ + endif + + test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES) +-test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) -fopenmp $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS) $(EVENT_CFLAGS) ++test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) ++if HAVE_OPENMP ++test_test_bitcoin_CPPFLAGS += -DMULTICORE -fopenmp ++endif ++test_test_bitcoin_CPPFLAGS += $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS) $(EVENT_CFLAGS) ++ + test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \ + $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) + test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +diff --git a/src/crypto/equihash.cpp b/src/crypto/equihash.cpp +index ecc50e536..995147c09 100644 +--- a/src/crypto/equihash.cpp ++++ b/src/crypto/equihash.cpp +@@ -18,7 +18,12 @@ + + #include "compat/endian.h" + #include "crypto/equihash.h" ++ ++#ifndef NO_UTIL_LOG + #include "util.h" ++#else ++#define LogPrint(...) ++#endif + + #include + #include +diff --git a/src/crypto/equihash.h b/src/crypto/equihash.h +index 6691844ba..8236f4c69 100644 +--- a/src/crypto/equihash.h ++++ b/src/crypto/equihash.h +@@ -10,7 +10,7 @@ + #include "utilstrencodings.h" + + #include "sodium.h" +- ++#include + #include + #include + #include +@@ -182,14 +182,12 @@ public: + Equihash() { } + + int InitialiseState(eh_HashState& base_state); +-#ifdef ENABLE_MINING + bool BasicSolve(const eh_HashState& base_state, + const std::function)> validBlock, + const std::function cancelled); + bool OptimisedSolve(const eh_HashState& base_state, + const std::function)> validBlock, + const std::function cancelled); +-#endif + bool IsValidSolution(const eh_HashState& base_state, std::vector soln); + }; + +@@ -213,7 +211,6 @@ static Equihash<48,5> Eh48_5; + throw std::invalid_argument("Unsupported Equihash parameters"); \ + } + +-#ifdef ENABLE_MINING + inline bool EhBasicSolve(unsigned int n, unsigned int k, const eh_HashState& base_state, + const std::function)> validBlock, + const std::function cancelled) +@@ -261,7 +258,6 @@ inline bool EhOptimisedSolveUncancellable(unsigned int n, unsigned int k, const + return EhOptimisedSolve(n, k, base_state, validBlock, + [](EhSolverCancelCheck pos) { return false; }); + } +-#endif // ENABLE_MINING + + #define EhIsValidSolution(n, k, base_state, soln, ret) \ + if (n == 96 && k == 3) { \ +@@ -276,4 +272,4 @@ inline bool EhOptimisedSolveUncancellable(unsigned int n, unsigned int k, const + throw std::invalid_argument("Unsupported Equihash parameters"); \ + } + +-#endif // BITCOIN_EQUIHASH_H ++#endif // BITCOIN_EQUIHASH_H +\ No newline at end of file +diff --git a/src/gtest/test_deprecation.cpp b/src/gtest/test_deprecation.cpp +index 72d98cf91..c44b810f1 100644 +--- a/src/gtest/test_deprecation.cpp ++++ b/src/gtest/test_deprecation.cpp +@@ -24,7 +24,7 @@ static bool ThreadSafeMessageBox(MockUIInterface *mock, + const std::string& caption, + unsigned int style) + { +- mock->ThreadSafeMessageBox(message, caption, style); ++ return mock->ThreadSafeMessageBox(message, caption, style); + } + + class DeprecationTest : public ::testing::Test { +diff --git a/src/paymentdisclosure.h b/src/paymentdisclosure.h +index d973c08ce..ee4a7c47c 100644 +--- a/src/paymentdisclosure.h ++++ b/src/paymentdisclosure.h +@@ -73,7 +73,7 @@ struct PaymentDisclosurePayload { + uint8_t version; // 0 = experimental, 1 = first production version, etc. + uint256 esk; // zcash/NoteEncryption.cpp + uint256 txid; // primitives/transaction.h +- size_t js; // Index into CTransaction.vjoinsplit ++ uint64_t js; // Index into CTransaction.vjoinsplit + uint8_t n; // Index into JSDescription fields of length ZC_NUM_JS_OUTPUTS + libzcash::PaymentAddress zaddr; // zcash/Address.hpp + std::string message; // parameter to RPC call +diff --git a/src/serialize.h b/src/serialize.h +index f776d6d99..d6daf4dd4 100644 +--- a/src/serialize.h ++++ b/src/serialize.h +@@ -649,7 +649,11 @@ void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVers + { + WriteCompactSize(os, v.size()); + for (typename std::vector::const_iterator vi = v.begin(); vi != v.end(); ++vi) ++#if defined(__APPLE__) ++ ::Serialize(os, static_cast(*vi), nType, nVersion); ++#else + ::Serialize(os, (*vi), nType, nVersion); ++#endif + } + + template +diff --git a/src/snark/Makefile b/src/snark/Makefile +index b865f992f..f7f76a40a 100644 +--- a/src/snark/Makefile ++++ b/src/snark/Makefile +@@ -141,7 +141,7 @@ ifeq ($(PROFILE_OP_COUNTS),1) + endif + + ifeq ($(STATIC),1) +- CXXFLAGS += -static -DSTATIC ++ CXXFLAGS += -DSTATIC + else + CXXFLAGS += -fPIC + endif +diff --git a/src/snark/libsnark/common/profiling.cpp b/src/snark/libsnark/common/profiling.cpp +index d227203a0..4c06cd34f 100644 +--- a/src/snark/libsnark/common/profiling.cpp ++++ b/src/snark/libsnark/common/profiling.cpp +@@ -26,6 +26,11 @@ + #include + #endif + ++#ifdef __APPLE__ ++#include ++#include ++#endif ++ + namespace libsnark { + + long long get_nsec_time() +@@ -38,10 +43,20 @@ long long get_nsec_time() + long long get_nsec_cpu_time() + { + ::timespec ts; ++#ifdef __APPLE__ ++ /* from latest Apple Libc: clock_gettime(CLOCK_PROCESS_CPUTIME_ID) ++ https://opensource.apple.com/source/Libc/Libc-1244.1.7/gen/clock_gettime.c.auto.html */ ++ struct rusage ru; ++ if (getrusage(RUSAGE_SELF, &ru)) ++ throw ::std::runtime_error("getrusage(RUSAGE_SELF) to get cpu time failed"); ++ timeradd(&ru.ru_utime, &ru.ru_stime, &ru.ru_utime); ++ TIMEVAL_TO_TIMESPEC(&ru.ru_utime, &ts); ++#else + if ( ::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) ) + throw ::std::runtime_error("clock_gettime(CLOCK_PROCESS_CPUTIME_ID) failed"); + // If we expected this to work, don't silently ignore failures, because that would hide the problem and incur an unnecessarily system-call overhead. So if we ever observe this exception, we should probably add a suitable #ifdef . + //TODO: clock_gettime(CLOCK_PROCESS_CPUTIME_ID) is not supported by native Windows. What about Cygwin? Should we #ifdef on CLOCK_PROCESS_CPUTIME_ID or on __linux__? ++#endif + return ts.tv_sec * 1000000000ll + ts.tv_nsec; + } + +diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp +index 18b687dbf..04fccfe81 100644 +--- a/src/test/rpc_wallet_tests.cpp ++++ b/src/test/rpc_wallet_tests.cpp +@@ -47,6 +47,13 @@ bool find_error(const UniValue& objError, const std::string& expected) { + return find_value(objError, "message").get_str().find(expected) != string::npos; + } + ++static UniValue ValueFromString(const std::string &str) ++{ ++ UniValue value; ++ BOOST_CHECK(value.setNumStr(str)); ++ return value; ++} ++ + BOOST_FIXTURE_TEST_SUITE(rpc_wallet_tests, TestingSetup) + + BOOST_AUTO_TEST_CASE(rpc_addmultisig) +@@ -1078,14 +1085,14 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) + CTransaction tx = proxy.getTx(); + BOOST_CHECK(tx.vout.size() == 0); + +- CAmount amount = 123.456; ++ CAmount amount = AmountFromValue(ValueFromString("123.456")); + proxy.add_taddr_change_output_to_tx(amount); + tx = proxy.getTx(); + BOOST_CHECK(tx.vout.size() == 1); + CTxOut out = tx.vout[0]; + BOOST_CHECK_EQUAL(out.nValue, amount); + +- amount = 1.111; ++ amount = AmountFromValue(ValueFromString("1.111")); + proxy.add_taddr_change_output_to_tx(amount); + tx = proxy.getTx(); + BOOST_CHECK(tx.vout.size() == 2); +diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h +index dfc84f921..a6053356b 100644 +--- a/src/univalue/include/univalue.h ++++ b/src/univalue/include/univalue.h +@@ -25,6 +25,9 @@ public: + typ = initialType; + val = initialStr; + } ++ UniValue(size_t val_) { ++ setInt(val_); ++ } + UniValue(uint64_t val_) { + setInt(val_); + } +@@ -54,6 +57,7 @@ public: + bool setNull(); + bool setBool(bool val); + bool setNumStr(const std::string& val); ++ bool setInt(size_t val_); + bool setInt(uint64_t val); + bool setInt(int64_t val); + bool setInt(int val_) { return setInt((int64_t)val_); } +@@ -92,6 +96,10 @@ public: + std::string s(val_); + return push_back(s); + } ++ bool push_back(size_t val_) { ++ UniValue tmpVal(val_); ++ return push_back(tmpVal); ++ } + bool push_back(uint64_t val_) { + UniValue tmpVal(val_); + return push_back(tmpVal); +@@ -190,6 +198,13 @@ static inline std::pair Pair(const char *cKey, std::string + return std::make_pair(key, uVal); + } + ++static inline std::pair Pair(const char *cKey, size_t sizeVal) ++{ ++ std::string key(cKey); ++ UniValue uVal(sizeVal); ++ return std::make_pair(key, uVal); ++} ++ + static inline std::pair Pair(const char *cKey, uint64_t u64Val) + { + std::string key(cKey); +diff --git a/src/univalue/lib/univalue.cpp b/src/univalue/lib/univalue.cpp +index 47ca7aca7..b6c205f16 100644 +--- a/src/univalue/lib/univalue.cpp ++++ b/src/univalue/lib/univalue.cpp +@@ -119,6 +119,15 @@ bool UniValue::setNumStr(const string& val_) + return true; + } + ++bool UniValue::setInt(size_t val_) ++{ ++ ostringstream oss; ++ ++ oss << val_; ++ ++ return setNumStr(oss.str()); ++} ++ + bool UniValue::setInt(uint64_t val_) + { + ostringstream oss; +diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h +index a954b5f31..838b35d26 100644 +--- a/src/wallet/wallet.h ++++ b/src/wallet/wallet.h +@@ -159,7 +159,7 @@ public: + // Transaction hash + uint256 hash; + // Index into CTransaction.vjoinsplit +- size_t js; ++ uint64_t js; + // Index into JSDescription fields of length ZC_NUM_JS_OUTPUTS + uint8_t n; + +diff --git a/zcutil/build.sh b/zcutil/build.sh +index 810872a40..1a89067bc 100755 +--- a/zcutil/build.sh ++++ b/zcutil/build.sh +@@ -132,5 +132,5 @@ ld -v + + HOST="$HOST" BUILD="$BUILD" NO_RUST="$RUST_ARG" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 + ./autogen.sh +-CC="$CC" CXX="$CXX" ./configure --prefix="${PREFIX}" --host="$HOST" --build="$BUILD" "$RUST_ARG" "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" "$LIBS_ARG" --enable-werror CXXFLAGS='-g' ++CC="$CC" CXX="$CXX" ./configure --prefix="${PREFIX}" --host="$HOST" --build="$BUILD" "$RUST_ARG" "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" "$LIBS_ARG" CXXFLAGS='-g' + "$MAKE" "$@" V=1