From a8e2342dca5e9cd771d883d4906cce6d2bb3de69 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 18 May 2025 16:10:19 +0100 Subject: [PATCH 1/5] cmake: Remove `ENABLE_SSE41` from `bitcoin-build-config.h` `ENABLE_SSE41` is already conditionally defined for the `bitcoin_crypto` target, so defining it in `bitcoin-build-config.h` is redundant. --- cmake/bitcoin-build-config.h.in | 3 --- cmake/introspection.cmake | 1 - test/lint/test_runner/src/main.rs | 1 - 3 files changed, 5 deletions(-) diff --git a/cmake/bitcoin-build-config.h.in b/cmake/bitcoin-build-config.h.in index 4783209ef77..fee037e1ba7 100644 --- a/cmake/bitcoin-build-config.h.in +++ b/cmake/bitcoin-build-config.h.in @@ -38,9 +38,6 @@ /* Define if external signer support is enabled */ #cmakedefine ENABLE_EXTERNAL_SIGNER 1 -/* Define this symbol to build code that uses SSE4.1 intrinsics */ -#cmakedefine ENABLE_SSE41 1 - /* Define to 1 to enable tracepoints for Userspace, Statically Defined Tracing */ #cmakedefine ENABLE_TRACING 1 diff --git a/cmake/introspection.cmake b/cmake/introspection.cmake index 0efcf7c63c7..00b15788739 100644 --- a/cmake/introspection.cmake +++ b/cmake/introspection.cmake @@ -170,7 +170,6 @@ if(NOT MSVC) " HAVE_SSE41 CXXFLAGS ${SSE41_CXXFLAGS} ) - set(ENABLE_SSE41 ${HAVE_SSE41}) # Check for AVX2 intrinsics. set(AVX2_CXXFLAGS -mavx -mavx2) diff --git a/test/lint/test_runner/src/main.rs b/test/lint/test_runner/src/main.rs index 073e2dd44cd..be551d627ca 100644 --- a/test/lint/test_runner/src/main.rs +++ b/test/lint/test_runner/src/main.rs @@ -620,7 +620,6 @@ fn lint_includes_build_config() -> LintResult { // these cppflags manually. ":(exclude)src/crypto/sha256_arm_shani.cpp", ":(exclude)src/crypto/sha256_avx2.cpp", - ":(exclude)src/crypto/sha256_sse41.cpp", ":(exclude)src/crypto/sha256_x86_shani.cpp", ]), ) From 8689628e2e36d70aed16f4c44d6503888600ab90 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 18 May 2025 16:12:01 +0100 Subject: [PATCH 2/5] cmake: Remove `ENABLE_AVX2` from `bitcoin-build-config.h` `ENABLE_AVX2` is already conditionally defined for the `bitcoin_crypto` target, so defining it in `bitcoin-build-config.h` is redundant. --- cmake/bitcoin-build-config.h.in | 3 --- cmake/introspection.cmake | 1 - test/lint/test_runner/src/main.rs | 1 - 3 files changed, 5 deletions(-) diff --git a/cmake/bitcoin-build-config.h.in b/cmake/bitcoin-build-config.h.in index fee037e1ba7..c79f5227c28 100644 --- a/cmake/bitcoin-build-config.h.in +++ b/cmake/bitcoin-build-config.h.in @@ -32,9 +32,6 @@ /* Define this symbol to build code that uses ARMv8 SHA-NI intrinsics */ #cmakedefine ENABLE_ARM_SHANI 1 -/* Define this symbol to build code that uses AVX2 intrinsics */ -#cmakedefine ENABLE_AVX2 1 - /* Define if external signer support is enabled */ #cmakedefine ENABLE_EXTERNAL_SIGNER 1 diff --git a/cmake/introspection.cmake b/cmake/introspection.cmake index 00b15788739..271dfcd0f84 100644 --- a/cmake/introspection.cmake +++ b/cmake/introspection.cmake @@ -184,7 +184,6 @@ if(NOT MSVC) " HAVE_AVX2 CXXFLAGS ${AVX2_CXXFLAGS} ) - set(ENABLE_AVX2 ${HAVE_AVX2}) # Check for x86 SHA-NI intrinsics. set(X86_SHANI_CXXFLAGS -msse4 -msha) diff --git a/test/lint/test_runner/src/main.rs b/test/lint/test_runner/src/main.rs index be551d627ca..62b7b2389f3 100644 --- a/test/lint/test_runner/src/main.rs +++ b/test/lint/test_runner/src/main.rs @@ -619,7 +619,6 @@ fn lint_includes_build_config() -> LintResult { // These are exceptions which don't use bitcoin-build-config.h, rather CMakeLists.txt adds // these cppflags manually. ":(exclude)src/crypto/sha256_arm_shani.cpp", - ":(exclude)src/crypto/sha256_avx2.cpp", ":(exclude)src/crypto/sha256_x86_shani.cpp", ]), ) From 1e900528d2450177a50eed15b36d2e6c226c2f4e Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 18 May 2025 16:13:32 +0100 Subject: [PATCH 3/5] cmake: Remove `ENABLE_X86_SHANI` from `bitcoin-build-config.h` `ENABLE_X86_SHANI` is already conditionally defined for the `bitcoin_crypto` target, so defining it in `bitcoin-build-config.h` is redundant. --- cmake/bitcoin-build-config.h.in | 3 --- cmake/introspection.cmake | 1 - test/lint/test_runner/src/main.rs | 1 - 3 files changed, 5 deletions(-) diff --git a/cmake/bitcoin-build-config.h.in b/cmake/bitcoin-build-config.h.in index c79f5227c28..a3710a834ad 100644 --- a/cmake/bitcoin-build-config.h.in +++ b/cmake/bitcoin-build-config.h.in @@ -42,9 +42,6 @@ /* Define to 1 to enable wallet functions. */ #cmakedefine ENABLE_WALLET 1 -/* Define this symbol to build code that uses x86 SHA-NI intrinsics */ -#cmakedefine ENABLE_X86_SHANI 1 - /* Define to 1 if you have the declaration of `fork', and to 0 if you don't. */ #cmakedefine01 HAVE_DECL_FORK diff --git a/cmake/introspection.cmake b/cmake/introspection.cmake index 271dfcd0f84..585a6bcb0a0 100644 --- a/cmake/introspection.cmake +++ b/cmake/introspection.cmake @@ -200,7 +200,6 @@ if(NOT MSVC) " HAVE_X86_SHANI CXXFLAGS ${X86_SHANI_CXXFLAGS} ) - set(ENABLE_X86_SHANI ${HAVE_X86_SHANI}) # Check for ARMv8 SHA-NI intrinsics. set(ARM_SHANI_CXXFLAGS -march=armv8-a+crypto) diff --git a/test/lint/test_runner/src/main.rs b/test/lint/test_runner/src/main.rs index 62b7b2389f3..d87fab833e1 100644 --- a/test/lint/test_runner/src/main.rs +++ b/test/lint/test_runner/src/main.rs @@ -619,7 +619,6 @@ fn lint_includes_build_config() -> LintResult { // These are exceptions which don't use bitcoin-build-config.h, rather CMakeLists.txt adds // these cppflags manually. ":(exclude)src/crypto/sha256_arm_shani.cpp", - ":(exclude)src/crypto/sha256_x86_shani.cpp", ]), ) .expect("grep failed"); From 028476e71fdcca5ea780fcfecfa7cf06c323beab Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 18 May 2025 16:15:46 +0100 Subject: [PATCH 4/5] cmake: Remove `ENABLE_ARM_SHANI` from `bitcoin-build-config.h` `ENABLE_ARM_SHANI` is already conditionally defined for the `bitcoin_crypto` target, so defining it in `bitcoin-build-config.h` is redundant. --- cmake/bitcoin-build-config.h.in | 3 --- cmake/introspection.cmake | 1 - src/crypto/sha256.cpp | 2 -- test/lint/test_runner/src/main.rs | 7 +------ 4 files changed, 1 insertion(+), 12 deletions(-) diff --git a/cmake/bitcoin-build-config.h.in b/cmake/bitcoin-build-config.h.in index a3710a834ad..bf3ddcd7ff6 100644 --- a/cmake/bitcoin-build-config.h.in +++ b/cmake/bitcoin-build-config.h.in @@ -29,9 +29,6 @@ /* Copyright year */ #define COPYRIGHT_YEAR @COPYRIGHT_YEAR@ -/* Define this symbol to build code that uses ARMv8 SHA-NI intrinsics */ -#cmakedefine ENABLE_ARM_SHANI 1 - /* Define if external signer support is enabled */ #cmakedefine ENABLE_EXTERNAL_SIGNER 1 diff --git a/cmake/introspection.cmake b/cmake/introspection.cmake index 585a6bcb0a0..fb94a120553 100644 --- a/cmake/introspection.cmake +++ b/cmake/introspection.cmake @@ -217,5 +217,4 @@ if(NOT MSVC) " HAVE_ARM_SHANI CXXFLAGS ${ARM_SHANI_CXXFLAGS} ) - set(ENABLE_ARM_SHANI ${HAVE_ARM_SHANI}) endif() diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp index 09c5d3123e8..902ebf18a6f 100644 --- a/src/crypto/sha256.cpp +++ b/src/crypto/sha256.cpp @@ -2,8 +2,6 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include // IWYU pragma: keep - #include #include diff --git a/test/lint/test_runner/src/main.rs b/test/lint/test_runner/src/main.rs index d87fab833e1..c2f82573352 100644 --- a/test/lint/test_runner/src/main.rs +++ b/test/lint/test_runner/src/main.rs @@ -614,12 +614,7 @@ fn lint_includes_build_config() -> LintResult { "*.cpp", "*.h", ]) - .args(get_pathspecs_default_excludes()) - .args([ - // These are exceptions which don't use bitcoin-build-config.h, rather CMakeLists.txt adds - // these cppflags manually. - ":(exclude)src/crypto/sha256_arm_shani.cpp", - ]), + .args(get_pathspecs_default_excludes()), ) .expect("grep failed"); git() From 800b7cc42ca63f2a6b245a4d327c7092289da6e1 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 18 May 2025 14:45:55 +0100 Subject: [PATCH 5/5] cmake: Add missed `SSE41_CXXFLAGS` --- src/crypto/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt index 1109806a776..92653ade5a7 100644 --- a/src/crypto/CMakeLists.txt +++ b/src/crypto/CMakeLists.txt @@ -47,7 +47,7 @@ if(HAVE_SSE41 AND HAVE_X86_SHANI) target_compile_definitions(bitcoin_crypto PRIVATE ENABLE_SSE41 ENABLE_X86_SHANI) target_sources(bitcoin_crypto PRIVATE sha256_x86_shani.cpp) set_property(SOURCE sha256_x86_shani.cpp PROPERTY - COMPILE_OPTIONS ${X86_SHANI_CXXFLAGS} + COMPILE_OPTIONS ${SSE41_CXXFLAGS} ${X86_SHANI_CXXFLAGS} ) endif()