From 615204e0762c2e12077e8c8dd3c6d29b9648f163 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 3 Apr 2020 12:54:00 +0200 Subject: Fix linking of header only Qt5Zlib for cmake static builds Fixes: QTBUG-79547 Change-Id: Ibd810b5415ae8f7a965caf8b94b0df834a867836 Reviewed-by: Alexandru Croitor --- mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in index 1099a761ce..aa36cb13ef 100644 --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in @@ -406,8 +406,12 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME}) !!ENDIF endif() +!!IF equals(TEMPLATE, aux) + add_library(Qt5::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED) +!!ELSE add_library(Qt5::$${CMAKE_MODULE_NAME} STATIC IMPORTED) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX") +!!ENDIF !!ELSE !!IF equals(TEMPLATE, aux) add_library(Qt5::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED) -- cgit v1.2.3 From 276fa8383a7535765be7182883ef4aade17ce013 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 2 Apr 2020 12:08:41 -0300 Subject: QLibrary: fix deadlock caused by fix to QTBUG-39642 Commit ae6f73e8566fa76470937aca737141183929a5ec inserted a mutex around the entire load_sys(). We had reasoed that deadlocks would only occur if the object creation in instance() recursed into its own instance(), which was already a bug. But we had forgotten that dlopen()/ LoadLibrary() executes initialization code from the module being loaded, which could cause a recursion back into the same QPluginLoader or QLibrary object. This recursion is benign because the module *is* loaded and dlopen()/LoadLibrary() returns the same handle. [ChangeLog][QtCore][QLibrary and QPluginLoader] Fixed a deadlock that would happen if the plugin or library being loaded has load-time initialization code (C++ global variables) that recursed back into the same QLibrary or QPluginLoader object. PS: QLibraryPrivate::loadPlugin() updates pluginState outside a mutex lock, so pluginState should be made an atomic variable. Once that is done, we'll only need locking the mutex to update errorString (no locking before loading). Fixes: QTBUG-83207 Task-number: QTBUG-39642 Change-Id: Ibdc95e9af7bd456a94ecfffd160209304e5ab2eb Reviewed-by: Volker Hilsheimer Reviewed-by: David Faure --- src/corelib/plugin/qlibrary.cpp | 2 -- src/corelib/plugin/qlibrary_unix.cpp | 4 ++++ src/corelib/plugin/qlibrary_win.cpp | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index ddb053c26f..be9d92b204 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -576,9 +576,7 @@ bool QLibraryPrivate::load() Q_TRACE(QLibraryPrivate_load_entry, fileName); - mutex.lock(); bool ret = load_sys(); - mutex.unlock(); if (qt_debug_component()) { if (ret) { qDebug() << "loaded library" << fileName; diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index 017aa97b66..a5c72f81d9 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -123,6 +123,7 @@ QStringList QLibraryPrivate::prefixes_sys() bool QLibraryPrivate::load_sys() { + QMutexLocker locker(&mutex); QString attempt; QFileSystemEntry fsEntry(fileName); @@ -213,6 +214,7 @@ bool QLibraryPrivate::load_sys() } #endif + locker.unlock(); bool retry = true; Handle hnd = nullptr; for (int prefix = 0; retry && !hnd && prefix < prefixes.size(); prefix++) { @@ -273,6 +275,8 @@ bool QLibraryPrivate::load_sys() } } #endif + + locker.relock(); if (!hnd) { errorString = QLibrary::tr("Cannot load library %1: %2").arg(fileName, qdlerror()); } diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp index 000bf76276..ef58724be8 100644 --- a/src/corelib/plugin/qlibrary_win.cpp +++ b/src/corelib/plugin/qlibrary_win.cpp @@ -78,6 +78,7 @@ bool QLibraryPrivate::load_sys() // fileName // // NB If it's a plugin we do not ever try the ".dll" extension + QMutexLocker locker(&mutex); QStringList attempts; if (pluginState != IsAPlugin) @@ -95,6 +96,7 @@ bool QLibraryPrivate::load_sys() attempts.prepend(QDir::rootPath() + fileName); #endif + locker.unlock(); Handle hnd = nullptr; for (const QString &attempt : qAsConst(attempts)) { #ifndef Q_OS_WINRT @@ -115,6 +117,7 @@ bool QLibraryPrivate::load_sys() #ifndef Q_OS_WINRT SetErrorMode(oldmode); #endif + locker.relock(); if (!hnd) { errorString = QLibrary::tr("Cannot load library %1: %2").arg( QDir::toNativeSeparators(fileName), qt_error_string()); -- cgit v1.2.3 From b40ac4b858958db136c0e39dc074c74429b568e9 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 31 Mar 2020 18:16:01 +0200 Subject: Ensure QTzTimeZonePrivate always tries a non-empty IANA ID QTzTimeZonePrivate::init() was coping with empty and then saving the system ID if the ID it looked up was empty. Better to have its caller ensure it's passed the system ID in place of empty. The system ID is always non-empty, as it falls back to "UTC" if it would otherwise have been empty. Change-Id: I5c74e23f01ef578de0dc1f6d558e9c8c7e65ff53 Reviewed-by: Ulf Hermann --- src/corelib/time/qtimezoneprivate_tz.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index bf6963a441..1d1b5b05cb 100644 --- a/src/corelib/time/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -639,7 +639,7 @@ QTzTimeZonePrivate::QTzTimeZonePrivate() // Create a named time zone QTzTimeZonePrivate::QTzTimeZonePrivate(const QByteArray &ianaId) { - init(ianaId); + init(ianaId.isEmpty() ? systemTimeZoneId() : ianaId); } QTzTimeZonePrivate::~QTzTimeZonePrivate() @@ -852,13 +852,16 @@ QTzTimeZoneCacheEntry QTzTimeZoneCache::fetchEntry(const QByteArray &ianaId) void QTzTimeZonePrivate::init(const QByteArray &ianaId) { + // System ID defaults to UTC, so is never empty; and our callers default to + // the system ID if what they're given is empty. + Q_ASSERT(!ianaId.isEmpty()); static QTzTimeZoneCache tzCache; const auto &entry = tzCache.fetchEntry(ianaId); if (entry.m_tranTimes.isEmpty() && entry.m_posixRule.isEmpty()) return; // Invalid after all ! cached_data = std::move(entry); - m_id = ianaId.isEmpty() ? systemTimeZoneId() : ianaId; + m_id = ianaId; } QLocale::Country QTzTimeZonePrivate::country() const -- cgit v1.2.3 From b0383cbd388336f698ceeac11a4f50cdff931dd9 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 6 Apr 2020 15:01:06 +0200 Subject: Purge two old time-zone lookup fallbacks We used to need to consult /etc/timezone for the zone name back when Debian, up to Jessie, used a copy of the zoneinfo file as /etc/localtime, instead of a symlink. Jessie's end of life is this May, but Thiago reports that its gcc can't build Qt 5.14, so we may as well remove this fall-back. Newer versions of Debian use a symlink. We used to need to consult /etc/sysconfig/clock for this information back when ancient Red Hat distros copied zoneinfo to /etc/localtime instead of symlinking, but Thiago believes that's now ancient history. So, again, remove this old fallback. Change-Id: I73cb40b926186b311dac6f00fe8743d37a9dfce5 Reviewed-by: Thiago Macieira --- src/corelib/time/qtimezoneprivate_tz.cpp | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp index 1d1b5b05cb..ada19f4eb4 100644 --- a/src/corelib/time/qtimezoneprivate_tz.cpp +++ b/src/corelib/time/qtimezoneprivate_tz.cpp @@ -1153,29 +1153,6 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const } } - // On Debian Etch up to Jessie, /etc/localtime is a copy of the relevant - // zoneinfo file, whose name is recorded in /etc/timezone: - if (ianaId.isEmpty()) { - QFile tzif(QStringLiteral("/etc/timezone")); - if (tzif.open(QIODevice::ReadOnly)) - ianaId = tzif.readAll().trimmed(); - } - - // On some Red Hat distros /etc/localtime is real file with name held in /etc/sysconfig/clock - // in a line like ZONE="Europe/Oslo" or TIMEZONE="Europe/Oslo" - if (ianaId.isEmpty()) { - QFile tzif(QStringLiteral("/etc/sysconfig/clock")); - if (tzif.open(QIODevice::ReadOnly)) { - while (ianaId.isEmpty() && !tzif.atEnd()) { - const QByteArray line(tzif.readLine().trimmed()); - if (line.startsWith("ZONE=")) - ianaId = line.mid(6, line.length() - 7); - else if (line.startsWith("TIMEZONE=")) - ianaId = line.mid(10, line.length() - 11); - } - } - } - // Some systems (e.g. uClibc) have a default value for $TZ in /etc/TZ: if (ianaId.isEmpty()) { QFile zone(QStringLiteral("/etc/TZ")); -- cgit v1.2.3 From 2a4e6124ac1f0c7beb061365a18146ca1f1e6233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Thu, 26 Mar 2020 12:52:22 +0100 Subject: Fix build with macOS 10.15 and deployment 10.12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit io/qfilesystemengine_unix.cpp:1420:9: error: 'futimens' is only available on macOS 10.13 or newer [-Werror,-Wunguarded-availability-new] if (futimens(fd, ts) == -1) { ^~~~~~~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/sys/stat.h:396:9: note: 'futimens' has been marked as being introduced in macOS 10.13 here, but the deployment target is macOS 10.12.0 int futimens(int __fd, const struct timespec __times[2]) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0)); ^ io/qfilesystemengine_unix.cpp:1420:9: note: enclose 'futimens' in a __builtin_available check to silence this warning if (futimens(fd, ts) == -1) { ^~~~~~~~ Change-Id: Ib52adf7b1ec4f1057d8cb260a00da509429cfaed Reviewed-by: Tor Arne Vestbø (cherry picked from commit 2f030c2cf3fe368be217c0e0b157e050d1c27afc) --- src/corelib/configure.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/configure.json b/src/corelib/configure.json index ae360239c6..37fa85cd3d 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -389,7 +389,8 @@ "# Block futimens() on Apple platforms unless it's available on ALL", "# deployment targets. This simplifies the logic at the call site", "# dramatically, as it isn't strictly needed compared to futimes().", - "darwin: QMAKE_CXXFLAGS += -Werror=unguarded-availability" + "darwin: QMAKE_CXXFLAGS += -Werror=unguarded-availability -Werror=unguarded-availability-new", + "CONFIG += warn_on" ] } }, -- cgit v1.2.3