summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2019-12-13 21:19:26 +0100
committerLinus Jahn <lnj@kaidan.im>2020-07-31 15:05:24 +0200
commitc19bafc60c1c2e9a73cb3d212293462a1be4eb47 (patch)
tree089269cabcc8b75832a6ce3cff8ec5e4020b0de0 /src
parent5d69aa3ee1214cf689e2357bff8688f2ff138471 (diff)
QtCore: Use system-wide libb2 if present
This adds the option to build Qt with libb2, which is especially recommended, if you care about the performance of the BLAKE2 hashing algorithms. The bundled version is the pure reference C implementation of BLAKE2, while libb2 has many additional hardware optimizations. However, the API of both is the same, so no changes to the code were necessary here. Change-Id: I3563982f4e07be300291fe103c38b16a404b3ebb Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/.prev_CMakeLists.txt21
-rw-r--r--src/corelib/CMakeLists.txt27
-rw-r--r--src/corelib/configure.cmake13
-rw-r--r--src/corelib/configure.json20
-rw-r--r--src/corelib/tools/qcryptographichash.cpp4
-rw-r--r--src/corelib/tools/qmessageauthenticationcode.cpp6
-rw-r--r--src/corelib/tools/tools.pri4
7 files changed, 76 insertions, 19 deletions
diff --git a/src/corelib/.prev_CMakeLists.txt b/src/corelib/.prev_CMakeLists.txt
index 4ae1329db7..e143581087 100644
--- a/src/corelib/.prev_CMakeLists.txt
+++ b/src/corelib/.prev_CMakeLists.txt
@@ -642,6 +642,11 @@ qt_extend_target(Core CONDITION QT_FEATURE_doubleconversion AND NOT QT_FEATURE_s
../3rdparty/double-conversion/include
)
+qt_extend_target(Core CONDITION QT_FEATURE_system_libb2
+ LIBRARIES
+ PkgConfig::Libb2
+)
+
qt_extend_target(Core CONDITION QT_FEATURE_easingcurve
SOURCES
tools/qeasingcurve.cpp tools/qeasingcurve.h
@@ -1018,7 +1023,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype
mimetypes/qmimetypeparser.cpp mimetypes/qmimetypeparser_p.h
)
-#### Keys ignored in scope 180:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype:
+#### Keys ignored in scope 181:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype:
# MIME_DATABASE = "mimetypes/mime/packages/freedesktop.org.xml"
# OTHER_FILES = "$$MIME_DATABASE"
@@ -1027,7 +1032,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype AND QT_FEATURE_mimetype_data
.rcc
)
-#### Keys ignored in scope 181:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database:
+#### Keys ignored in scope 182:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database:
# QMAKE_EXTRA_COMPILERS = "mimedb"
# mimedb.commands = "${QMAKE_FILE_IN}" ">" "${QMAKE_FILE_OUT}"
# mimedb.depends = "$$PWD/mime/generate.pl"
@@ -1035,23 +1040,23 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype AND QT_FEATURE_mimetype_data
# mimedb.output = "$$outpath/qmimeprovider_database.cpp"
# mimedb.variable_out = "INCLUDED_SOURCES"
-#### Keys ignored in scope 182:.:mimetypes:mimetypes/mimetypes.pri:ANDROID:
+#### Keys ignored in scope 183:.:mimetypes:mimetypes/mimetypes.pri:ANDROID:
# outpath = "$$outpath/$${QT_ARCH}"
-#### Keys ignored in scope 184:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug):
+#### Keys ignored in scope 185:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug):
# outpath = "$$outpath/debug"
-#### Keys ignored in scope 185:.:mimetypes:mimetypes/mimetypes.pri:else:
+#### Keys ignored in scope 186:.:mimetypes:mimetypes/mimetypes.pri:else:
# outpath = "$$outpath/release"
-#### Keys ignored in scope 186:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY:
+#### Keys ignored in scope 187:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY:
# mimedb.commands = "cmd" "/c" "$$shell_path($$PWD/mime/generate.bat)"
# mimedb.depends = "$$PWD/mime/generate.bat" "$$PWD/mime/hexdump.ps1"
-#### Keys ignored in scope 187:.:mimetypes:mimetypes/mimetypes.pri:else:
+#### Keys ignored in scope 188:.:mimetypes:mimetypes/mimetypes.pri:else:
# mimedb.commands = "perl" "$${mimedb.depends}"
-#### Keys ignored in scope 188:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd:
+#### Keys ignored in scope 189:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd:
# mimedb.commands = "--zstd"
qt_extend_target(Core CONDITION WASM
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 5d79b00bf9..4a3204e381 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -247,13 +247,13 @@ qt_add_module(Core
# ../3rdparty/md5 # special case remove
# ../3rdparty/sha3 # special case remove
../3rdparty/tinycbor/src
+ LIBRARIES
+ Qt::GlobalConfigPrivate # special case
+ Threads::Threads # special case
PRECOMPILED_HEADER
"global/qt_pch.h"
NO_PCH_SOURCES
"text/qstring_compat.cpp"
- LIBRARIES
- Qt::GlobalConfigPrivate # special case
- Threads::Threads # special case
PUBLIC_LIBRARIES # special case:
Qt::Platform # special case:
# special case begin
@@ -747,6 +747,11 @@ qt_extend_target(Core CONDITION QT_FEATURE_doubleconversion AND NOT QT_FEATURE_s
../3rdparty/double-conversion/include
)
+qt_extend_target(Core CONDITION QT_FEATURE_system_libb2
+ LIBRARIES
+ PkgConfig::Libb2
+)
+
qt_extend_target(Core CONDITION QT_FEATURE_easingcurve
SOURCES
tools/qeasingcurve.cpp tools/qeasingcurve.h
@@ -1123,7 +1128,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype
mimetypes/qmimetypeparser.cpp mimetypes/qmimetypeparser_p.h
)
-#### Keys ignored in scope 180:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype:
+#### Keys ignored in scope 181:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype:
# MIME_DATABASE = "mimetypes/mime/packages/freedesktop.org.xml"
# OTHER_FILES = "$$MIME_DATABASE"
@@ -1134,7 +1139,7 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype
#)
# special case end
-#### Keys ignored in scope 181:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database:
+#### Keys ignored in scope 182:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_mimetype_database:
# QMAKE_EXTRA_COMPILERS = "mimedb"
# mimedb.commands = "${QMAKE_FILE_IN}" ">" "${QMAKE_FILE_OUT}"
# mimedb.depends = "$$PWD/mime/generate.pl"
@@ -1142,23 +1147,23 @@ qt_extend_target(Core CONDITION QT_FEATURE_mimetype
# mimedb.output = "$$outpath/qmimeprovider_database.cpp"
# mimedb.variable_out = "INCLUDED_SOURCES"
-#### Keys ignored in scope 182:.:mimetypes:mimetypes/mimetypes.pri:ANDROID:
+#### Keys ignored in scope 183:.:mimetypes:mimetypes/mimetypes.pri:ANDROID:
# outpath = "$$outpath/$${QT_ARCH}"
-#### Keys ignored in scope 184:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug):
+#### Keys ignored in scope 185:.:mimetypes:mimetypes/mimetypes.pri:(CMAKE_BUILD_TYPE STREQUAL Debug):
# outpath = "$$outpath/debug"
-#### Keys ignored in scope 185:.:mimetypes:mimetypes/mimetypes.pri:else:
+#### Keys ignored in scope 186:.:mimetypes:mimetypes/mimetypes.pri:else:
# outpath = "$$outpath/release"
-#### Keys ignored in scope 186:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY:
+#### Keys ignored in scope 187:.:mimetypes:mimetypes/mimetypes.pri:MAKEFILE_GENERATOR___equals___MSVC.NET OR MAKEFILE_GENERATOR___equals___MSBUILD OR QMAKE_SH_ISEMPTY:
# mimedb.commands = "cmd" "/c" "$$shell_path($$PWD/mime/generate.bat)"
# mimedb.depends = "$$PWD/mime/generate.bat" "$$PWD/mime/hexdump.ps1"
-#### Keys ignored in scope 187:.:mimetypes:mimetypes/mimetypes.pri:else:
+#### Keys ignored in scope 188:.:mimetypes:mimetypes/mimetypes.pri:else:
# mimedb.commands = "perl" "$${mimedb.depends}"
-#### Keys ignored in scope 188:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd:
+#### Keys ignored in scope 189:.:mimetypes:mimetypes/mimetypes.pri:QT_FEATURE_zstd:
# mimedb.commands = "--zstd"
# Resources:
# special case begin
diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake
index 7f565437cd..21a525bd03 100644
--- a/src/corelib/configure.cmake
+++ b/src/corelib/configure.cmake
@@ -6,6 +6,10 @@
set(INPUT_doubleconversion "undefined" CACHE STRING "")
set_property(CACHE INPUT_doubleconversion PROPERTY STRINGS undefined no qt system)
+# input libb2
+set(INPUT_libb2 "undefined" CACHE STRING "")
+set_property(CACHE INPUT_libb2 PROPERTY STRINGS undefined no qt system)
+
#### Libraries
@@ -18,6 +22,7 @@ if(QT_FEATURE_dlopen)
endif()
qt_find_package(Libsystemd PROVIDED_TARGETS PkgConfig::Libsystemd MODULE_NAME core QMAKE_LIB journald)
qt_find_package(WrapAtomic PROVIDED_TARGETS WrapAtomic::WrapAtomic MODULE_NAME core QMAKE_LIB libatomic)
+qt_find_package(Libb2 PROVIDED_TARGETS PkgConfig::Libb2 MODULE_NAME core QMAKE_LIB libb2)
qt_find_package(WrapRt PROVIDED_TARGETS WrapRt::WrapRt MODULE_NAME core QMAKE_LIB librt)
qt_find_package(LTTngUST PROVIDED_TARGETS LTTng::UST MODULE_NAME core QMAKE_LIB lttng-ust)
qt_add_qmake_lib_dependency(lttng-ust libdl)
@@ -607,6 +612,13 @@ qt_feature("journald" PRIVATE
AUTODETECT OFF
CONDITION Libsystemd_FOUND
)
+# Used by QCryptographicHash for the BLAKE2 hashing algorithms
+qt_feature("system-libb2" PRIVATE
+ LABEL "Using system libb2"
+ CONDITION Libb2_FOUND
+ ENABLE INPUT_libb2 STREQUAL 'system'
+ DISABLE INPUT_libb2 STREQUAL 'no' OR INPUT_libb2 STREQUAL 'qt'
+)
# Currently only used by QTemporaryFile; linkat() exists on Android, but hardlink creation fails due to security rules
qt_feature("linkat" PRIVATE
LABEL "linkat()"
@@ -956,6 +968,7 @@ qt_configure_add_summary_entry(ARGS "doubleconversion")
qt_configure_add_summary_entry(ARGS "system-doubleconversion")
qt_configure_add_summary_entry(ARGS "glib")
qt_configure_add_summary_entry(ARGS "icu")
+qt_configure_add_summary_entry(ARGS "system-libb2")
qt_configure_add_summary_entry(ARGS "mimetype-database")
qt_configure_add_summary_entry(
TYPE "firstAvailableFeature"
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 2610392ad1..966bc7684a 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -10,6 +10,7 @@
"icu": "boolean",
"inotify": "boolean",
"journald": "boolean",
+ "libb2": { "type": "enum", "values": [ "no", "qt", "system" ] },
"mimetype-database": "boolean",
"pcre": { "type": "enum", "values": [ "no", "qt", "system" ] },
"posix-ipc": { "type": "boolean", "name": "ipc_posix" },
@@ -111,6 +112,16 @@
"-latomic"
]
},
+ "libb2": {
+ "label": "libb2",
+ "test": {
+ "main": "BLAKE2B_BLOCKBYTES;"
+ },
+ "headers": "blake2.h",
+ "sources": [
+ { "type": "pkgConfig", "args": "libb2" }
+ ]
+ },
"librt": {
"label": "clock_gettime()",
"test": {
@@ -647,6 +658,14 @@
"condition": "libs.journald",
"output": [ "privateFeature" ]
},
+ "system-libb2": {
+ "label": "Using system libb2",
+ "comment": "Used by QCryptographicHash for the BLAKE2 hashing algorithms",
+ "disable": "input.libb2 == 'no' || input.libb2 == 'qt'",
+ "enable": "input.libb2 == 'system'",
+ "condition": "libs.libb2",
+ "output": [ "privateFeature" ]
+ },
"linkat": {
"label": "linkat()",
"comment": "Currently only used by QTemporaryFile; linkat() exists on Android, but hardlink creation fails due to security rules",
@@ -1074,6 +1093,7 @@ Note that this is required for plugin loading. Qt GUI needs QPA plugins for basi
"system-doubleconversion",
"glib",
"icu",
+ "system-libb2",
"mimetype-database",
{
"message": "Tracing backend",
diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp
index 9f98475dc0..d5a6c4e5a0 100644
--- a/src/corelib/tools/qcryptographichash.cpp
+++ b/src/corelib/tools/qcryptographichash.cpp
@@ -165,8 +165,12 @@ static inline int SHA384_512AddLength(SHA512Context *context, unsigned int lengt
return SHA384_512AddLengthM(context, length);
}
+#if QT_CONFIG(system_libb2)
+#include <blake2.h>
+#else
#include "../../3rdparty/blake2/src/blake2b-ref.c"
#include "../../3rdparty/blake2/src/blake2s-ref.c"
+#endif
#endif // QT_CRYPTOGRAPHICHASH_ONLY_SHA1
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qmessageauthenticationcode.cpp b/src/corelib/tools/qmessageauthenticationcode.cpp
index d84b1b0b6c..ada502ecb8 100644
--- a/src/corelib/tools/qmessageauthenticationcode.cpp
+++ b/src/corelib/tools/qmessageauthenticationcode.cpp
@@ -40,6 +40,8 @@
#include "qmessageauthenticationcode.h"
#include "qvarlengtharray.h"
+#include "qtcore-config_p.h"
+
/*
These #defines replace the typedefs needed by the RFC6234 code. Normally
the typedefs would come from from stdint.h, but since this header is not
@@ -75,7 +77,11 @@
// sha1.h - commented out '#include <stdint.h>' on line 74
#include "../../3rdparty/rfc6234/sha.h"
+#if QT_CONFIG(system_libb2)
+#include <blake2.h>
+#else
#include "../../3rdparty/blake2/src/blake2.h"
+#endif
#undef uint64_t
#undef uint32_t
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 4d3b5e25ff..c8ce79ce36 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -99,6 +99,10 @@ qtConfig(system-doubleconversion) {
include($$PWD/../../3rdparty/double-conversion/double-conversion.pri)
}
+qtConfig(system-libb2) {
+ QMAKE_USE_PRIVATE += libb2
+}
+
qtConfig(easingcurve) {
HEADERS += \
tools/qeasingcurve.h \