Skip to content

Commit

Permalink
Make Rust compilation mandatory
Browse files Browse the repository at this point in the history
The temporary integration check in CheckEquihashSolution() remains, until we
have "real" Rust code to integrate.

Closes zcash#2688.
  • Loading branch information
str4d committed Mar 28, 2018
1 parent a08ad2b commit d9cd254
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 43 deletions.
23 changes: 1 addition & 22 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ AC_ARG_ENABLE([mining],
[enable_mining=$enableval],
[enable_mining=yes])

AC_ARG_ENABLE([rust],
[AS_HELP_STRING([--enable-rust],
[enable rust (default is yes)])],
[enable_rust=$enableval],
[enable_rust=yes])

AC_ARG_ENABLE([proton],
[AS_HELP_STRING([--disable-proton],
[disable Proton (AMQP messaging)])],
Expand Down Expand Up @@ -728,10 +722,7 @@ AC_CHECK_LIB([gmp],[[__gmpn_sub_n]],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing
AC_CHECK_HEADER([gmpxx.h],,AC_MSG_ERROR(libgmpxx headers missing))
AC_CHECK_LIB([gmpxx],[main],GMPXX_LIBS=-lgmpxx, [AC_MSG_ERROR(libgmpxx missing)])

RUST_LIBS=""
if test x$enable_rust != xno; then
RUST_LIBS="-lrustzcash"
fi
RUST_LIBS="-lrustzcash"

dnl Check for OpenMP support
AX_OPENMP(
Expand Down Expand Up @@ -815,16 +806,6 @@ else
AC_MSG_RESULT(no)
fi

dnl enable rust
AC_MSG_CHECKING([if rust should be enabled])
if test x$enable_rust != xno; then
AC_MSG_RESULT(yes)
AC_DEFINE(ENABLE_RUST, 1, [Define to 1 to enable Rust language dependent functions])

else
AC_MSG_RESULT(no)
fi

AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"])

AM_CONDITIONAL([ENABLE_PROTON], [test "x$use_proton" = "xyes"])
Expand Down Expand Up @@ -854,7 +835,6 @@ AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes])
AM_CONDITIONAL([ENABLE_MINING],[test x$enable_mining = xyes])
AM_CONDITIONAL([ENABLE_RUST],[test x$enable_rust = xyes])
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
Expand Down Expand Up @@ -947,7 +927,6 @@ esac
echo
echo "Options used to compile and link:"
echo " with wallet = $enable_wallet"
echo " with rust = $enable_rust"
echo " with proton = $use_proton"
echo " with zmq = $use_zmq"
echo " with test = $use_tests"
Expand Down
3 changes: 1 addition & 2 deletions depends/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ include builders/$(build_os).mk
include builders/default.mk
include packages/packages.mk

rust_packages_$(NO_RUST) = $(rust_packages)
wallet_packages_$(NO_WALLET) = $(wallet_packages)
proton_packages_$(NO_PROTON) = $(proton_packages)

packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(rust_packages_) $(proton_packages_) $(wallet_packages_)
packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(rust_packages) $(proton_packages_) $(wallet_packages_)
native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages)
all_packages = $(packages) $(native_packages)

Expand Down
4 changes: 0 additions & 4 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

#include "sodium.h"

#ifdef ENABLE_RUST
#include "librustzcash.h"
#endif // ENABLE_RUST

unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
{
Expand Down Expand Up @@ -100,13 +98,11 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
// H(I||V||...
crypto_generichash_blake2b_update(&state, (unsigned char*)&ss[0], ss.size());

#ifdef ENABLE_RUST
// Ensure that our Rust interactions are working in production builds. This is
// temporary and should be removed.
{
assert(librustzcash_xor(0x0f0f0f0f0f0f0f0f, 0x1111111111111111) == 0x1e1e1e1e1e1e1e1e);
}
#endif // ENABLE_RUST

bool isValid;
EhIsValidSolution(n, k, state, pblock->nSolution, isValid);
Expand Down
19 changes: 4 additions & 15 deletions zcutil/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Usage:
$0 --help
Show this help message and exit.
$0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ --disable-rust ] [ --enable-proton ] [ --disable-libs ] [ MAKEARGS... ]
$0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ --enable-proton ] [ --disable-libs ] [ MAKEARGS... ]
Build Zcash and most of its transitive dependencies from
source. MAKEARGS are applied to both dependencies and Zcash itself.
Expand All @@ -65,12 +65,9 @@ $0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ --disable-rust ]
If --disable-mining is passed, Zcash is configured to not build any mining
code. It must be passed after the test arguments, if present.
If --disable-rust is passed, Zcash is configured to not build any Rust language
assets. It must be passed after test/mining arguments, if present.
If --enable-proton is passed, Zcash is configured to build the Apache Qpid Proton
library required for AMQP support. This library is not built by default.
It must be passed after the test/mining/Rust arguments, if present.
It must be passed after the test/mining arguments, if present.
If --disable-libs is passed, Zcash is configured to not build any libraries like
'libzcashconsensus'.
Expand Down Expand Up @@ -103,14 +100,6 @@ then
shift
fi

# If --disable-rust is the next argument, disable Rust code:
RUST_ARG=''
if [ "x${1:-}" = 'x--disable-rust' ]
then
RUST_ARG='--enable-rust=no'
shift
fi

# If --enable-proton is the next argument, enable building Proton code:
PROTON_ARG='--enable-proton=no'
if [ "x${1:-}" = 'x--enable-proton' ]
Expand All @@ -135,7 +124,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
HOST="$HOST" BUILD="$BUILD" 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" $CONFIGURE_FLAGS --enable-werror CXXFLAGS='-g'
CC="$CC" CXX="$CXX" ./configure --prefix="${PREFIX}" --host="$HOST" --build="$BUILD" "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" "$LIBS_ARG" $CONFIGURE_FLAGS --enable-werror CXXFLAGS='-g'
"$MAKE" "$@" V=1

0 comments on commit d9cd254

Please sign in to comment.