aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/build.py27
-rw-r--r--test cases/unit/69 static link/lib/func7.c4
-rw-r--r--test cases/unit/69 static link/lib/func8.c6
-rw-r--r--test cases/unit/69 static link/lib/func9.c6
-rw-r--r--test cases/unit/69 static link/lib/meson.build15
-rw-r--r--test cases/unit/69 static link/meson.build9
-rw-r--r--test cases/unit/69 static link/test4.c6
7 files changed, 56 insertions, 17 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index bb5d9db..49c1808 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -974,20 +974,17 @@ This will become a hard error in a future Meson release.''')
transitive_deps = []
if exclude is None:
exclude = []
- if not for_pkgconfig:
- link_targets = itertools.chain(self.link_targets, self.link_whole_targets)
- else:
- # We don't want the 'internal' libraries when generating the
- # `Libs:` and `Libs.private:` lists in pkg-config files.
- link_targets = self.link_targets
- for t in link_targets:
+ for t in itertools.chain(self.link_targets, self.link_whole_targets):
if t in transitive_deps or t in exclude:
continue
- if for_pkgconfig and t.is_internal():
- # Skip uninstalled static libraries, they have been promoted to
- # link_whole into the static library.
- continue
- transitive_deps.append(t)
+ # When generating `Libs:` and `Libs.private:` lists in pkg-config
+ # files we don't want to include static libraries that we link_whole
+ # or are uninstalled (they're implicitly promoted to link_whole).
+ # But we still need to include their transitive dependencies,
+ # a static library we link_whole would itself link to a shared
+ # library or an installed static library.
+ if not for_pkgconfig or (not t.is_internal() and t not in self.link_whole_targets):
+ transitive_deps.append(t)
if isinstance(t, StaticLibrary):
transitive_deps += t.get_dependencies(transitive_deps + exclude, for_pkgconfig)
return transitive_deps
@@ -1114,11 +1111,7 @@ You probably should put it in link_with instead.''')
# When we're a static library and we link_whole: to another static
# library, we need to add that target's objects to ourselves.
self.objects.append(t.extract_all_objects())
- # Add internal and external deps
- self.external_deps += t.external_deps
- self.link_targets += t.link_targets
- else:
- self.link_whole_targets.append(t)
+ self.link_whole_targets.append(t)
def add_pch(self, language, pchlist):
if not pchlist:
diff --git a/test cases/unit/69 static link/lib/func7.c b/test cases/unit/69 static link/lib/func7.c
new file mode 100644
index 0000000..8c1a536
--- /dev/null
+++ b/test cases/unit/69 static link/lib/func7.c
@@ -0,0 +1,4 @@
+int func7()
+{
+ return 1;
+}
diff --git a/test cases/unit/69 static link/lib/func8.c b/test cases/unit/69 static link/lib/func8.c
new file mode 100644
index 0000000..b7b6cd5
--- /dev/null
+++ b/test cases/unit/69 static link/lib/func8.c
@@ -0,0 +1,6 @@
+int func7();
+
+int func8()
+{
+ return func7() + 1;
+}
diff --git a/test cases/unit/69 static link/lib/func9.c b/test cases/unit/69 static link/lib/func9.c
new file mode 100644
index 0000000..852252d
--- /dev/null
+++ b/test cases/unit/69 static link/lib/func9.c
@@ -0,0 +1,6 @@
+int func8();
+
+int func9()
+{
+ return func8() + 1;
+}
diff --git a/test cases/unit/69 static link/lib/meson.build b/test cases/unit/69 static link/lib/meson.build
index 9bd3d19..309543c 100644
--- a/test cases/unit/69 static link/lib/meson.build
+++ b/test cases/unit/69 static link/lib/meson.build
@@ -26,3 +26,18 @@ libfunc6 = both_libraries('func6', 'func6.c',
link_with : libfunc5,
install : true)
pkg.generate(libfunc6)
+
+# libfunc9 should contain both func8() and func9() but not func7() because that
+# one gets installed. Also test that link_with and link_whole works the same way
+# because libfunc8 is uninstalled.
+libfunc7 = static_library('func7', 'func7.c',
+ install : true)
+libfunc8 = static_library('func8', 'func8.c',
+ link_with : libfunc7,
+ install : false)
+libfunc9_linkwith = static_library('func9_linkwith', 'func9.c',
+ link_with : libfunc8,
+ install : true)
+libfunc9_linkwhole = static_library('func9_linkwhole', 'func9.c',
+ link_whole : libfunc8,
+ install : true)
diff --git a/test cases/unit/69 static link/meson.build b/test cases/unit/69 static link/meson.build
index 307139a..8ebcf5e 100644
--- a/test cases/unit/69 static link/meson.build
+++ b/test cases/unit/69 static link/meson.build
@@ -17,3 +17,12 @@ test('test3-static', executable('test3-static', 'test3.c',
func6_shared_dep = dependency('func6', static : false)
test('test3-shared', executable('test3-shared', 'test3.c',
dependencies : func6_shared_dep))
+
+# Verify that installed libfunc9.a contains func8() and func8() but not func7()
+func7_dep = cc.find_library('func7')
+func9_linkwhole_dep = cc.find_library('func9_linkwhole')
+test('test4-linkwhole', executable('test4-linkwhole', 'test4.c',
+ dependencies : [func7_dep, func9_linkwhole_dep]))
+func9_linkwith_dep = cc.find_library('func9_linkwith')
+test('test4-linkwith', executable('test4-linkwith', 'test4.c',
+ dependencies : [func7_dep, func9_linkwith_dep]))
diff --git a/test cases/unit/69 static link/test4.c b/test cases/unit/69 static link/test4.c
new file mode 100644
index 0000000..7c281e0
--- /dev/null
+++ b/test cases/unit/69 static link/test4.c
@@ -0,0 +1,6 @@
+int func9();
+
+int main(int argc, char *argv[])
+{
+ return func9() == 3 ? 0 : 1;
+}