summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2019-09-27 14:33:35 -0400
committerXavier Claessens <xclaesse@gmail.com>2019-10-01 13:06:45 -0400
commita3153747b97512b57309e493b8b6545994d0a106 (patch)
tree86f6e696c2471d3c01c018b2f5e8b3c55ee19476
parent19fc692b2554a03c0452001ca17d635f2445fafa (diff)
downloadmeson-a3153747b97512b57309e493b8b6545994d0a106.tar.gz
Do not promote to link_whole when an internal library links to another
-rw-r--r--mesonbuild/build.py2
-rw-r--r--test cases/unit/69 static link/lib/func10.c4
-rw-r--r--test cases/unit/69 static link/lib/func11.c6
-rw-r--r--test cases/unit/69 static link/lib/func12.c7
-rw-r--r--test cases/unit/69 static link/lib/meson.build15
5 files changed, 33 insertions, 1 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 49c18080c..96bacaa58 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1068,7 +1068,7 @@ You probably should put it in link_with instead.''')
def link(self, target):
for t in listify(target, unholder=True):
- if isinstance(self, StaticLibrary) and t.is_internal():
+ if isinstance(self, StaticLibrary) and self.need_install and t.is_internal():
# When we're a static library and we link_with to an
# internal/convenience library, promote to link_whole.
return self.link_whole(t)
diff --git a/test cases/unit/69 static link/lib/func10.c b/test cases/unit/69 static link/lib/func10.c
new file mode 100644
index 000000000..75a911fb7
--- /dev/null
+++ b/test cases/unit/69 static link/lib/func10.c
@@ -0,0 +1,4 @@
+int func10()
+{
+ return 1;
+}
diff --git a/test cases/unit/69 static link/lib/func11.c b/test cases/unit/69 static link/lib/func11.c
new file mode 100644
index 000000000..1d5119b47
--- /dev/null
+++ b/test cases/unit/69 static link/lib/func11.c
@@ -0,0 +1,6 @@
+int func10();
+
+int func11()
+{
+ return func10() + 1;
+}
diff --git a/test cases/unit/69 static link/lib/func12.c b/test cases/unit/69 static link/lib/func12.c
new file mode 100644
index 000000000..73db5c073
--- /dev/null
+++ b/test cases/unit/69 static link/lib/func12.c
@@ -0,0 +1,7 @@
+int func10();
+int func11();
+
+int func12()
+{
+ return func10() + func11();
+}
diff --git a/test cases/unit/69 static link/lib/meson.build b/test cases/unit/69 static link/lib/meson.build
index 309543cb3..85e1880f6 100644
--- a/test cases/unit/69 static link/lib/meson.build
+++ b/test cases/unit/69 static link/lib/meson.build
@@ -41,3 +41,18 @@ libfunc9_linkwith = static_library('func9_linkwith', 'func9.c',
libfunc9_linkwhole = static_library('func9_linkwhole', 'func9.c',
link_whole : libfunc8,
install : true)
+
+# Pattern found in mesa:
+# - libfunc11 uses func10()
+# - libfunc12 uses both func10() and func11()
+# When a shared library link_whole on libfunc12, we ensure we don't include
+# func10.c.o twice which would fail to link.
+libfunc10 = static_library('func10', 'func10.c',
+ install : false)
+libfunc11 = static_library('func11', 'func11.c',
+ link_with : libfunc10,
+ install : false)
+libfunc12 = static_library('func12', 'func12.c',
+ link_with : [libfunc10, libfunc11],
+ install : false)
+libfunc13 = shared_library('func13', link_whole : libfunc12)