parent
4ec5444a7a
commit
b477dd62fc
@ -1,47 +0,0 @@
|
||||
From 7c54988b1b3b9eb4d2f3650c1ba5ffe97673ca92 Mon Sep 17 00:00:00 2001
|
||||
From: Pino Toscano <toscano.pino@tiscali.it>
|
||||
Date: Thu, 10 Feb 2022 08:26:11 +0100
|
||||
Subject: [PATCH] Avoid a stack buffer when not needed
|
||||
|
||||
Allocate a PATH_MAX-sized buffer on stack only in case we are not using
|
||||
realpath(X, null), i.e. on platforms with older POSIX versions, macOS,
|
||||
or Android.
|
||||
|
||||
This fixes the build on platforms that do not have PATH_MAX (e.g.
|
||||
GNU/Hurd), and it provides a minor optimization on realpath(X, null)
|
||||
platforms.
|
||||
|
||||
Change-Id: Icd92a1b15ec18c5eef8113408e9610dfac774101
|
||||
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
|
||||
---
|
||||
src/corelib/io/qfilesystemengine_unix.cpp | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
|
||||
index 6e8229daec..fb66d47d38 100644
|
||||
--- a/src/corelib/io/qfilesystemengine_unix.cpp
|
||||
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
|
||||
@@ -686,7 +686,9 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
|
||||
Q_UNUSED(data);
|
||||
return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath()));
|
||||
#else
|
||||
+# if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) || _POSIX_VERSION < 200801L
|
||||
char stack_result[PATH_MAX+1];
|
||||
+# endif
|
||||
char *resolved_name = nullptr;
|
||||
# if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID)
|
||||
// On some Android and macOS versions, realpath() will return a path even if
|
||||
@@ -714,8 +716,10 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
|
||||
data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
|
||||
data.entryFlags |= QFileSystemMetaData::ExistsAttribute;
|
||||
QString canonicalPath = QDir::cleanPath(QFile::decodeName(resolved_name));
|
||||
+# if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) || _POSIX_VERSION < 200801L
|
||||
if (resolved_name != stack_result)
|
||||
free(resolved_name);
|
||||
+# endif
|
||||
return QFileSystemEntry(canonicalPath);
|
||||
} else if (errno == ENOENT || errno == ENOTDIR) { // file doesn't exist
|
||||
data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
|
||||
--
|
||||
2.34.1
|
||||
|
@ -1,143 +0,0 @@
|
||||
From 099e0fff61f080e2d628c8f472df78f6fd2f5234 Mon Sep 17 00:00:00 2001
|
||||
From: Pino Toscano <toscano.pino@tiscali.it>
|
||||
Date: Sun, 21 Nov 2021 08:59:56 +0100
|
||||
Subject: [PATCH] CMake: add support for GNU/Hurd
|
||||
|
||||
Add a "HURD" CMake platform specification, so it can be properly
|
||||
checked in the build system.
|
||||
|
||||
Set QT_DEFAULT_MKSPEC to the existing hurd-g++ mkspec.
|
||||
|
||||
Hurd supports $ORIGIN in RPATH, so enable it.
|
||||
|
||||
Hurd uses X11, so add it to the X11_SUPPORTED list.
|
||||
|
||||
Enable few more feature checks that apply to Hurd as well: either
|
||||
because they are provided by GNU libc itself, or because they are
|
||||
implemented on Hurd.
|
||||
|
||||
Check and set the ELF interpreter, as it is a common functionality of
|
||||
the GNU toolchain.
|
||||
|
||||
Change-Id: Id347033560bbc5a2a4e2c3abb493c948c002b40e
|
||||
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
|
||||
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
|
||||
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
|
||||
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
|
||||
---
|
||||
cmake/QtBuild.cmake | 2 ++
|
||||
cmake/QtPlatformSupport.cmake | 1 +
|
||||
cmake/QtRpathHelpers.cmake | 2 +-
|
||||
src/corelib/CMakeLists.txt | 2 +-
|
||||
src/corelib/configure.cmake | 8 ++++----
|
||||
src/gui/configure.cmake | 2 +-
|
||||
6 files changed, 10 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
|
||||
index b06dec60d8..d267f560c1 100644
|
||||
--- a/cmake/QtBuild.cmake
|
||||
+++ b/cmake/QtBuild.cmake
|
||||
@@ -362,6 +362,8 @@ elseif(SOLARIS)
|
||||
set(QT_DEFAULT_MKSPEC solaris-cc)
|
||||
endif()
|
||||
endif()
|
||||
+elseif(HURD)
|
||||
+ set(QT_DEFAULT_MKSPEC hurd-g++)
|
||||
endif()
|
||||
|
||||
if(NOT QT_QMAKE_TARGET_MKSPEC)
|
||||
diff --git a/cmake/QtPlatformSupport.cmake b/cmake/QtPlatformSupport.cmake
|
||||
index c8462043c9..44db95d807 100644
|
||||
--- a/cmake/QtPlatformSupport.cmake
|
||||
+++ b/cmake/QtPlatformSupport.cmake
|
||||
@@ -18,6 +18,7 @@ qt_set01(FREEBSD CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FIXME: How to identify
|
||||
qt_set01(NETBSD CMAKE_SYSTEM_NAME STREQUAL "NetBSD") # FIXME: How to identify this?
|
||||
qt_set01(WASM CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR EMSCRIPTEN)
|
||||
qt_set01(SOLARIS CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
||||
+qt_set01(HURD CMAKE_SYSTEM_NAME STREQUAL "GNU")
|
||||
|
||||
# This is the only reliable way we can determine the webOS platform as the yocto recipe adds this
|
||||
# compile definition into its generated toolchain.cmake file
|
||||
|
||||
diff --git a/cmake/QtRpathHelpers.cmake b/cmake/QtRpathHelpers.cmake
|
||||
index 6e3414b50f..cbe33a6b77 100644
|
||||
--- a/cmake/QtRpathHelpers.cmake
|
||||
+++ b/cmake/QtRpathHelpers.cmake
|
||||
@@ -20,7 +20,7 @@ function(qt_compute_relative_rpath_base rpath install_location out_var)
|
||||
# needed in the .prf files, but for CMake we need to prepend them ourselves.
|
||||
if(APPLE)
|
||||
set(rpath_rel_base "@loader_path")
|
||||
- elseif(LINUX OR SOLARIS OR FREEBSD)
|
||||
+ elseif(LINUX OR SOLARIS OR FREEBSD OR HURD)
|
||||
set(rpath_rel_base "$ORIGIN")
|
||||
else()
|
||||
message(WARNING "No known RPATH_REL_BASE for target platform.")
|
||||
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
|
||||
index c1259150ab..be4bc7b2de 100644
|
||||
--- a/src/corelib/CMakeLists.txt
|
||||
+++ b/src/corelib/CMakeLists.txt
|
||||
@@ -339,7 +339,7 @@ set_property(TARGET Core APPEND PROPERTY
|
||||
PRIVATE_HEADER "${CMAKE_CURRENT_BINARY_DIR}/global/qconfig_p.h")
|
||||
|
||||
# Find ELF interpreter and define a macro for that:
|
||||
-if (LINUX AND NOT CMAKE_CROSSCOMPILING AND BUILD_SHARED_LIBS)
|
||||
+if ((LINUX OR HURD) AND NOT CMAKE_CROSSCOMPILING AND BUILD_SHARED_LIBS)
|
||||
if (NOT DEFINED ELF_INTERPRETER)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C readelf -l /bin/ls
|
||||
RESULT_VARIABLE readelf_ok
|
||||
diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake
|
||||
index 08d1e0d976..71e237ae9c 100644
|
||||
--- a/src/corelib/configure.cmake
|
||||
+++ b/src/corelib/configure.cmake
|
||||
@@ -578,7 +578,7 @@ qt_feature("glib" PUBLIC PRIVATE
|
||||
qt_feature_definition("glib" "QT_NO_GLIB" NEGATE VALUE "1")
|
||||
qt_feature("glibc" PRIVATE
|
||||
LABEL "GNU libc"
|
||||
- AUTODETECT LINUX
|
||||
+ AUTODETECT ( LINUX OR HURD )
|
||||
CONDITION TEST_glibc
|
||||
)
|
||||
qt_feature("icu" PRIVATE
|
||||
@@ -612,7 +612,7 @@ qt_feature("system-libb2" PRIVATE
|
||||
# Currently only used by QTemporaryFile; linkat() exists on Android, but hardlink creation fails due to security rules
|
||||
qt_feature("linkat" PRIVATE
|
||||
LABEL "linkat()"
|
||||
- AUTODETECT LINUX AND NOT ANDROID
|
||||
+ AUTODETECT ( LINUX AND NOT ANDROID ) OR HURD
|
||||
CONDITION TEST_linkat
|
||||
)
|
||||
qt_feature("std-atomic64" PUBLIC
|
||||
@@ -669,7 +669,7 @@ qt_feature("qqnx_pps" PRIVATE
|
||||
)
|
||||
qt_feature("renameat2" PRIVATE
|
||||
LABEL "renameat2()"
|
||||
- CONDITION LINUX AND TEST_renameat2
|
||||
+ CONDITION ( LINUX OR HURD ) AND TEST_renameat2
|
||||
)
|
||||
qt_feature("slog2" PRIVATE
|
||||
LABEL "slog2"
|
||||
@@ -677,7 +677,7 @@ qt_feature("slog2" PRIVATE
|
||||
)
|
||||
qt_feature("statx" PRIVATE
|
||||
LABEL "statx() in libc"
|
||||
- CONDITION LINUX AND TEST_statx
|
||||
+ CONDITION ( LINUX OR HURD ) AND TEST_statx
|
||||
)
|
||||
qt_feature("syslog" PRIVATE
|
||||
LABEL "syslog"
|
||||
diff --git a/src/gui/configure.cmake b/src/gui/configure.cmake
|
||||
index f5d26977af..b4625c77b4 100644
|
||||
--- a/src/gui/configure.cmake
|
||||
+++ b/src/gui/configure.cmake
|
||||
@@ -25,7 +25,7 @@ set_property(CACHE INPUT_libpng PROPERTY STRINGS undefined no qt system)
|
||||
|
||||
|
||||
#### Libraries
|
||||
-qt_set01(X11_SUPPORTED LINUX OR HPUX OR FREEBSD OR NETBSD OR OPENBSD OR SOLARIS) # special case
|
||||
+qt_set01(X11_SUPPORTED LINUX OR HPUX OR FREEBSD OR NETBSD OR OPENBSD OR SOLARIS OR HURD) # special case
|
||||
qt_find_package(ATSPI2 PROVIDED_TARGETS PkgConfig::ATSPI2 MODULE_NAME gui QMAKE_LIB atspi)
|
||||
qt_find_package(DirectFB PROVIDED_TARGETS PkgConfig::DirectFB MODULE_NAME gui QMAKE_LIB directfb)
|
||||
qt_find_package(Libdrm PROVIDED_TARGETS Libdrm::Libdrm MODULE_NAME gui QMAKE_LIB drm)
|
||||
--
|
||||
2.34.1
|
||||
|
@ -1,31 +0,0 @@
|
||||
From 06e7b5168e269f913f03ecb9d77fc82db4d9dfd6 Mon Sep 17 00:00:00 2001
|
||||
From: Pino Toscano <toscano.pino@tiscali.it>
|
||||
Date: Mon, 31 Jan 2022 21:36:59 +0100
|
||||
Subject: [PATCH] Hurd: enable XOPEN largefile APIs
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Hurd supports largefile, so enable it also in Qt.
|
||||
|
||||
Change-Id: I8384ca2cb5c6250376916b6a890e1a873c0a0e96
|
||||
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
|
||||
---
|
||||
mkspecs/hurd-g++/qplatformdefs.h | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/mkspecs/hurd-g++/qplatformdefs.h b/mkspecs/hurd-g++/qplatformdefs.h
|
||||
index b1887aae7f..c6d35e0ac5 100644
|
||||
--- a/mkspecs/hurd-g++/qplatformdefs.h
|
||||
+++ b/mkspecs/hurd-g++/qplatformdefs.h
|
||||
@@ -78,6 +78,7 @@
|
||||
#include <sys/wait.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
+#define QT_USE_XOPEN_LFS_EXTENSIONS
|
||||
#include "../common/posix/qplatformdefs.h"
|
||||
|
||||
#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
|
||||
--
|
||||
2.34.1
|
||||
|
@ -1,98 +0,0 @@
|
||||
From 06e45cbd6a2e09bc32cb1c9aa3779d6bd5282c45 Mon Sep 17 00:00:00 2001
|
||||
From: Fabian Kosmale <fabian.kosmale@qt.io>
|
||||
Date: Mon, 14 Feb 2022 10:29:24 +0100
|
||||
Subject: [PATCH] QFileSystemEngine::canonicalName (Unix): clean up
|
||||
control-flow
|
||||
|
||||
When passing a nullptr to realpath, it will allocate memory. That memory
|
||||
has to be freed (with free) later to avoid a leak, which we so far
|
||||
didn't.
|
||||
This patch ensures that we always clean up the memory by using a
|
||||
unique_ptr. As a drive-by, clean up the control-flow:
|
||||
- Always pass either the stack buffer or nullptr to realpath.
|
||||
- Rely on realpath returning nullptr in the error case.
|
||||
Lastly, fix a few coding-style issues.
|
||||
|
||||
Change-Id: Ia906df77324020c267b087ec52a9a6c47aaa2a59
|
||||
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
|
||||
---
|
||||
src/corelib/io/qfilesystemengine_unix.cpp | 43 ++++++++++++-----------
|
||||
1 file changed, 23 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
|
||||
index fb66d47d38..47dd7bea7e 100644
|
||||
--- a/src/corelib/io/qfilesystemengine_unix.cpp
|
||||
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
|
||||
@@ -58,6 +58,8 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
+#include <memory> // for std::unique_ptr
|
||||
+
|
||||
#if __has_include(<paths.h>)
|
||||
# include <paths.h>
|
||||
#endif
|
||||
@@ -687,39 +689,40 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
|
||||
return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath()));
|
||||
#else
|
||||
# if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) || _POSIX_VERSION < 200801L
|
||||
- char stack_result[PATH_MAX+1];
|
||||
+ // used to store the result of realpath in case where realpath cannot allocate itself
|
||||
+ char stack_result[PATH_MAX + 1];
|
||||
+#else
|
||||
+ // enables unconditionally passing stack_result below
|
||||
+ std::nullptr_t stack_result = nullptr;
|
||||
+# endif
|
||||
+ auto resolved_path_deleter = [&](char *ptr) {
|
||||
+ // frees resolved_name if it was allocated by realpath
|
||||
+# if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) || _POSIX_VERSION < 200801L
|
||||
+ // ptr is either null, or points to stack_result
|
||||
+ Q_ASSERT(!ptr || ptr == stack_result);
|
||||
+ return;
|
||||
+#else
|
||||
+ free(ptr);
|
||||
# endif
|
||||
- char *resolved_name = nullptr;
|
||||
+ };
|
||||
+ std::unique_ptr<char, decltype (resolved_path_deleter)> resolved_name {nullptr, resolved_path_deleter};
|
||||
# if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID)
|
||||
// On some Android and macOS versions, realpath() will return a path even if
|
||||
// it does not exist. To work around this, we check existence in advance.
|
||||
if (!data.hasFlags(QFileSystemMetaData::ExistsAttribute))
|
||||
fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute);
|
||||
|
||||
- if (!data.exists()) {
|
||||
+ if (!data.exists())
|
||||
errno = ENOENT;
|
||||
- } else {
|
||||
- resolved_name = stack_result;
|
||||
- }
|
||||
- if (resolved_name && realpath(entry.nativeFilePath().constData(), resolved_name) == nullptr)
|
||||
- resolved_name = nullptr;
|
||||
+ else
|
||||
+ resolved_name.reset(realpath(entry.nativeFilePath().constData(), stack_result));
|
||||
# else
|
||||
-# if _POSIX_VERSION >= 200801L // ask realpath to allocate memory
|
||||
- resolved_name = realpath(entry.nativeFilePath().constData(), nullptr);
|
||||
-# else
|
||||
- resolved_name = stack_result;
|
||||
- if (realpath(entry.nativeFilePath().constData(), resolved_name) == nullptr)
|
||||
- resolved_name = nullptr;
|
||||
-# endif
|
||||
+ resolved_name.reset(realpath(entry.nativeFilePath().constData(), stack_result));
|
||||
# endif
|
||||
if (resolved_name) {
|
||||
data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
|
||||
data.entryFlags |= QFileSystemMetaData::ExistsAttribute;
|
||||
- QString canonicalPath = QDir::cleanPath(QFile::decodeName(resolved_name));
|
||||
-# if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) || _POSIX_VERSION < 200801L
|
||||
- if (resolved_name != stack_result)
|
||||
- free(resolved_name);
|
||||
-# endif
|
||||
+ QString canonicalPath = QDir::cleanPath(QFile::decodeName(resolved_name.get()));
|
||||
return QFileSystemEntry(canonicalPath);
|
||||
} else if (errno == ENOENT || errno == ENOTDIR) { // file doesn't exist
|
||||
data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
|
||||
--
|
||||
2.34.1
|
||||
|
@ -1,53 +0,0 @@
|
||||
From 13a11f1c3526112eaf28943185fadc14523fd496 Mon Sep 17 00:00:00 2001
|
||||
From: Pino Toscano <toscano.pino@tiscali.it>
|
||||
Date: Mon, 17 Jan 2022 20:43:01 +0100
|
||||
Subject: [PATCH] QProcess/Unix: fallback on _POSIX_PIPE_BUF w/ missing
|
||||
PIPE_BUF
|
||||
|
||||
PIPE_BUF is optional in POSIX, e.g. "where the corresponding value is
|
||||
equal to or greater than the stated minimum, but where the value can
|
||||
vary depending on the file to which it is applied." [1]
|
||||
|
||||
GNU/Hurd does not provide PIPE_BUF, so fallback to its minimum
|
||||
acceptable value, that is _POSIX_PIPE_BUF.
|
||||
|
||||
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
|
||||
|
||||
Also, explicitly include <limits.h> in this file, to make sure PIPE_BUF
|
||||
or _POSIX_PIPE_BUF are available without relying on other headers to
|
||||
pull <limits.h>.
|
||||
|
||||
Change-Id: Ifae964db81841e1d31fc09e73b45594af9a326d1
|
||||
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
|
||||
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
|
||||
---
|
||||
src/corelib/io/qprocess_unix.cpp | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
|
||||
index bf19fc2183..91005b0b67 100644
|
||||
--- a/src/corelib/io/qprocess_unix.cpp
|
||||
+++ b/src/corelib/io/qprocess_unix.cpp
|
||||
@@ -69,6 +69,7 @@
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
+#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -935,7 +936,11 @@ bool QProcessPrivate::startDetached(qint64 *pid)
|
||||
{
|
||||
QByteArray encodedWorkingDirectory = QFile::encodeName(workingDirectory);
|
||||
|
||||
+#ifdef PIPE_BUF
|
||||
static_assert(PIPE_BUF >= sizeof(ChildError));
|
||||
+#else
|
||||
+ static_assert(_POSIX_PIPE_BUF >= sizeof(ChildError));
|
||||
+#endif
|
||||
ChildError childStatus = { 0, {} };
|
||||
|
||||
AutoPipe startedPipe, pidPipe;
|
||||
--
|
||||
2.34.1
|
||||
|
Loading…
Reference in new issue