diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-10-08 11:35:06 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-10-10 13:26:37 +0200 |
commit | a6ece9e88a3b227b7359d85d2641e9aab9be1c7b (patch) | |
tree | d9603a6daf4f81e80003b1fa4e873852f2a25585 /src/corelib/global/qlibraryinfo.cpp | |
parent | 386768298cf2be024de673f5329c94a23dab4b90 (diff) |
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 <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib/global/qlibraryinfo.cpp')
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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; |