aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormerge-script <fanquake@gmail.com>2024-07-17 16:58:54 +0100
committermerge-script <fanquake@gmail.com>2024-07-17 16:58:54 +0100
commit3679fa167f7d198d9287f05f210f03e83b76f3b8 (patch)
tree4c421f1fe94fba7c5f0ca7ce7b68a7ed8edd36f3 /src
parent5f5862f3820a7618522970e32d4011a57a5cc87b (diff)
parentd440f13db02c82c842000abe4fe4d0c721a4ad3b (diff)
downloadbitcoin-3679fa167f7d198d9287f05f210f03e83b76f3b8.tar.xz
Merge bitcoin/bitcoin#28893: Fix SSE4.1-related issues
d440f13db02c82c842000abe4fe4d0c721a4ad3b crypto: Guard code with `ENABLE_SSE41` macro (Hennadii Stepanov) 6ec1ca7c85a4009b77e149a798a331592b96ea42 build: Fix test for SSE4.1 intrinsics (Hennadii Stepanov) Pull request description: 1. Fix the test for SSE4.1 intrinsics during build system configuration, which currently can be false positive, for example, when `CXXFLAGS="-mno-sse4.1"` provided. This PR fixes the test by adding the `_mm_blend_epi16` SSE4.1 function used in our codebase. 2. Guard `sha_x86_shani.cpp` code with `ENABLE_SSE41` macro as it uses the `_mm_blend_epi16` function from the SSE4.1 instruction set. It is possible that SHA-NI is enabled even when SSE4.1 is disabled, which causes compile errors in the master branch. Closes https://github.com/bitcoin/bitcoin/issues/28864. ACKs for top commit: sipa: utACK d440f13db02c82c842000abe4fe4d0c721a4ad3b willcl-ark: tACK d440f13db02c82c842000abe4fe4d0c721a4ad3b theuni: utACK d440f13db02c82c842000abe4fe4d0c721a4ad3b Tree-SHA512: a6e1e8c94e1b94874ff51846815ef445e6135cbdb01b08eb695b3548115f2340dd835ebe53673ae46a553fe6be4815e68d8642c34235dd7af5106c4b7c9ea6f3
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am10
-rw-r--r--src/crypto/sha256.cpp2
-rw-r--r--src/crypto/sha256_x86_shani.cpp2
3 files changed, 7 insertions, 7 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0ae5effdbe..72dd942c40 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -51,15 +51,15 @@ LIBBITCOIN_CRYPTO = $(LIBBITCOIN_CRYPTO_BASE)
if ENABLE_SSE41
LIBBITCOIN_CRYPTO_SSE41 = crypto/libbitcoin_crypto_sse41.la
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_SSE41)
+if ENABLE_X86_SHANI
+LIBBITCOIN_CRYPTO_X86_SHANI = crypto/libbitcoin_crypto_x86_shani.la
+LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_X86_SHANI)
+endif
endif
if ENABLE_AVX2
LIBBITCOIN_CRYPTO_AVX2 = crypto/libbitcoin_crypto_avx2.la
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_AVX2)
endif
-if ENABLE_X86_SHANI
-LIBBITCOIN_CRYPTO_X86_SHANI = crypto/libbitcoin_crypto_x86_shani.la
-LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_X86_SHANI)
-endif
if ENABLE_ARM_SHANI
LIBBITCOIN_CRYPTO_ARM_SHANI = crypto/libbitcoin_crypto_arm_shani.la
LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_ARM_SHANI)
@@ -622,7 +622,7 @@ crypto_libbitcoin_crypto_x86_shani_la_LDFLAGS = $(AM_LDFLAGS) -static
crypto_libbitcoin_crypto_x86_shani_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -static
crypto_libbitcoin_crypto_x86_shani_la_CPPFLAGS = $(AM_CPPFLAGS)
crypto_libbitcoin_crypto_x86_shani_la_CXXFLAGS += $(X86_SHANI_CXXFLAGS)
-crypto_libbitcoin_crypto_x86_shani_la_CPPFLAGS += -DENABLE_X86_SHANI
+crypto_libbitcoin_crypto_x86_shani_la_CPPFLAGS += -DENABLE_SSE41 -DENABLE_X86_SHANI
crypto_libbitcoin_crypto_x86_shani_la_SOURCES = crypto/sha256_x86_shani.cpp
# See explanation for -static in crypto_libbitcoin_crypto_base_la's LDFLAGS and
diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp
index c883bd2f03..89d7204808 100644
--- a/src/crypto/sha256.cpp
+++ b/src/crypto/sha256.cpp
@@ -621,7 +621,7 @@ std::string SHA256AutoDetect(sha256_implementation::UseImplementation use_implem
}
}
-#if defined(ENABLE_X86_SHANI)
+#if defined(ENABLE_SSE41) && defined(ENABLE_X86_SHANI)
if (have_x86_shani) {
Transform = sha256_x86_shani::Transform;
TransformD64 = TransformD64Wrapper<sha256_x86_shani::Transform>;
diff --git a/src/crypto/sha256_x86_shani.cpp b/src/crypto/sha256_x86_shani.cpp
index 79871bfcc1..7471828193 100644
--- a/src/crypto/sha256_x86_shani.cpp
+++ b/src/crypto/sha256_x86_shani.cpp
@@ -6,7 +6,7 @@
// Written and placed in public domain by Jeffrey Walton.
// Based on code from Intel, and by Sean Gulley for the miTLS project.
-#ifdef ENABLE_X86_SHANI
+#if defined(ENABLE_SSE41) && defined(ENABLE_X86_SHANI)
#include <stdint.h>
#include <immintrin.h>