Fix the qtpath issue with lto enabled

Move qtconfManualPath pointer to the unnamed namespace, so it's never
exported. Add the static setQtconfManualPath method that sets the
pointer at runtime.

Fixes: QTBUG-122739
Pick-to: 6.5 6.6 6.7
Change-Id: Icfc631f9680ad5f484920b0fdf3e408b7657c108
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Alexey Edelev 2024-02-27 17:57:05 +01:00
parent b42f174cd5
commit bdb2f20154
4 changed files with 14 additions and 7 deletions

View File

@ -188,7 +188,7 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state)
return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR;
}
if (!globals->qtconf.isEmpty())
QLibraryInfoPrivate::qtconfManualPath = &globals->qtconf;
QLibraryInfoPrivate::setQtconfManualPath(&globals->qtconf);
if (cmdRet == QMakeGlobals::ArgumentsOk)
break;
Q_ASSERT(cmdRet == QMakeGlobals::ArgumentUnknown);

View File

@ -87,10 +87,19 @@ void QLibrarySettings::load()
}
}
namespace {
const QString *qtconfManualPath = nullptr;
}
void QLibraryInfoPrivate::setQtconfManualPath(const QString *path)
{
qtconfManualPath = path;
}
static QSettings *findConfiguration()
{
if (QLibraryInfoPrivate::qtconfManualPath)
return new QSettings(*QLibraryInfoPrivate::qtconfManualPath, QSettings::IniFormat);
if (qtconfManualPath)
return new QSettings(*qtconfManualPath, QSettings::IniFormat);
QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
if (QFile::exists(qtconfig))
@ -122,8 +131,6 @@ static QSettings *findConfiguration()
return nullptr; //no luck
}
const QString *QLibraryInfoPrivate::qtconfManualPath = nullptr;
QSettings *QLibraryInfoPrivate::configuration()
{
QLibrarySettings *ls = qt_library_settings();

View File

@ -32,7 +32,7 @@ public:
#if QT_CONFIG(settings)
static QSettings *configuration();
static void reload();
static const QString *qtconfManualPath;
static void setQtconfManualPath(const QString *qtconfManualPath);
#endif
struct LocationInfo

View File

@ -224,7 +224,7 @@ int main(int argc, char **argv)
#if QT_CONFIG(settings)
if (parser.isSet(qtconf)) {
qtconfManualPath = parser.value(qtconf);
QLibraryInfoPrivate::qtconfManualPath = &qtconfManualPath;
QLibraryInfoPrivate::setQtconfManualPath(&qtconfManualPath);
}
#endif