fix: update Qt cross-compile toolchain and remove absorbed patches

Remove absorbed qtbase include and OpenGL guard patches. Update
toolchain cmake for cross-compile. Fix QtWayland cursor guards.
This commit is contained in:
2026-05-11 10:09:34 +01:00
parent 2b8dd96a5c
commit e5366f3ce5
5 changed files with 77 additions and 92 deletions
@@ -1 +0,0 @@
../../../../local/patches/qtbase/P0-fix-broken-include.patch
@@ -1 +0,0 @@
../../../../local/patches/qtbase/P1-qplatformopengl-guard.patch
@@ -1,71 +0,0 @@
--- source/src/plugins/platforms/wayland/qwaylandcursor.cpp
+++ source/src/plugins/platforms/wayland/qwaylandcursor.cpp
@@ -177,6 +177,10 @@ wl_cursor *QWaylandCursorTheme::requestCursor(WaylandCursor shape)
ShapeAndName{shape, ""}, byShape);
for (auto it = p.first; it != p.second; ++it) {
if (wl_cursor *cursor = wl_cursor_theme_get_cursor(m_theme, it->name)) {
+ if (cursor->image_count == 0 || !cursor->images || !cursor->images[0]) {
+ qCWarning(lcQpaWayland) << "Ignoring empty Wayland cursor" << it->name;
+ continue;
+ }
m_cursors[shape] = cursor;
return cursor;
}
--- source/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
+++ source/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
@@ -225,6 +225,10 @@ void QWaylandInputDevice::Pointer::updateCursorTheme()
return; // A warning has already been printed in loadCursorTheme
if (auto *arrow = mCursor.theme->cursor(Qt::ArrowCursor)) {
+ if (arrow->image_count == 0 || !arrow->images || !arrow->images[0]) {
+ qCWarning(lcQpaWayland) << "Cursor theme returned an empty arrow cursor";
+ return;
+ }
int arrowPixelSize = qMax(arrow->images[0]->width, arrow->images[0]->height); // Not all cursor themes are square
while (scale > 1 && arrowPixelSize / scale < cursorSize.width())
--scale;
@@ -279,8 +283,16 @@ void QWaylandInputDevice::Pointer::updateCursor()
if (struct ::wl_cursor *waylandCursor = mCursor.theme->cursor(shape)) {
+ if (waylandCursor->image_count == 0 || !waylandCursor->images) {
+ qCWarning(lcQpaWayland) << "Cursor theme returned an empty cursor" << shape;
+ return;
+ }
uint duration = 0;
int frame = wl_cursor_frame_and_duration(waylandCursor, time, &duration);
+ if (frame < 0 || uint(frame) >= waylandCursor->image_count || !waylandCursor->images[frame]) {
+ qCWarning(lcQpaWayland) << "Cursor theme returned an invalid cursor frame" << shape << frame;
+ return;
+ }
::wl_cursor_image *image = waylandCursor->images[frame];
struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
--- source/src/plugins/platforms/wayland/qwaylandtabletv2.cpp
+++ source/src/plugins/platforms/wayland/qwaylandtabletv2.cpp
@@ -62,6 +62,10 @@ void QWaylandTabletToolV2::updateCursorTheme()
return; // A warning has already been printed in loadCursorTheme
if (auto *arrow = mCursor.theme->cursor(Qt::ArrowCursor)) {
+ if (arrow->image_count == 0 || !arrow->images || !arrow->images[0]) {
+ qCWarning(lcQpaWayland) << "Cursor theme returned an empty tablet arrow cursor";
+ return;
+ }
int arrowPixelSize = qMax(arrow->images[0]->width,
arrow->images[0]->height); // Not all cursor themes are square
while (scale > 1 && arrowPixelSize / scale < cursorSize.width())
@@ -117,8 +121,16 @@ void QWaylandTabletToolV2::updateCursor()
if (struct ::wl_cursor *waylandCursor = mCursor.theme->cursor(shape)) {
+ if (waylandCursor->image_count == 0 || !waylandCursor->images) {
+ qCWarning(lcQpaWayland) << "Cursor theme returned an empty tablet cursor" << shape;
+ return;
+ }
uint duration = 0;
int frame = wl_cursor_frame_and_duration(waylandCursor, time, &duration);
+ if (frame < 0 || uint(frame) >= waylandCursor->image_count || !waylandCursor->images[frame]) {
+ qCWarning(lcQpaWayland) << "Cursor theme returned an invalid tablet cursor frame" << shape << frame;
+ return;
+ }
::wl_cursor_image *image = waylandCursor->images[frame];
struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
@@ -0,0 +1 @@
../../../../local/patches/qtbase/qtwayland-empty-cursor-guards.patch
+74 -17
View File
@@ -6,6 +6,7 @@
tar = "https://download.qt.io/official_releases/qt/6.8/6.8.2/submodules/qtbase-everywhere-src-6.8.2.tar.xz"
patches = [
"qtwaylandscanner-null-guard-listeners.patch",
"qtwayland-empty-cursor-guards.patch",
]
[build]
@@ -105,8 +106,8 @@ mkdir -p "${COOKBOOK_STAGE}/usr/lib"
cp -f "${COOKBOOK_SYSROOT}/lib/libredbear-qt-strtold-compat.so" "${COOKBOOK_STAGE}/usr/lib/"
export LDFLAGS="${LDFLAGS} -Wl,--no-as-needed -L${COOKBOOK_SYSROOT}/lib -lredbear-qt-strtold-compat -lffi -lc"
export CFLAGS="${CFLAGS} -fcf-protection=none"
export CXXFLAGS="${CXXFLAGS} -fcf-protection=none"
export CFLAGS="${CFLAGS} -fcf-protection=none -DST_RDONLY=1 -DST_NOSUID=2"
export CXXFLAGS="${CXXFLAGS} -fcf-protection=none -DST_RDONLY=1 -DST_NOSUID=2"
# Mesa's Redox sysroot currently exposes GLES2 headers but not the GLES3 wrapper headers
# that qtbase expects when building the ES-backed OpenGL path. Provide minimal forwarding
@@ -212,19 +213,31 @@ rm -rf "${COOKBOOK_SOURCE}/CMakeFiles"
# qstorageinfo_linux.cpp (compiled when LINUX=1 in CMake) includes sys/statfs.h.
# Alias statfs → statvfs so it compiles against relibc's POSIX API.
mkdir -p "${COOKBOOK_SYSROOT}/include/sys"
if [ ! -f "${COOKBOOK_SYSROOT}/include/sys/statfs.h" ]; then
cat > "${COOKBOOK_SYSROOT}/include/sys/statfs.h" << 'STATFS_EOF'
cat > "${COOKBOOK_SYSROOT}/include/sys/statfs.h" << 'STATFS_EOF'
#ifndef _SYS_STATFS_H
#define _SYS_STATFS_H
/* Redox: relibc provides statvfs (POSIX), not Linux statfs.
Provide a compatibility shim so Linux-targeted code compiles. */
#include <sys/statvfs.h>
typedef struct statvfs statfs;
#define statfs statvfs
#define f_flags f_flag
#endif /* _SYS_STATFS_H */
#ifndef ST_RDONLY
#define ST_RDONLY 1
#endif
#ifndef ST_NOSUID
#define ST_NOSUID 2
#endif
#endif
STATFS_EOF
fi
cat > "${COOKBOOK_SYSROOT}/include/byteswap.h" << 'BYTESWAP_EOF'
#ifndef _BYTESWAP_H
#define _BYTESWAP_H
#include <stdint.h>
static inline uint16_t bswap_16(uint16_t x) { return __builtin_bswap16(x); }
static inline uint32_t bswap_32(uint32_t x) { return __builtin_bswap32(x); }
static inline uint64_t bswap_64(uint64_t x) { return __builtin_bswap64(x); }
#endif
BYTESWAP_EOF
# Ensure private forwarding headers exist for Unix-specific includes
# syncqt may not generate these for unknown platforms like Redox
@@ -388,26 +401,39 @@ if marker not in text:
backend.write_text(text)
PY
# QtGui needs the float16 shims — copy to gui dir and append to first SOURCES line
# QtCore needs the float16 shims — insert them into the Core module's first SOURCES block
if [ -f "${COOKBOOK_SOURCE}/src/corelib/global/qt_float16_shims.c" ]; then
cp "${COOKBOOK_SOURCE}/src/corelib/global/qt_float16_shims.c" \
"${COOKBOOK_SOURCE}/src/gui/painting/qt_float16_shims.c"
fi
if [ -f "${COOKBOOK_SOURCE}/src/gui/painting/qt_float16_shims.c" ]; then
python - <<'PY'
import os
from pathlib import Path
path = Path(os.environ["COOKBOOK_SOURCE"]) / "src/gui/CMakeLists.txt"
path = Path(os.environ["COOKBOOK_SOURCE"]) / "src/corelib/CMakeLists.txt"
lines = path.read_text().splitlines()
out = []
in_core = False
inserted = False
for line in lines:
if line.strip() == "painting/qt_float16_shims.c":
stripped = line.strip()
if stripped == "global/qt_float16_shims.c":
continue
if not in_core and stripped.startswith("qt_internal_add_module(Core"):
in_core = True
out.append(line)
if not inserted and line.strip() == "SOURCES":
out.append(" painting/qt_float16_shims.c")
if in_core and not inserted and stripped == "SOURCES":
out.append(" global/qt_float16_shims.c")
inserted = True
if in_core and stripped == ")":
in_core = False
if not inserted:
raise SystemExit("Core SOURCES block not found for qt_float16_shims.c insertion")
path.write_text("\\n".join(out) + "\\n")
PY
fi
@@ -590,6 +616,37 @@ if needle in text and "#ifdef Q_OS_REDOX" not in text:
path.write_text(text)
PY
# Patch qsystemdetection.h to define Q_OS_REDOX for the __redox__ target macro
QSYSDET="${COOKBOOK_SOURCE}/src/corelib/global/qsystemdetection.h"
if ! grep -q 'Q_OS_REDOX' "${QSYSDET}" 2>/dev/null; then
python - <<'PY'
import os
p = os.environ["COOKBOOK_SOURCE"] + "/src/corelib/global/qsystemdetection.h"
t = open(p).read()
if "Q_OS_REDOX" not in t:
old = "#elif defined(__MAKEDEPEND__)"
new = "#elif defined(__redox__)\\n# define Q_OS_REDOX\\n#elif defined(__MAKEDEPEND__)"
t = t.replace(old, new)
open(p, "w").write(t)
PY
fi
# Redox is inherently 64-bit (off_t is always 64-bit) — no need for LFS64 compat.
# Undefine QT_USE_XOPEN_LFS_EXTENSIONS on Redox so Qt uses the non-64 code path
# (open, stat, lseek instead of open64, stat64, lseek64, etc.).
QPLATDEFS="${COOKBOOK_SOURCE}/mkspecs/common/posix/qplatformdefs.h"
if ! grep -q 'Q_OS_REDOX.*LFS' "${QPLATDEFS}" 2>/dev/null; then
python - <<'PY'
import os
from pathlib import Path
path = Path(os.environ["COOKBOOK_SOURCE"]) / "mkspecs/common/posix/qplatformdefs.h"
text = path.read_text()
guard = "#ifdef Q_OS_REDOX\\n#undef QT_USE_XOPEN_LFS_EXTENSIONS\\n#undef QT_LARGEFILE_SUPPORT\\n#ifndef O_LARGEFILE\\n#define O_LARGEFILE 0\\n#endif\\n#endif\\n"
text = guard + "\\n" + text
path.write_text(text)
PY
fi
cmake "${COOKBOOK_SOURCE}" \
-GNinja \
-DCMAKE_TOOLCHAIN_FILE="${COOKBOOK_ROOT}/local/recipes/qt/redox-toolchain.cmake" \
+2 -2
View File
@@ -166,8 +166,8 @@ set(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1)
# --- Redox POSIX compatibility shims ---
# relibc's assert.h does not define static_assert (C11 macro). Provide it for C only
# (C++ has it as a keyword — redefining would cause errors in try_compile checks).
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dstatic_assert=_Static_assert -DP_ALL=0 -DP_PID=1 -DP_PGID=2 -Dvfork=fork" CACHE STRING "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DP_ALL=0 -DP_PID=1 -DP_PGID=2 -Dvfork=fork" CACHE STRING "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dstatic_assert=_Static_assert -DP_ALL=0 -DP_PID=1 -DP_PGID=2 -Dvfork=fork -DST_RDONLY=1 -DST_NOSUID=2" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DP_ALL=0 -DP_PID=1 -DP_PGID=2 -Dvfork=fork -DST_RDONLY=1 -DST_NOSUID=2" CACHE STRING "" FORCE)
# relibc now provides waitid() itself, but qtbase/forkfd still does not reliably pick up the
# P_PID / P_PGID / P_ALL constants through the active cross-build include path, so keep the