Skip to content

Commit

Permalink
crypto: added library for ARMv8.2 SHA-512 intrinsics
Browse files Browse the repository at this point in the history
added LIBDOGECOIN_CRYPTO_BASE variables
  • Loading branch information
edtubbs committed Apr 3, 2024
1 parent a12b0aa commit 63c3266
Show file tree
Hide file tree
Showing 4 changed files with 336 additions and 237 deletions.
17 changes: 10 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ if test x$armv8_crypto = xyes; then
AC_MSG_CHECKING([whether to build with armv8 crypto])
AC_MSG_RESULT(yes)
AC_DEFINE(USE_ARMV8, 1, [Define this symbol if armv8 crypto works])
CXXFLAGS="$CXXFLAGS -march=armv8-a+crypto"
CPPFLAGS="$CPPFLAGS -march=armv8-a+crypto"
fi

if test x$armv82_crypto = xyes; then
Expand All @@ -798,12 +798,12 @@ if test x$armv82_crypto = xyes; then
AC_MSG_CHECKING([whether to build with armv8.2-a crypto])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t x; x = vsha512su0q_u64(x, x);]])],
[AC_DEFINE(USE_ARMV82, 1, [Define this symbol if armv8.2 crypto works])
ARM_CXXFLAGS="-march=armv8.2-a+crypto+sha3"]
ARMV82_CXXFLAGS="-march=armv8.2-a+crypto+sha3"]
AC_MSG_RESULT(yes),
[AC_MSG_WARN([sha512 missing, using armv8.2-a crypto without sha512])
ARM_CXXFLAGS="-march=armv8.2-a+crypto"
AC_DEFINE(USE_ARMV8)])
CPPFLAGS=${CPPFLAGS/"-march=armv8.2-a+crypto+sha3"/}
[AC_MSG_WARN([sha512 missing, using armv8-a crypto without sha512])
AC_DEFINE(USE_ARMV8, 1, [Define this symbol if armv8 crypto works])
CPPFLAGS=${CPPFLAGS/"-march=armv8.2-a+crypto+sha3"/}
CPPFLAGS+="-march=armv8-a+crypto"])
fi

if test x$use_pkgconfig = xyes; then
Expand Down Expand Up @@ -1130,6 +1130,7 @@ 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])
AM_CONDITIONAL([USE_ARMV82], [test x$armv82_crypto = xyes])

AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version])
AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version])
Expand Down Expand Up @@ -1160,7 +1161,7 @@ AC_SUBST(BITCOIN_CLI_NAME)
AC_SUBST(BITCOIN_TX_NAME)

AC_SUBST(RELDFLAGS)
AC_SUBST(ARM_CXXFLAGS)
AC_SUBST(ARMV82_CXXFLAGS)
AC_SUBST(COMPAT_LDFLAGS)
AC_SUBST(ERROR_CXXFLAGS)
AC_SUBST(HARDENED_CXXFLAGS)
Expand Down Expand Up @@ -1262,6 +1263,8 @@ if test x$allow_experimental = xyes; then
echo " AVX2 crypto = $intel_avx2"
echo " ARMv8 crypto = $armv8_crypto"
echo " ARMv82 crypto = $armv82_crypto"
echo
echo " ARMV82_CXXFLAGS = $ARMV82_CXXFLAGS"
fi
echo
echo " target os = $TARGET_OS"
Expand Down
23 changes: 17 additions & 6 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ LIBDOGECOIN_COMMON=libdogecoin_common.a
LIBDOGECOIN_CONSENSUS=libdogecoin_consensus.a
LIBDOGECOIN_CLI=libdogecoin_cli.a
LIBDOGECOIN_UTIL=libdogecoin_util.a
LIBDOGECOIN_CRYPTO=crypto/libdogecoin_crypto.a
LIBDOGECOIN_CRYPTO_BASE=crypto/libdogecoin_crypto_base.a
LIBDOGECOIN_CRYPTO=$(LIBDOGECOIN_CRYPTO_BASE)
LIBDOGECOINQT=qt/libdogecoinqt.a
LIBSECP256K1=secp256k1/libsecp256k1.la

Expand All @@ -42,6 +43,10 @@ endif
if ENABLE_WALLET
LIBDOGECOIN_WALLET=libdogecoin_wallet.a
endif
if USE_ARMV82
LIBDOGECOIN_CRYPTO_ARMV82=crypto/libdogecoin_crypto_armv82.a
LIBDOGECOIN_CRYPTO += $(LIBDOGECOIN_CRYPTO_ARMV82)
endif

$(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*)
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
Expand Down Expand Up @@ -251,9 +256,9 @@ libdogecoin_wallet_a_SOURCES = \
$(BITCOIN_CORE_H)

# crypto primitives library
crypto_libdogecoin_crypto_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_CONFIG_INCLUDES)
crypto_libdogecoin_crypto_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) $(ARM_CXXFLAGS)
crypto_libdogecoin_crypto_a_SOURCES = \
crypto_libdogecoin_crypto_base_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_CONFIG_INCLUDES)
crypto_libdogecoin_crypto_base_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
crypto_libdogecoin_crypto_base_a_SOURCES = \
crypto/aes.cpp \
crypto/aes.h \
crypto/common.h \
Expand All @@ -274,7 +279,13 @@ crypto_libdogecoin_crypto_a_SOURCES = \

# only include SSE2 scrypt sources if USE_SCRYPT_SSE2 is defined
if USE_SCRYPT_SSE2
crypto_libdogecoin_crypto_a_SOURCES += crypto/scrypt-sse2.cpp
crypto_libdogecoin_crypto_base_a_SOURCES += crypto/scrypt-sse2.cpp
endif

# only include ARMv8.2 sha512 sources if USE_ARMV82 is defined
if USE_ARMV82
crypto_libdogecoin_crypto_armv82_a_CXXFLAGS = $(ARMV82_CXXFLAGS)
crypto_libdogecoin_crypto_armv82_a_SOURCES = crypto/sha512-armv82.cpp
endif

# consensus: shared between all executables that validate any consensus rules.
Expand Down Expand Up @@ -450,7 +461,7 @@ dogecoin_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
# bitcoinconsensus library #
if BUILD_BITCOIN_LIBS
include_HEADERS = script/bitcoinconsensus.h
libdogecoinconsensus_la_SOURCES = $(crypto_libdogecoin_crypto_a_SOURCES) $(libdogecoin_consensus_a_SOURCES)
libdogecoinconsensus_la_SOURCES = $(crypto_libdogecoin_crypto_base_a_SOURCES) $(libdogecoin_consensus_a_SOURCES)

if GLIBC_BACK_COMPAT
libdogecoinconsensus_la_SOURCES += compat/glibc_compat.cpp
Expand Down
Loading

0 comments on commit 63c3266

Please sign in to comment.