From a6ece9e88a3b227b7359d85d2641e9aab9be1c7b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 8 Oct 2019 11:35:06 +0200 Subject: Fix relocatable prefix for hardware-specific Linux builds Since Qt 5.3.0 we recommend that Linux distributions place a SSE2-enabled copy of QtCore in a $PREFIX/lib/sse2 subdirectory (see Qt 5.3.0 changelog for details). Same for other hardware capabilities like AVX2 and AVX512. This use case was broken with the introduction of the 'relocatable' feature, because the prefix is determined from the location of libQt5Core.so and the relative path from libdir to prefix, which is baked in at configure time. We now try to locate the libdir below the prefix, and if that fails try again in the upper directories. Fixes: QTBUG-78948 Change-Id: Ieec6e1484974e19335cf08ae0df3ee5c0e316d28 Reviewed-by: Alexandru Croitor --- src/corelib/global/qlibraryinfo.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/corelib/global/qlibraryinfo.cpp') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 6476b7404a..8bcf67e73d 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -569,6 +569,23 @@ static QString getRelocatablePrefix() #error "The chosen platform / config does not support querying for a dynamic prefix." #endif +#if defined(Q_OS_LINUX) && !defined(QT_STATIC) && defined(__GLIBC__) + // QTBUG-78948: libQt5Core.so may be located in subdirectories below libdir. + // See "Hardware capabilities" in the ld.so documentation and the Qt 5.3.0 + // changelog regarding SSE2 support. + const QString libdir = QString::fromLatin1( + qt_configure_strs + qt_configure_str_offsets[QLibraryInfo::LibrariesPath - 1]); + QDir prefixDir(prefixPath); + while (!prefixDir.exists(libdir)) { + prefixDir.cdUp(); + prefixPath = prefixDir.absolutePath(); + if (prefixDir.isRoot()) { + prefixPath.clear(); + break; + } + } +#endif + Q_ASSERT_X(!prefixPath.isEmpty(), "getRelocatablePrefix", "Failed to find the Qt prefix path."); return prefixPath; -- cgit v1.2.3