diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f219d364fae2..83616cbbdbb1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,9 +145,7 @@ cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OF if(WITH_QRENCODE) find_package(PkgConfig REQUIRED) pkg_check_modules(libqrencode REQUIRED IMPORTED_TARGET libqrencode) - target_compile_definitions(PkgConfig::libqrencode INTERFACE - USE_QRCODE - ) + set(USE_QRCODE TRUE) endif() cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "CMAKE_SYSTEM_NAME STREQUAL \"Linux\" AND BUILD_GUI" OFF) @@ -166,6 +164,7 @@ if(BUILD_GUI) endif() if(WITH_DBUS) list(APPEND qt_components DBus) + set(USE_DBUS TRUE) endif() if(BUILD_GUI_TESTS) list(APPEND qt_components Test) diff --git a/cmake/bitcoin-config.h.in b/cmake/bitcoin-config.h.in index 9951cd0874ea3..01d3f379235fa 100644 --- a/cmake/bitcoin-config.h.in +++ b/cmake/bitcoin-config.h.in @@ -29,6 +29,28 @@ /* 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 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 + +/* 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 + +/* 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 @@ -55,6 +77,9 @@ /* Define if the dllexport attribute is supported. */ #cmakedefine HAVE_DLLEXPORT_ATTRIBUTE 1 +/* Define this symbol if evhttp_connection_get_peer expects const char** */ +#cmakedefine HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR 1 + /* Define to 1 if fdatasync is available. */ #cmakedefine HAVE_FDATASYNC 1 @@ -119,16 +144,16 @@ /* Define to 1 if strerror_r returns char *. */ #cmakedefine STRERROR_R_CHAR_P 1 -/* Define to 1 to enable wallet functions. */ -#cmakedefine ENABLE_WALLET 1 +/* Define if BDB support should be compiled in */ +#cmakedefine USE_BDB 1 -/* Define if SQLite support should be compiled in. */ -#cmakedefine USE_SQLITE +/* Define if dbus support should be compiled in */ +#cmakedefine USE_DBUS 1 -/* Define if Berkeley DB (BDB) support should be compiled in. */ -#cmakedefine USE_BDB +/* Define if QR support should be compiled in */ +#cmakedefine USE_QRCODE 1 -/* Define if external signer support is enabled. */ -#cmakedefine ENABLE_EXTERNAL_SIGNER +/* Define if sqlite support should be compiled in */ +#cmakedefine USE_SQLITE 1 #endif //BITCOIN_CONFIG_H diff --git a/cmake/introspection.cmake b/cmake/introspection.cmake index 0d5462e84c3a2..d0d16aec2f198 100644 --- a/cmake/introspection.cmake +++ b/cmake/introspection.cmake @@ -177,3 +177,70 @@ check_cxx_source_compiles(" int main(){} " HAVE_DLLEXPORT_ATTRIBUTE ) + +if(NOT MSVC) + include(CheckSourceCompilesAndLinks) + + # Check for SSE4.1 intrinsics. + set(SSE41_CXXFLAGS -msse4.1) + check_cxx_source_compiles_with_flags("${SSE41_CXXFLAGS}" " + #include + + int main() + { + __m128i a = _mm_set1_epi32(0); + __m128i b = _mm_set1_epi32(1); + __m128i r = _mm_blend_epi16(a, b, 0xFF); + return _mm_extract_epi32(r, 3); + } + " HAVE_SSE41 + ) + set(ENABLE_SSE41 ${HAVE_SSE41}) + + # Check for AVX2 intrinsics. + set(AVX2_CXXFLAGS -mavx -mavx2) + check_cxx_source_compiles_with_flags("${AVX2_CXXFLAGS}" " + #include + + int main() + { + __m256i l = _mm256_set1_epi32(0); + return _mm256_extract_epi32(l, 7); + } + " HAVE_AVX2 + ) + set(ENABLE_AVX2 ${HAVE_AVX2}) + + # Check for x86 SHA-NI intrinsics. + set(X86_SHANI_CXXFLAGS -msse4 -msha) + check_cxx_source_compiles_with_flags("${X86_SHANI_CXXFLAGS}" " + #include + + int main() + { + __m128i i = _mm_set1_epi32(0); + __m128i j = _mm_set1_epi32(1); + __m128i k = _mm_set1_epi32(2); + return _mm_extract_epi32(_mm_sha256rnds2_epu32(i, j, k), 0); + } + " HAVE_X86_SHANI + ) + set(ENABLE_X86_SHANI ${HAVE_X86_SHANI}) + + # Check for ARMv8 SHA-NI intrinsics. + set(ARM_SHANI_CXXFLAGS -march=armv8-a+crypto) + check_cxx_source_compiles_with_flags("${ARM_SHANI_CXXFLAGS}" " + #include + + int main() + { + uint32x4_t a, b, c; + vsha256h2q_u32(a, b, c); + vsha256hq_u32(a, b, c); + vsha256su0q_u32(a, b); + vsha256su1q_u32(a, b, c); + } + " HAVE_ARM_SHANI + ) + set(ENABLE_ARM_SHANI ${HAVE_ARM_SHANI}) +endif() diff --git a/cmake/module/FindLibevent.cmake b/cmake/module/FindLibevent.cmake index 9207d967ec737..901a4f3bd41ec 100644 --- a/cmake/module/FindLibevent.cmake +++ b/cmake/module/FindLibevent.cmake @@ -35,9 +35,7 @@ function(check_evhttp_connection_get_peer target) " HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR ) cmake_pop_check_state() - target_compile_definitions(${target} INTERFACE - $<$:HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR> - ) + set(HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR ${HAVE_EVHTTP_CONNECTION_GET_PEER_CONST_CHAR} PARENT_SCOPE) endfunction() diff --git a/cmake/module/FindUSDT.cmake b/cmake/module/FindUSDT.cmake index 496b5fb18f4a2..0ba9a58fc10ac 100644 --- a/cmake/module/FindUSDT.cmake +++ b/cmake/module/FindUSDT.cmake @@ -59,6 +59,6 @@ if(USDT_FOUND AND NOT TARGET USDT::headers) add_library(USDT::headers INTERFACE IMPORTED) set_target_properties(USDT::headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${USDT_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS ENABLE_TRACING ) + set(ENABLE_TRACING TRUE) endif() diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt index 6c971c5b3ec0e..3b3b322c47f06 100644 --- a/src/crypto/CMakeLists.txt +++ b/src/crypto/CMakeLists.txt @@ -2,69 +2,6 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -if(NOT MSVC) - include(CheckSourceCompilesAndLinks) - - # Check for SSE4.1 intrinsics. - set(SSE41_CXXFLAGS -msse4.1) - check_cxx_source_compiles_with_flags("${SSE41_CXXFLAGS}" " - #include - - int main() - { - __m128i a = _mm_set1_epi32(0); - __m128i b = _mm_set1_epi32(1); - __m128i r = _mm_blend_epi16(a, b, 0xFF); - return _mm_extract_epi32(r, 3); - } - " HAVE_SSE41 - ) - - # Check for AVX2 intrinsics. - set(AVX2_CXXFLAGS -mavx -mavx2) - check_cxx_source_compiles_with_flags("${AVX2_CXXFLAGS}" " - #include - - int main() - { - __m256i l = _mm256_set1_epi32(0); - return _mm256_extract_epi32(l, 7); - } - " HAVE_AVX2 - ) - - # Check for x86 SHA-NI intrinsics. - set(X86_SHANI_CXXFLAGS -msse4 -msha) - check_cxx_source_compiles_with_flags("${X86_SHANI_CXXFLAGS}" " - #include - - int main() - { - __m128i i = _mm_set1_epi32(0); - __m128i j = _mm_set1_epi32(1); - __m128i k = _mm_set1_epi32(2); - return _mm_extract_epi32(_mm_sha256rnds2_epu32(i, j, k), 0); - } - " HAVE_X86_SHANI - ) - - # Check for ARMv8 SHA-NI intrinsics. - set(ARM_SHANI_CXXFLAGS -march=armv8-a+crypto) - check_cxx_source_compiles_with_flags("${ARM_SHANI_CXXFLAGS}" " - #include - - int main() - { - uint32x4_t a, b, c; - vsha256h2q_u32(a, b, c); - vsha256hq_u32(a, b, c); - vsha256su0q_u32(a, b); - vsha256su1q_u32(a, b, c); - } - " HAVE_ARM_SHANI - ) -endif() - add_library(bitcoin_crypto STATIC EXCLUDE_FROM_ALL aes.cpp chacha20.cpp diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp index 8e3586540829c..89d7204808459 100644 --- a/src/crypto/sha256.cpp +++ b/src/crypto/sha256.cpp @@ -2,6 +2,8 @@ // 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/src/httpserver.cpp b/src/httpserver.cpp index 9db0f52fb567f..b6c6db8b35553 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -2,6 +2,8 @@ // 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/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index beda704a748d7..90bab3675c1b2 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -212,7 +212,6 @@ if(ENABLE_WALLET) endif() if(WITH_DBUS) - target_compile_definitions(bitcoinqt PRIVATE USE_DBUS) target_link_libraries(bitcoinqt PRIVATE Qt5::DBus) endif() diff --git a/src/qt/notificator.cpp b/src/qt/notificator.cpp index 6eeb19cd20acd..85bdeee49a0df 100644 --- a/src/qt/notificator.cpp +++ b/src/qt/notificator.cpp @@ -2,6 +2,8 @@ // 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/src/qt/notificator.h b/src/qt/notificator.h index f72a859f89af4..8808716aa4dca 100644 --- a/src/qt/notificator.h +++ b/src/qt/notificator.h @@ -5,6 +5,8 @@ #ifndef BITCOIN_QT_NOTIFICATOR_H #define BITCOIN_QT_NOTIFICATOR_H +#include // IWYU pragma: keep + #include #include diff --git a/src/qt/qrimagewidget.cpp b/src/qt/qrimagewidget.cpp index 9aa2db9cd97c3..f6e712a047a3e 100644 --- a/src/qt/qrimagewidget.cpp +++ b/src/qt/qrimagewidget.cpp @@ -15,6 +15,8 @@ #include #include +#include // IWYU pragma: keep + #ifdef USE_QRCODE #include #endif diff --git a/src/qt/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp index a3528d7e0069e..b4322ddc0f436 100644 --- a/src/qt/receiverequestdialog.cpp +++ b/src/qt/receiverequestdialog.cpp @@ -14,6 +14,8 @@ #include #include +#include // IWYU pragma: keep + ReceiveRequestDialog::ReceiveRequestDialog(QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags), ui(new Ui::ReceiveRequestDialog) diff --git a/src/util/trace.h b/src/util/trace.h index 7a63f39c83f94..d9ed65e3aab56 100644 --- a/src/util/trace.h +++ b/src/util/trace.h @@ -5,6 +5,8 @@ #ifndef BITCOIN_UTIL_TRACE_H #define BITCOIN_UTIL_TRACE_H +#include // IWYU pragma: keep + #ifdef ENABLE_TRACING #include