diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2021-11-12 14:07:28 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2021-12-06 10:35:17 +0000 |
commit | 4e2f84bea2efeb96f7c571e110e55d8efeefde63 (patch) | |
tree | e2f342978ac261e2706c5d79b2ffeabc5cf257c3 /tests/auto/blackbox/tst_blackboxqt.cpp | |
parent | c470f57036b3b60acf68f931faff33bfd094f23e (diff) | |
download | qbs-4e2f84bea2efeb96f7c571e110e55d8efeefde63.tar.gz |
Ignore weak symbols when re-linking in non-strict mode
Weak symbols can very easily get pulled into binaries. Make sure this
does not mess with our re-linking detection logic.
Change-Id: I013cc12728528e684d6cd4ba3c61cb56f1f854b4
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Diffstat (limited to 'tests/auto/blackbox/tst_blackboxqt.cpp')
-rw-r--r-- | tests/auto/blackbox/tst_blackboxqt.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/blackbox/tst_blackboxqt.cpp b/tests/auto/blackbox/tst_blackboxqt.cpp index 1702d4ad6..5d825f8ec 100644 --- a/tests/auto/blackbox/tst_blackboxqt.cpp +++ b/tests/auto/blackbox/tst_blackboxqt.cpp @@ -285,6 +285,57 @@ void TestBlackboxQt::mocSameFileName() QCOMPARE(m_qbsStdout.count("compiling moc_someclass.cpp"), 2); } +void TestBlackboxQt::noRelinkOnQDebug() +{ + QFETCH(QString, checkMode); + QFETCH(bool, expectRelink); + + QVERIFY(QDir::setCurrent(testDataDir + "/no-relink-on-qdebug")); + rmDirR("default"); + + // Target check. + QCOMPARE(runQbs(QbsRunParameters("resolve")), 0); + QVERIFY2(m_qbsStdout.contains("is GCC: "), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("is MinGW: "), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("is Darwin: "), m_qbsStdout.constData()); + const bool isGCCLike = m_qbsStdout.contains("is GCC: true"); + const bool isMingw = m_qbsStdout.contains("is MinGW: true"); + const bool isDarwin = m_qbsStdout.contains("is Darwin: true"); + if (!isGCCLike) + expectRelink = false; + else if (isMingw || isDarwin) + expectRelink = true; + + // Initial build. + QbsRunParameters params("resolve"); + if (isGCCLike && !checkMode.isEmpty()) + params.arguments << ("modules.cpp.exportedSymbolsCheckMode:" + checkMode); + QCOMPARE(runQbs(params), 0); + QCOMPARE(runQbs(), 0); + QCOMPARE(m_qbsStdout.count("linking"), 2); + + // Inserting the qDebug() statement will pull in weak symbols. + WAIT_FOR_NEW_TIMESTAMP(); + REPLACE_IN_FILE("lib.cpp", "// qDebug", "qDebug"); + QCOMPARE(runQbs(), 0); + QCOMPARE(m_qbsStdout.count("linking"), expectRelink ? 2 : 1); + + // Also check the opposite case. + WAIT_FOR_NEW_TIMESTAMP(); + REPLACE_IN_FILE("lib.cpp", "qDebug", "// qDebug"); + QCOMPARE(runQbs(), 0); + QCOMPARE(m_qbsStdout.count("linking"), expectRelink ? 2 : 1); +} + +void TestBlackboxQt::noRelinkOnQDebug_data() +{ + QTest::addColumn<QString>("checkMode"); + QTest::addColumn<bool>("expectRelink"); + QTest::newRow("default") << QString() << false; + QTest::newRow("relaxed") << QString("ignore-undefined") << false; + QTest::newRow("strict") << QString("strict") << true; +} + void TestBlackboxQt::pkgconfig() { QDir::setCurrent(testDataDir + "/pkgconfig"); |