aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/qbs/modules/cpp/gcc.js6
-rw-r--r--tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/aggregateDependencyLinking.qbs35
-rw-r--r--tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/app.c8
-rw-r--r--tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/lib.c12
-rw-r--r--tests/auto/blackbox/tst_blackboxapple.cpp14
-rw-r--r--tests/auto/blackbox/tst_blackboxapple.h1
6 files changed, 76 insertions, 0 deletions
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js
index 5ac936eb0..896ae48fa 100644
--- a/share/qbs/modules/cpp/gcc.js
+++ b/share/qbs/modules/cpp/gcc.js
@@ -157,6 +157,12 @@ function collectLibraryDependencies(product, isDarwin) {
var nextIsBelowIndirectDynamicLib = isBelowIndirectDynamicLib || isDynamicLibrary;
dep.dependencies.forEach(function(depdep) {
+ // If "dep" is an aggregate product, and "depdep" is one of the multiplexed variants
+ // of the same product, we don't want to depend on the multiplexed variants, because
+ // that could mean linking more than one time against the same library. Instead skip
+ // the multiplexed dependency, and depend only on the aggregate one.
+ if (depdep.name === dep.name)
+ return;
traverse(depdep, nextIsBelowIndirectDynamicLib);
});
if (isStaticLibrary) {
diff --git a/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/aggregateDependencyLinking.qbs b/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/aggregateDependencyLinking.qbs
new file mode 100644
index 000000000..e7c8867bd
--- /dev/null
+++ b/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/aggregateDependencyLinking.qbs
@@ -0,0 +1,35 @@
+import qbs
+
+Project {
+ minimumQbsVersion: "1.8"
+
+ StaticLibrary {
+ name: "multi_arch_lib"
+ files: ["lib.c"]
+
+ Depends { name: "cpp" }
+ Depends { name: "bundle" }
+ bundle.isBundle: false
+
+ // This will generate 2 multiplex configs and an aggregate.
+ qbs.architectures: ["x86", "x86_64"]
+ qbs.buildVariant: "debug"
+ }
+
+ CppApplication {
+ name: "just_app"
+ files: ["app.c"]
+
+ // This should link only against the aggregate static library, and not against
+ // the {debug, x86_64} variant, or worse - against both the single arch variant
+ // and the lipo-ed one.
+ Depends { name: "multi_arch_lib" }
+
+ Depends { name: "bundle" }
+ bundle.isBundle: false
+
+ qbs.architecture: "x86_64"
+ qbs.buildVariant: "debug"
+ multiplexByQbsProperties: []
+ }
+}
diff --git a/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/app.c b/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/app.c
new file mode 100644
index 000000000..ae414324b
--- /dev/null
+++ b/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/app.c
@@ -0,0 +1,8 @@
+extern int foo();
+
+int main(int argc, char *argv[]) {
+ (void) argc;
+ (void) argv;
+
+ return foo();
+}
diff --git a/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/lib.c b/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/lib.c
new file mode 100644
index 000000000..9ef95547b
--- /dev/null
+++ b/tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/lib.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+int foo()
+{
+#ifdef __i386__
+ printf("Hello from i386\n");
+#endif
+#ifdef __x86_64__
+ printf("Hello from x86_64\n");
+#endif
+ return 0;
+}
diff --git a/tests/auto/blackbox/tst_blackboxapple.cpp b/tests/auto/blackbox/tst_blackboxapple.cpp
index 6fc526cd8..c08cc9759 100644
--- a/tests/auto/blackbox/tst_blackboxapple.cpp
+++ b/tests/auto/blackbox/tst_blackboxapple.cpp
@@ -145,6 +145,20 @@ void TestBlackboxApple::appleMultiConfig()
}
}
+void TestBlackboxApple::aggregateDependencyLinking()
+{
+ if (HostOsInfo::hostOsVersion() > qbs::Version(10, 13, 4))
+ QSKIP("32-bit arch build is no longer supported on macOS versions higher than 10.13.4.");
+
+ QDir::setCurrent(testDataDir + "/aggregateDependencyLinking");
+ QCOMPARE(runQbs(QStringList{"-p", "multi_arch_lib"}), 0);
+
+ QCOMPARE(runQbs(QStringList{"-p", "just_app", "--command-echo-mode", "command-line"}), 0);
+ int linkedInLibrariesCount =
+ QString::fromUtf8(m_qbsStdout).count(QStringLiteral("multi_arch_lib.a"));
+ QCOMPARE(linkedInLibrariesCount, 1);
+}
+
void TestBlackboxApple::assetCatalog()
{
QFETCH(bool, flatten);
diff --git a/tests/auto/blackbox/tst_blackboxapple.h b/tests/auto/blackbox/tst_blackboxapple.h
index 05e0d8acd..76711ddf5 100644
--- a/tests/auto/blackbox/tst_blackboxapple.h
+++ b/tests/auto/blackbox/tst_blackboxapple.h
@@ -47,6 +47,7 @@ public slots:
private slots:
void appleMultiConfig();
+ void aggregateDependencyLinking();
void assetCatalog();
void assetCatalog_data();
void assetCatalogsEmpty();