Fix needless resolution of -l LIBS entries on Windows
Do not resolve -l entries to absolute file paths for libraries in the
default search paths.
This restores behavior from 5.12.0 (commit 2327944d
) for Windows
system libraries.
Fixes: QTBUG-78827
Change-Id: Ic2d4626df87308dd635afc1ab5c4b8191d3d2831
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
parent
85f9fa7fab
commit
ce5dc31932
@ -38,6 +38,8 @@
|
|||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
ProString Win32MakefileGenerator::fixLibFlag(const ProString &lib)
|
ProString Win32MakefileGenerator::fixLibFlag(const ProString &lib)
|
||||||
@ -73,16 +75,37 @@ Win32MakefileGenerator::parseLibFlag(const ProString &flag, ProString *arg)
|
|||||||
return LibFlagFile;
|
return LibFlagFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LibrarySearchPath : public QMakeLocalFileName
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LibrarySearchPath() = default;
|
||||||
|
|
||||||
|
LibrarySearchPath(const QString &s)
|
||||||
|
: QMakeLocalFileName(s)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LibrarySearchPath(QString &&s, bool isDefault = false)
|
||||||
|
: QMakeLocalFileName(std::move(s)), _default(isDefault)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isDefault() const { return _default; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _default = false;
|
||||||
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
|
Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
|
||||||
{
|
{
|
||||||
ProStringList impexts = project->values("QMAKE_LIB_EXTENSIONS");
|
ProStringList impexts = project->values("QMAKE_LIB_EXTENSIONS");
|
||||||
if (impexts.isEmpty())
|
if (impexts.isEmpty())
|
||||||
impexts = project->values("QMAKE_EXTENSION_STATICLIB");
|
impexts = project->values("QMAKE_EXTENSION_STATICLIB");
|
||||||
QVector<QMakeLocalFileName> dirs;
|
QVector<LibrarySearchPath> dirs;
|
||||||
int libidx = 0;
|
int libidx = 0;
|
||||||
for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS"))
|
for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS"))
|
||||||
dirs.append(QMakeLocalFileName(dlib.toQString()));
|
dirs.append(LibrarySearchPath(dlib.toQString(), true));
|
||||||
static const char * const lflags[] = { "LIBS", "LIBS_PRIVATE",
|
static const char * const lflags[] = { "LIBS", "LIBS_PRIVATE",
|
||||||
"QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", nullptr };
|
"QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", nullptr };
|
||||||
for (int i = 0; lflags[i]; i++) {
|
for (int i = 0; lflags[i]; i++) {
|
||||||
@ -92,12 +115,20 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
|
|||||||
ProString arg;
|
ProString arg;
|
||||||
LibFlagType type = parseLibFlag(opt, &arg);
|
LibFlagType type = parseLibFlag(opt, &arg);
|
||||||
if (type == LibFlagPath) {
|
if (type == LibFlagPath) {
|
||||||
QMakeLocalFileName lp(arg.toQString());
|
const QString argqstr = arg.toQString();
|
||||||
int idx = dirs.indexOf(lp);
|
auto dit = std::find_if(dirs.cbegin(), dirs.cend(),
|
||||||
|
[&argqstr](const LibrarySearchPath &p)
|
||||||
|
{
|
||||||
|
return p.real() == argqstr;
|
||||||
|
});
|
||||||
|
int idx = dit == dirs.cend()
|
||||||
|
? -1
|
||||||
|
: std::distance(dirs.cbegin(), dit);
|
||||||
if (idx >= 0 && idx < libidx) {
|
if (idx >= 0 && idx < libidx) {
|
||||||
it = l.erase(it);
|
it = l.erase(it);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const LibrarySearchPath lp(argqstr);
|
||||||
dirs.insert(libidx++, lp);
|
dirs.insert(libidx++, lp);
|
||||||
(*it) = "-L" + lp.real();
|
(*it) = "-L" + lp.real();
|
||||||
} else if (type == LibFlagLib) {
|
} else if (type == LibFlagLib) {
|
||||||
@ -114,7 +145,8 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
|
|||||||
for (ProStringList::ConstIterator extit = impexts.cbegin();
|
for (ProStringList::ConstIterator extit = impexts.cbegin();
|
||||||
extit != impexts.cend(); ++extit) {
|
extit != impexts.cend(); ++extit) {
|
||||||
if (exists(libBase + '.' + *extit)) {
|
if (exists(libBase + '.' + *extit)) {
|
||||||
(*it) = cand + verovr + '.' + *extit;
|
*it = (dir_it->isDefault() ? lib : cand)
|
||||||
|
+ verovr + '.' + *extit;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user