aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/blackbox/testdata/linkerMode
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2016-07-18 18:05:10 -0700
committerJake Petroules <jake.petroules@qt.io>2016-07-22 22:40:12 +0000
commit0200426f9f974188e8c548bb9bf05b4825362ed8 (patch)
tree7a57b42f663a6cdb7238f4f6210ae6d7f107af5c /tests/auto/blackbox/testdata/linkerMode
parent65cb4cba999b47a643e820a102b3185f861b97c1 (diff)
Introduce cpp.linkerMode
This property allows qbs to automatically select an appropriate linker based on the objects being linked. The new behavior is to automatically use the C++ compiler driver for linking if any of the objects being linked were compiled from C++ or Objective-C++ sources, otherwise the C compiler driver if any of the objects being linked were compiled from C or Objective-C sources, otherwise the system linker. To retain the old behavior, cpp.linkerName can be set to cpp.cxxCompilerName, and cpp.linkerMode to "manual". Qbs will also avoid passing the -stdlib option or linking c++abi on Linux unless any of the objects being linked were compiled from C++ or Objective-C++ sources. As a result the default behavior for building a pure C application or pure ASM application with Qbs is to NOT link to the C++ standard library or any other supporting C++ libraries. [ChangeLog] Introduced cpp.linkerMode property to allow selection of the correct linker (C driver, C++ driver, or system linker) based on the objects being linked Change-Id: Ic16e31a3072c9e296c348783a21717902c15bff6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/auto/blackbox/testdata/linkerMode')
-rw-r--r--tests/auto/blackbox/testdata/linkerMode/main.c8
-rw-r--r--tests/auto/blackbox/testdata/linkerMode/main.cpp8
-rw-r--r--tests/auto/blackbox/testdata/linkerMode/main.m7
-rw-r--r--tests/auto/blackbox/testdata/linkerMode/main.mm10
-rw-r--r--tests/auto/blackbox/testdata/linkerMode/main.s3
-rw-r--r--tests/auto/blackbox/testdata/linkerMode/project.qbs83
-rw-r--r--tests/auto/blackbox/testdata/linkerMode/staticlib.cpp9
-rw-r--r--tests/auto/blackbox/testdata/linkerMode/staticmain.c6
8 files changed, 134 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/linkerMode/main.c b/tests/auto/blackbox/testdata/linkerMode/main.c
new file mode 100644
index 000000000..cfc7d07f0
--- /dev/null
+++ b/tests/auto/blackbox/testdata/linkerMode/main.c
@@ -0,0 +1,8 @@
+#include <stdlib.h>
+
+int main()
+{
+ void *memory = malloc(8);
+ free(memory);
+ return 0;
+}
diff --git a/tests/auto/blackbox/testdata/linkerMode/main.cpp b/tests/auto/blackbox/testdata/linkerMode/main.cpp
new file mode 100644
index 000000000..2f360bde4
--- /dev/null
+++ b/tests/auto/blackbox/testdata/linkerMode/main.cpp
@@ -0,0 +1,8 @@
+#include <string>
+
+int main()
+{
+ std::string s = "Hello World";
+ (void)s;
+ return 0;
+}
diff --git a/tests/auto/blackbox/testdata/linkerMode/main.m b/tests/auto/blackbox/testdata/linkerMode/main.m
new file mode 100644
index 000000000..8db28e5be
--- /dev/null
+++ b/tests/auto/blackbox/testdata/linkerMode/main.m
@@ -0,0 +1,7 @@
+#include <objc/objc.h>
+
+int main()
+{
+ sel_registerName("qbs");
+ return 0;
+}
diff --git a/tests/auto/blackbox/testdata/linkerMode/main.mm b/tests/auto/blackbox/testdata/linkerMode/main.mm
new file mode 100644
index 000000000..65ef04091
--- /dev/null
+++ b/tests/auto/blackbox/testdata/linkerMode/main.mm
@@ -0,0 +1,10 @@
+#include <string>
+#include <objc/objc.h>
+
+int main()
+{
+ std::string s = "Hello World";
+ (void)s;
+ sel_registerName("qbs");
+ return 0;
+}
diff --git a/tests/auto/blackbox/testdata/linkerMode/main.s b/tests/auto/blackbox/testdata/linkerMode/main.s
new file mode 100644
index 000000000..578cc628a
--- /dev/null
+++ b/tests/auto/blackbox/testdata/linkerMode/main.s
@@ -0,0 +1,3 @@
+.global _start
+
+_start:
diff --git a/tests/auto/blackbox/testdata/linkerMode/project.qbs b/tests/auto/blackbox/testdata/linkerMode/project.qbs
new file mode 100644
index 000000000..f1cfcb52c
--- /dev/null
+++ b/tests/auto/blackbox/testdata/linkerMode/project.qbs
@@ -0,0 +1,83 @@
+import qbs
+
+Project {
+ CppApplication {
+ consoleApplication: true
+ name: "LinkedProduct-Assembly"
+ files: ["main.s"]
+
+ cpp.entryPoint: "_start"
+ cpp.dynamicLibraries: qbs.targetOS.contains("darwin") ? ["System"] : ["c"]
+
+ Group {
+ fileTagsFilter: product.type
+ qbs.install: true
+ }
+ }
+
+ CppApplication {
+ consoleApplication: true
+ name: "LinkedProduct-C"
+ files: ["main.c"]
+
+ Group {
+ fileTagsFilter: product.type
+ qbs.install: true
+ }
+ }
+
+ CppApplication {
+ condition: qbs.targetOS.contains("darwin")
+
+ consoleApplication: true
+ name: "LinkedProduct-Objective-C"
+ files: ["main.m"]
+
+ cpp.dynamicLibraries: ["ObjC"]
+
+ Group {
+ fileTagsFilter: product.type
+ qbs.install: true
+ }
+ }
+
+ CppApplication {
+ consoleApplication: true
+ name: "LinkedProduct-C++"
+ files: ["main.cpp"]
+
+ Group {
+ fileTagsFilter: product.type
+ qbs.install: true
+ }
+ }
+
+ CppApplication {
+ condition: qbs.targetOS.contains("darwin")
+
+ consoleApplication: true
+ name: "LinkedProduct-Objective-C++"
+ files: ["main.mm"]
+
+ cpp.dynamicLibraries: ["ObjC"]
+
+ Group {
+ fileTagsFilter: product.type
+ qbs.install: true
+ }
+ }
+
+ CppApplication {
+ Depends { name: "LinkedProduct-C++StaticLibrary" }
+
+ name: "LinkedProduct-BlankApp"
+ files: ["staticmain.c"]
+ }
+
+ StaticLibrary {
+ Depends { name: "cpp" }
+
+ name: "LinkedProduct-C++StaticLibrary"
+ files: ["staticlib.cpp"]
+ }
+}
diff --git a/tests/auto/blackbox/testdata/linkerMode/staticlib.cpp b/tests/auto/blackbox/testdata/linkerMode/staticlib.cpp
new file mode 100644
index 000000000..663658d88
--- /dev/null
+++ b/tests/auto/blackbox/testdata/linkerMode/staticlib.cpp
@@ -0,0 +1,9 @@
+#include <iostream>
+
+extern "C" int cpp();
+
+int cpp()
+{
+ std::cout << "Hello world" << std::endl;
+ return 0;
+}
diff --git a/tests/auto/blackbox/testdata/linkerMode/staticmain.c b/tests/auto/blackbox/testdata/linkerMode/staticmain.c
new file mode 100644
index 000000000..763f9e388
--- /dev/null
+++ b/tests/auto/blackbox/testdata/linkerMode/staticmain.c
@@ -0,0 +1,6 @@
+extern int cpp();
+
+int main()
+{
+ return cpp();
+}