Skip to content

Commit

Permalink
crypto: added ARMv8.2 SHA-512 intrinsics to library
Browse files Browse the repository at this point in the history
updated to build a shared library archive
  • Loading branch information
edtubbs committed Apr 9, 2024
1 parent a12b0aa commit a8049b6
Show file tree
Hide file tree
Showing 4 changed files with 333 additions and 240 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: 14 additions & 9 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ 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=crypto/libdogecoin_crypto.la
LIBDOGECOINQT=qt/libdogecoinqt.a
LIBSECP256K1=secp256k1/libsecp256k1.la

Expand All @@ -49,7 +49,6 @@ $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*)
# Make is not made aware of per-object dependencies to avoid limiting building parallelization
# But to build the less dependent modules first, we manually select their order here:
EXTRA_LIBRARIES += \
$(LIBDOGECOIN_CRYPTO) \
$(LIBDOGECOIN_UTIL) \
$(LIBDOGECOIN_COMMON) \
$(LIBDOGECOIN_CONSENSUS) \
Expand All @@ -58,7 +57,7 @@ EXTRA_LIBRARIES += \
$(LIBDOGECOIN_WALLET) \
$(LIBDOGECOIN_ZMQ)

lib_LTLIBRARIES = $(LIBDOGECOINCONSENSUS)
lib_LTLIBRARIES = $(LIBDOGECOINCONSENSUS) $(LIBDOGECOIN_CRYPTO)

bin_PROGRAMS =
noinst_PROGRAMS =
Expand Down Expand Up @@ -251,9 +250,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_la_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_CONFIG_INCLUDES) -static
crypto_libdogecoin_crypto_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -static
crypto_libdogecoin_crypto_la_SOURCES = \
crypto/aes.cpp \
crypto/aes.h \
crypto/common.h \
Expand All @@ -274,7 +273,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_la_SOURCES += crypto/scrypt-sse2.cpp
endif

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

# consensus: shared between all executables that validate any consensus rules.
Expand Down Expand Up @@ -450,14 +455,14 @@ 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 = $(libdogecoin_consensus_a_SOURCES)

if GLIBC_BACK_COMPAT
libdogecoinconsensus_la_SOURCES += compat/glibc_compat.cpp
endif

libdogecoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
libdogecoinconsensus_la_LIBADD = $(LIBSECP256K1)
libdogecoinconsensus_la_LIBADD = $(LIBSECP256K1) $(LIBDOGECOIN_CRYPTO)
libdogecoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
libdogecoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)

Expand Down
Loading

0 comments on commit a8049b6

Please sign in to comment.