From 34b27e650f2c1033e5e92c57beeccc5aabcd3f63 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 18 Dec 2019 15:19:58 +0100 Subject: windeployqt: Fix deployment of MinGW/release with debug info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the debug detection to match debug or release for anything except Msvc/ClangMsvc, effectively turning the check off. Msvc/ClangMsvc are the only remaining compilers for which distinct debug/release binaries are generated by debug-and-release due to the different runtimes. Fixes: QTBUG-80806 Task-number: QTBUG-80763 Task-number: QTBUG-78445 Change-Id: I85f170787c45a08cc28f37caa54e152dd7191e0f Reviewed-by: Oliver Wolff Reviewed-by: Qt CI Bot Reviewed-by: André de la Rocha --- src/windeployqt/main.cpp | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp index 71b6e1258..bae019150 100644 --- a/src/windeployqt/main.cpp +++ b/src/windeployqt/main.cpp @@ -1246,9 +1246,26 @@ static DeployResult deploy(const Options &options, } } - const bool isDebug = options.debugDetection == Options::DebugDetectionAuto ? detectedDebug: options.debugDetection == Options::DebugDetectionForceDebug; - result.isDebug = isDebug; - const DebugMatchMode debugMatchMode = isDebug ? MatchDebug : MatchRelease; + DebugMatchMode debugMatchMode = MatchDebugOrRelease; + result.isDebug = false; + switch (options.debugDetection) { + case Options::DebugDetectionAuto: + // Debug detection is only relevant for Msvc/ClangMsvc which have distinct + // runtimes and binaries. For anything else, use MatchDebugOrRelease + // since also debug cannot be reliably detect for MinGW. + if (options.platform.testFlag(Msvc) || options.platform.testFlag(ClangMsvc)) { + result.isDebug = detectedDebug; + debugMatchMode = result.isDebug ? MatchDebug : MatchRelease; + } + break; + case Options::DebugDetectionForceDebug: + result.isDebug = true; + debugMatchMode = MatchDebug; + break; + case Options::DebugDetectionForceRelease: + debugMatchMode = MatchRelease; + break; + } // Determine application type, check Quick2 is used by looking at the // direct dependencies (do not be fooled by QtWebKit depending on it). @@ -1266,7 +1283,7 @@ static DeployResult deploy(const Options &options, if (optVerboseLevel) { std::wcout << QDir::toNativeSeparators(options.binaries.first()) << ' ' - << wordSize << " bit, " << (isDebug ? "debug" : "release") + << wordSize << " bit, " << (result.isDebug ? "debug" : "release") << " executable"; if (usesQml2) std::wcout << " [QML]"; @@ -1378,7 +1395,7 @@ static DeployResult deploy(const Options &options, QString qtGuiLibrary; for (const auto &qtModule : qtModuleEntries) { if (result.deployedQtLibraries & qtModule.module) { - const QString library = libraryPath(libraryLocation, qtModule.libraryName, qtLibInfix, options.platform, isDebug); + const QString library = libraryPath(libraryLocation, qtModule.libraryName, qtLibInfix, options.platform, result.isDebug); deployedQtLibraries.append(library); if (qtModule.module == QtGuiModule) qtGuiLibrary = library; @@ -1402,11 +1419,11 @@ static DeployResult deploy(const Options &options, // Check for ANGLE on the Qt5Gui library. if (options.platform.testFlag(WindowsBased) && !qtGuiLibrary.isEmpty()) { QString libGlesName = QStringLiteral("libGLESV2"); - if (isDebug && platformHasDebugSuffix(options.platform)) + if (result.isDebug && platformHasDebugSuffix(options.platform)) libGlesName += QLatin1Char('d'); libGlesName += QLatin1String(windowsSharedLibrarySuffix); QString libCombinedQtAngleName = QStringLiteral("QtANGLE"); - if (isDebug && platformHasDebugSuffix(options.platform)) + if (result.isDebug && platformHasDebugSuffix(options.platform)) libCombinedQtAngleName += QLatin1Char('d'); libCombinedQtAngleName += QLatin1String(windowsSharedLibrarySuffix); const QStringList guiLibraries = findDependentLibraries(qtGuiLibrary, options.platform, errorMessage); @@ -1422,7 +1439,7 @@ static DeployResult deploy(const Options &options, const QString libGlesFullPath = qtBinDir + slash + libGlesName; deployedQtLibraries.append(libGlesFullPath); QString libEglFullPath = qtBinDir + slash + QStringLiteral("libEGL"); - if (isDebug && platformHasDebugSuffix(options.platform)) + if (result.isDebug && platformHasDebugSuffix(options.platform)) libEglFullPath += QLatin1Char('d'); libEglFullPath += QLatin1String(windowsSharedLibrarySuffix); deployedQtLibraries.append(libEglFullPath); @@ -1448,7 +1465,7 @@ static DeployResult deploy(const Options &options, // We need to copy ucrtbased.dll on WinRT as this library is not part of // the c runtime package. VS 2015 does the same when deploying to a device // or creating an appx. - if (isDebug && options.platform == WinRtArmMsvc + if (result.isDebug && options.platform == WinRtArmMsvc && qmakeVariables.value(QStringLiteral("QMAKE_XSPEC")).endsWith(QLatin1String("msvc2015"))) { const QString extensionPath = QString::fromLocal8Bit(qgetenv("ExtensionSdkDir")); const QString ucrtVersion = QString::fromLocal8Bit(qgetenv("UCRTVersion")); @@ -1478,7 +1495,7 @@ static DeployResult deploy(const Options &options, options.directory : options.libraryDirectory; QStringList libraries = deployedQtLibraries; if (options.compilerRunTime) - libraries.append(compilerRunTimeLibs(options.platform, isDebug, machineArch)); + libraries.append(compilerRunTimeLibs(options.platform, result.isDebug, machineArch)); for (const QString &qtLib : qAsConst(libraries)) { if (!updateLibrary(qtLib, targetPath, options, errorMessage)) return result; @@ -1486,7 +1503,7 @@ static DeployResult deploy(const Options &options, if (options.patchQt && !options.dryRun && !options.isWinRt()) { const QString qt5CoreName = QFileInfo(libraryPath(libraryLocation, "Qt5Core", qtLibInfix, - options.platform, isDebug)).fileName(); + options.platform, result.isDebug)).fileName(); #ifndef QT_RELOCATABLE if (!patchQtCore(targetPath + QLatin1Char('/') + qt5CoreName, errorMessage)) { std::wcerr << "Warning: " << *errorMessage << '\n'; -- cgit v1.2.3