qmake: link qt libraries by full path

this avoids the scenario where the linker would pick up the wrong qt
libraries for LIBS_PRIVATE because LIBS added the "wrong" path first.
this is also consistent with configure-supplied dependencies as of
recently.

as a side effect, this also removes pretenses of lsb linker handling, as
it makes no sense after the change and is certainly obsolete anyway.

Fixes: QTBUG-50921
Change-Id: I84398c9143f393c2eefb3c69a31bd9f633669924
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Oswald Buddenhagen 2018-12-19 12:46:52 +01:00 committed by Joerg Bornemann
parent 2a815855a9
commit 5b3dfa470e
4 changed files with 28 additions and 27 deletions

View File

@ -145,12 +145,14 @@ import_plugins:qtConfig(static) {
# the plugin path. Unknown plugins must rely on the default link path.
plug_type = $$eval(QT_PLUGIN.$${plug}.TYPE)
!isEmpty(plug_type) {
plug_name = $$QMAKE_PREFIX_STATICLIB$${plug}$$qtPlatformTargetSuffix().$$QMAKE_EXTENSION_STATICLIB
plug_path = $$eval(QT_PLUGIN.$${plug}.PATH)
isEmpty(plug_path): \
plug_path = $$[QT_INSTALL_PLUGINS/get]
LIBS += -L$$plug_path/$$plug_type
LIBS += $$plug_path/$$plug_type/$$plug_name
} else {
LIBS += -l$${plug}$$qtPlatformTargetSuffix()
}
LIBS += -l$${plug}$$qtPlatformTargetSuffix()
}
}
@ -195,8 +197,6 @@ for(ever) {
qtProcessModuleFlags(DEFINES, QT.$${QTLIB}.DEFINES)
MODULE_INCLUDES -= $$QMAKE_DEFAULT_INCDIRS
MODULE_LIBS_ADD = $$MODULE_LIBS
MODULE_LIBS_ADD -= $$QMAKE_DEFAULT_LIBDIRS
# Frameworks shouldn't need include paths, but much code does not use
# module-qualified #includes, so by default we add paths which point
@ -209,23 +209,17 @@ for(ever) {
!isEmpty(MODULE_MODULE) {
contains(MODULE_CONFIG, lib_bundle) {
framework = $$MODULE_MODULE
# Linking frameworks by absolute path does not work.
LIBS$$var_sfx += -framework $$framework
} else {
!isEmpty(MODULE_LIBS_ADD): \
LIBS$$var_sfx += -L$$MODULE_LIBS_ADD
lib = $$MODULE_MODULE$$qtPlatformTargetSuffix()
LIBS$$var_sfx += -l$$lib
contains(MODULE_CONFIG, staticlib): \
PRE_TARGETDEPS *= $$MODULE_LIBS/$${QMAKE_PREFIX_STATICLIB}$${lib}.$${QMAKE_EXTENSION_STATICLIB}
!isEmpty(QMAKE_LSB) {
!isEmpty(MODULE_LIBS_ADD): \
QMAKE_LFLAGS *= --lsb-libpath=$$MODULE_LIBS_ADD
QMAKE_LFLAGS *= --lsb-shared-libs=$$lib
QMAKE_LIBDIR *= /opt/lsb/lib
win32|contains(MODULE_CONFIG, staticlib) {
lib = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB$${lib}.$$QMAKE_EXTENSION_STATICLIB
PRE_TARGETDEPS += $$lib
} else {
lib = $$MODULE_LIBS/$$QMAKE_PREFIX_SHLIB$${lib}.$$QMAKE_EXTENSION_SHLIB
}
LIBS$$var_sfx += $$lib
}
}
QMAKE_USE$$var_sfx += $$MODULE_USES
@ -295,7 +289,8 @@ contains(all_qt_module_deps, qml): \
for (key, IMPORTS._KEYS_) {
PATH = $$eval(IMPORTS.$${key}.path)
PLUGIN = $$eval(IMPORTS.$${key}.plugin)
!isEmpty(PATH):!isEmpty(PLUGIN): LIBS *= -L$$PATH -l$${PLUGIN}$$qtPlatformTargetSuffix()
!isEmpty(PATH):!isEmpty(PLUGIN): \
LIBS += $$PATH/$$QMAKE_PREFIX_STATICLIB$${PLUGIN}$$qtPlatformTargetSuffix().$$QMAKE_EXTENSION_STATICLIB
}
# create qml_plugin_import.cpp

View File

@ -1,13 +1,21 @@
QT_FOR_CONFIG += gui
defineTest(prependOpenGlLib) {
path = $$QT.core.libs/$$QMAKE_PREFIX_STATICLIB$$1
ext = .$$QMAKE_EXTENSION_STATICLIB
QMAKE_LIBS_OPENGL_ES2 = $${path}$${ext} $$QMAKE_LIBS_OPENGL_ES2
QMAKE_LIBS_OPENGL_ES2_DEBUG = $${path}d$${ext} $$QMAKE_LIBS_OPENGL_ES2_DEBUG
export(QMAKE_LIBS_OPENGL_ES2)
export(QMAKE_LIBS_OPENGL_ES2_DEBUG)
}
qtConfig(opengles2) {
# Depending on the configuration we use libQtANGLE or libEGL and libGLESv2
qtConfig(combined-angle-lib) {
QMAKE_LIBS_OPENGL_ES2 = -l$${LIBQTANGLE_NAME} $$QMAKE_LIBS_OPENGL_ES2
QMAKE_LIBS_OPENGL_ES2_DEBUG = -l$${LIBQTANGLE_NAME}d $$QMAKE_LIBS_OPENGL_ES2_DEBUG
prependOpenGlLib($$LIBQTANGLE_NAME)
} else {
QMAKE_LIBS_OPENGL_ES2 = -l$${LIBEGL_NAME} -l$${LIBGLESV2_NAME} $$QMAKE_LIBS_OPENGL_ES2
QMAKE_LIBS_OPENGL_ES2_DEBUG = -l$${LIBEGL_NAME}d -l$${LIBGLESV2_NAME}d $$QMAKE_LIBS_OPENGL_ES2_DEBUG
prependOpenGlLib($$LIBGLESV2_NAME)
prependOpenGlLib($$LIBEGL_NAME)
}
# For Desktop, use the ANGLE library location passed on from configure.
INCLUDEPATH += $$QMAKE_INCDIR_OPENGL_ES2

View File

@ -6,10 +6,9 @@ contains(TEMPLATE, ".*app") {
qt:for(entryLib, $$list($$unique(QMAKE_LIBS_QT_ENTRY))) {
isEqual(entryLib, -lqtmain) {
!contains(QMAKE_DEFAULT_LIBDIRS, $$QT.core.libs): \
QMAKE_LIBS += -L$$QT.core.libs
CONFIG(debug, debug|release): QMAKE_LIBS += $${entryLib}$${QT_LIBINFIX}d
else: QMAKE_LIBS += $${entryLib}$${QT_LIBINFIX}
lib = $$QT.core.libs/$${QMAKE_PREFIX_STATICLIB}qtmain$$QT_LIBINFIX$$qtPlatformTargetSuffix().$$QMAKE_EXTENSION_STATICLIB
PRE_TARGETDEPS += $$lib
QMAKE_LIBS += $$lib
} else {
QMAKE_LIBS += $${entryLib}
}

View File

@ -13,7 +13,6 @@ load(qt_config)
QMAKE_LIBS_THREAD += -lrt
QMAKE_LSB = 1
QMAKE_CC = lsbcc
QMAKE_CXX = lsbc++