summaryrefslogtreecommitdiff
path: root/test cases/unit
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2023-04-26 10:05:19 -0400
committerXavier Claessens <xavier.claessens@collabora.com>2023-05-01 12:57:45 -0400
commita78af236862008f284d84ab9327a38886e086d8c (patch)
tree5b5e4abc864df2c37976385e2c07df41f6d76611 /test cases/unit
parentf71c9aebfbceb8623756b981392b6d6d2b4e7c22 (diff)
downloadmeson-a78af236862008f284d84ab9327a38886e086d8c.tar.gz
Fix niche cases when linking static libs
Case 1: - Prog links to static lib A - A link_whole to static lib B - B link to static lib C - Prog dependencies should be A and C but not B which is already included in A. Case 2: - Same as case 1, but with A being installed. - To be useful, A must also include all objects from C that is not installed. - Prog only need to link on A.
Diffstat (limited to 'test cases/unit')
-rw-r--r--test cases/unit/113 complex link cases/main.c6
-rw-r--r--test cases/unit/113 complex link cases/meson.build40
-rw-r--r--test cases/unit/113 complex link cases/s1.c3
-rw-r--r--test cases/unit/113 complex link cases/s2.c5
-rw-r--r--test cases/unit/113 complex link cases/s3.c5
5 files changed, 59 insertions, 0 deletions
diff --git a/test cases/unit/113 complex link cases/main.c b/test cases/unit/113 complex link cases/main.c
new file mode 100644
index 000000000..739b413af
--- /dev/null
+++ b/test cases/unit/113 complex link cases/main.c
@@ -0,0 +1,6 @@
+int s3(void);
+
+int main(int argc, char *argv[])
+{
+ return s3();
+}
diff --git a/test cases/unit/113 complex link cases/meson.build b/test cases/unit/113 complex link cases/meson.build
new file mode 100644
index 000000000..d3387c2ce
--- /dev/null
+++ b/test cases/unit/113 complex link cases/meson.build
@@ -0,0 +1,40 @@
+project('complex link cases', 'c')
+
+# In all tests, e1 uses s3 which uses s2 which uses s1.
+
+# Executable links with s3 and s1 but not s2 because it is included in s3.
+s1 = static_library('t1-s1', 's1.c')
+s2 = static_library('t1-s2', 's2.c', link_with: s1)
+s3 = static_library('t1-s3', 's3.c', link_whole: s2)
+e = executable('t1-e1', 'main.c', link_with: s3)
+
+# s3 is installed but not s1 so it has to include s1 too.
+# Executable links only s3 because it contains s1 and s2.
+s1 = static_library('t2-s1', 's1.c')
+s2 = static_library('t2-s2', 's2.c', link_with: s1)
+s3 = static_library('t2-s3', 's3.c', link_whole: s2, install: true)
+e = executable('t2-e1', 'main.c', link_with: s3)
+
+# Executable needs to link with s3 only
+s1 = static_library('t3-s1', 's1.c')
+s2 = static_library('t3-s2', 's2.c', link_with: s1)
+s3 = shared_library('t3-s3', 's3.c', link_with: s2)
+e = executable('t3-e1', 'main.c', link_with: s3)
+
+# Executable needs to link with s3 and s2
+s1 = static_library('t4-s1', 's1.c')
+s2 = shared_library('t4-s2', 's2.c', link_with: s1)
+s3 = static_library('t4-s3', 's3.c', link_with: s2)
+e = executable('t4-e1', 'main.c', link_with: s3)
+
+# Executable needs to link with s3 and s1
+s1 = shared_library('t5-s1', 's1.c')
+s2 = static_library('t5-s2', 's2.c', link_with: s1)
+s3 = static_library('t5-s3', 's3.c', link_with: s2, install: true)
+e = executable('t5-e1', 'main.c', link_with: s3)
+
+# Executable needs to link with s3 and s2
+s1 = static_library('t6-s1', 's1.c')
+s2 = static_library('t6-s2', 's2.c', link_with: s1, install: true)
+s3 = static_library('t6-s3', 's3.c', link_with: s2, install: true)
+e = executable('t6-e1', 'main.c', link_with: s3)
diff --git a/test cases/unit/113 complex link cases/s1.c b/test cases/unit/113 complex link cases/s1.c
new file mode 100644
index 000000000..68bba4949
--- /dev/null
+++ b/test cases/unit/113 complex link cases/s1.c
@@ -0,0 +1,3 @@
+int s1(void) {
+ return 1;
+}
diff --git a/test cases/unit/113 complex link cases/s2.c b/test cases/unit/113 complex link cases/s2.c
new file mode 100644
index 000000000..835870c04
--- /dev/null
+++ b/test cases/unit/113 complex link cases/s2.c
@@ -0,0 +1,5 @@
+int s1(void);
+
+int s2(void) {
+ return s1() + 1;
+}
diff --git a/test cases/unit/113 complex link cases/s3.c b/test cases/unit/113 complex link cases/s3.c
new file mode 100644
index 000000000..08e062010
--- /dev/null
+++ b/test cases/unit/113 complex link cases/s3.c
@@ -0,0 +1,5 @@
+int s2(void);
+
+int s3(void) {
+ return s2() + 1;
+}