build: configure scrypt-sse2 through autoconf

- Add --enable/disable-scrypt-sse2 configuration flag
- use bitcoin-config.h instead of CPPFLAGS, like all other
  features
- make the scrypt.h header guard to be similar to everything else
This commit is contained in:
Patrick Lodder 2021-12-21 19:34:24 -04:00
parent 3a1fd97f9c
commit 79aa24389f
No known key found for this signature in database
GPG Key ID: 2D3A345B98D0DC1F
3 changed files with 24 additions and 3 deletions

View File

@ -177,6 +177,12 @@ AC_ARG_ENABLE([zmq],
[use_zmq=$enableval],
[use_zmq=yes])
AC_ARG_ENABLE([scrypt-sse2],
[AS_HELP_STRING([--enable-scrypt-sse2],
[Build with scrypt sse2 implementation (default is no)])],
[use_scrypt_sse2=$enableval],
[use_scrypt_sse2=no])
AC_ARG_WITH([intel-avx2],
[AS_HELP_STRING([--with-intel-avx2],
[Build with intel avx2 (default is no)])],
@ -725,6 +731,11 @@ BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRA
fi
# Configure Scrypt SSE2
if test x$use_scrypt_sse2 = xyes; then
AC_DEFINE(USE_SSE2, 1, [Define this symbol if SSE2 works])
fi
if test x$intel_avx2 = xyes; then
case $host in
x86_64-*-linux*)
@ -1028,6 +1039,7 @@ AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes])
AM_CONDITIONAL([HARDEN],[test x$use_hardening = xyes])
AM_CONDITIONAL([WORDS_BIGENDIAN],[test x$ac_cv_c_bigendian = xyes])
AM_CONDITIONAL([USE_SCRYPT_SSE2], [test x$use_scrypt_sse2 = xyes])
AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])

View File

@ -267,6 +267,11 @@ crypto_libdogecoin_crypto_a_SOURCES = \
crypto/sha512.cpp \
crypto/sha512.h
# only include SSE2 scrypt sources if USE_SCRYPT_SSE2 is defined
if USE_SCRYPT_SSE2
crypto_libdogecoin_crypto_a_SOURCES += crypto/scrypt-sse2.cpp
endif
# consensus: shared between all executables that validate any consensus rules.
libdogecoin_consensus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libdogecoin_consensus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)

View File

@ -1,8 +1,12 @@
#ifndef SCRYPT_H
#define SCRYPT_H
#ifndef BITCOIN_CRYPTO_SCRYPT_H
#define BITCOIN_CRYPTO_SCRYPT_H
#include <stdlib.h>
#include <stdint.h>
#if defined(HAVE_CONFIG_H)
#include "bitcoin-config.h" // for USE_SSE2
#endif
static const int SCRYPT_SCRATCHPAD_SIZE = 131072 + 63;
void scrypt_1024_1_1_256(const char *input, char *output);
@ -44,4 +48,4 @@ static inline void le32enc(void *pp, uint32_t x)
p[3] = (x >> 24) & 0xff;
}
#endif
#endif
#endif // BITCOIN_CRYPTO_SCRYPT_H