commit:     34215c570dac0cf122f3d0e54209f061c5d6264f
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Sun Mar  2 22:42:38 2025 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Mon Mar  3 22:38:19 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=34215c57

dev-qt/qtbase: Patch Qt6Config.cmake to fix cross-compiling other packages

It's a long story involving CMAKE_FIND_ROOT_PATH. See the patch for details.

Closes: https://bugs.gentoo.org/950314
Closes: https://github.com/gentoo/gentoo/pull/40856
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>

 dev-qt/qtbase/files/qtbase-6.8.2-cross.patch | 36 ++++++++++++++++++++++++++++
 dev-qt/qtbase/qtbase-6.8.2-r2.ebuild         |  1 +
 dev-qt/qtbase/qtbase-6.8.9999.ebuild         |  1 +
 dev-qt/qtbase/qtbase-6.9.9999.ebuild         |  1 +
 dev-qt/qtbase/qtbase-6.9999.ebuild           |  1 +
 5 files changed, 40 insertions(+)

diff --git a/dev-qt/qtbase/files/qtbase-6.8.2-cross.patch 
b/dev-qt/qtbase/files/qtbase-6.8.2-cross.patch
new file mode 100644
index 000000000000..b597aa38d107
--- /dev/null
+++ b/dev-qt/qtbase/files/qtbase-6.8.2-cross.patch
@@ -0,0 +1,36 @@
+When cross-compiling, CMake needs to find the build host's Qt6CoreTools. It
+therefore prepends QT_HOST_PATH, which is /usr, to CMAKE_FIND_ROOT_PATH. The
+problem is that CMAKE_FIND_ROOT_PATH is only a hint, not a definitive
+location. Just below, CMake's find_package is usually told to look in
+/usr/${CHOST}/usr/lib/cmake and /usr/lib/cmake when cross-compiling. Since
+both of these are under /usr, it chooses the former instead of the latter.
+It then ends up trying to execute non-native Qt binaries.
+
+We can avoid this problem by setting CMAKE_FIND_ROOT_PATH to a more precise
+location. All the Qt6 modules are installed under /usr/lib/cmake, represented
+by the __qt_find_package_host_qt_path variable, so we can point it there.
+
+find_package has two modes, module mode and config mode. No mode is
+explicitly chosen in this case, so it tries both. In module mode, it would
+use a module called FindQt6*.cmake, but no such module exists. It is
+therefore safe to assume config mode, which involves the files under
+/usr/lib/cmake.
+
+See the isSameDirectoryOrSubDirectory() call in CMake's
+cmFindCommon::RerootPaths() function for exactly where this goes wrong.
+
+Chewi
+
+https://bugs.gentoo.org/950314
+
+--- a/cmake/QtConfig.cmake.in
++++ b/cmake/QtConfig.cmake.in
+@@ -131,7 +131,7 @@
+         set(__qt_backup_cmake_find_root_path "${CMAKE_FIND_ROOT_PATH}")
+         list(PREPEND CMAKE_PREFIX_PATH "${__qt_find_package_host_qt_path}"
+             ${_qt_additional_host_packages_prefix_paths})
+-        list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}"
++        list(PREPEND CMAKE_FIND_ROOT_PATH "${__qt_find_package_host_qt_path}"
+             ${_qt_additional_host_packages_root_paths})
+     endif()
+ 

diff --git a/dev-qt/qtbase/qtbase-6.8.2-r2.ebuild 
b/dev-qt/qtbase/qtbase-6.8.2-r2.ebuild
index 08f1610075ec..fd2849534194 100644
--- a/dev-qt/qtbase/qtbase-6.8.2-r2.ebuild
+++ b/dev-qt/qtbase/qtbase-6.8.2-r2.ebuild
@@ -146,6 +146,7 @@ PATCHES=(
        "${FILESDIR}"/${PN}-6.6.1-forkfd-childstack-size.patch
        "${FILESDIR}"/${PN}-6.6.3-gcc14-avx512fp16.patch
        "${FILESDIR}"/${PN}-6.8.0-qcontiguouscache.patch
+       "${FILESDIR}"/${PN}-6.8.2-cross.patch
        "${FILESDIR}"/${P}-QTBUG-133500.patch
        "${FILESDIR}"/${P}-QTBUG-133808.patch
 )

diff --git a/dev-qt/qtbase/qtbase-6.8.9999.ebuild 
b/dev-qt/qtbase/qtbase-6.8.9999.ebuild
index 6eeb224df3dd..48ee516e8b4b 100644
--- a/dev-qt/qtbase/qtbase-6.8.9999.ebuild
+++ b/dev-qt/qtbase/qtbase-6.8.9999.ebuild
@@ -146,6 +146,7 @@ PATCHES=(
        "${FILESDIR}"/${PN}-6.6.1-forkfd-childstack-size.patch
        "${FILESDIR}"/${PN}-6.6.3-gcc14-avx512fp16.patch
        "${FILESDIR}"/${PN}-6.8.0-qcontiguouscache.patch
+       "${FILESDIR}"/${PN}-6.8.2-cross.patch
 )
 
 src_prepare() {

diff --git a/dev-qt/qtbase/qtbase-6.9.9999.ebuild 
b/dev-qt/qtbase/qtbase-6.9.9999.ebuild
index b27a756c0106..58e3064e4a82 100644
--- a/dev-qt/qtbase/qtbase-6.9.9999.ebuild
+++ b/dev-qt/qtbase/qtbase-6.9.9999.ebuild
@@ -145,6 +145,7 @@ PATCHES=(
        "${FILESDIR}"/${PN}-6.5.2-no-symlink-check.patch
        "${FILESDIR}"/${PN}-6.6.1-forkfd-childstack-size.patch
        "${FILESDIR}"/${PN}-6.6.3-gcc14-avx512fp16.patch
+       "${FILESDIR}"/${PN}-6.8.2-cross.patch
 )
 
 src_prepare() {

diff --git a/dev-qt/qtbase/qtbase-6.9999.ebuild 
b/dev-qt/qtbase/qtbase-6.9999.ebuild
index b27a756c0106..58e3064e4a82 100644
--- a/dev-qt/qtbase/qtbase-6.9999.ebuild
+++ b/dev-qt/qtbase/qtbase-6.9999.ebuild
@@ -145,6 +145,7 @@ PATCHES=(
        "${FILESDIR}"/${PN}-6.5.2-no-symlink-check.patch
        "${FILESDIR}"/${PN}-6.6.1-forkfd-childstack-size.patch
        "${FILESDIR}"/${PN}-6.6.3-gcc14-avx512fp16.patch
+       "${FILESDIR}"/${PN}-6.8.2-cross.patch
 )
 
 src_prepare() {

Reply via email to