diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2019-09-18 21:23:03 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2019-10-01 13:06:45 -0400 |
commit | 484b721369957100ee6d2b76f17224a583e2bd86 (patch) | |
tree | 50e1340d6f72e584e82ce6718ff75accdc9d3ac3 | |
parent | f396c71c52a7a3589c2998fce000843fc1e73835 (diff) | |
download | meson-484b721369957100ee6d2b76f17224a583e2bd86.zip meson-484b721369957100ee6d2b76f17224a583e2bd86.tar.gz meson-484b721369957100ee6d2b76f17224a583e2bd86.tar.bz2 |
Fix link_with of a static library with an uninstalled static library
-rw-r--r-- | mesonbuild/build.py | 7 | ||||
-rw-r--r-- | test cases/unit/69 static link/lib/func3.c | 4 | ||||
-rw-r--r-- | test cases/unit/69 static link/lib/func4.c | 6 | ||||
-rw-r--r-- | test cases/unit/69 static link/lib/meson.build | 8 | ||||
-rw-r--r-- | test cases/unit/69 static link/meson.build | 4 | ||||
-rw-r--r-- | test cases/unit/69 static link/test2.c | 6 |
6 files changed, 35 insertions, 0 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 49d53c0..1530ae5 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1062,8 +1062,15 @@ You probably should put it in link_with instead.''') def get_external_deps(self): return self.external_deps + def is_internal(self): + return isinstance(self, StaticLibrary) and not self.need_install + def link(self, target): for t in listify(target, unholder=True): + if isinstance(self, StaticLibrary) 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) if not isinstance(t, (Target, CustomTargetIndex)): raise InvalidArguments('{!r} is not a target.'.format(t)) if not t.is_linkable_target(): diff --git a/test cases/unit/69 static link/lib/func3.c b/test cases/unit/69 static link/lib/func3.c new file mode 100644 index 0000000..04f9f89 --- /dev/null +++ b/test cases/unit/69 static link/lib/func3.c @@ -0,0 +1,4 @@ +int func3() +{ + return 1; +} diff --git a/test cases/unit/69 static link/lib/func4.c b/test cases/unit/69 static link/lib/func4.c new file mode 100644 index 0000000..c44c990 --- /dev/null +++ b/test cases/unit/69 static link/lib/func4.c @@ -0,0 +1,6 @@ +int func3(); + +int func4() +{ + return func3() + 1; +} diff --git a/test cases/unit/69 static link/lib/meson.build b/test cases/unit/69 static link/lib/meson.build index 0d7f108..f5cc76b 100644 --- a/test cases/unit/69 static link/lib/meson.build +++ b/test cases/unit/69 static link/lib/meson.build @@ -6,3 +6,11 @@ libfunc1 = static_library('func1', 'func1.c', libfunc2 = static_library('func2', 'func2.c', link_whole : libfunc1, install : true) + +# Same as above, but with link_with instead of link_whole, +# libfunc4 should contain both func3() and func4() symbols +libfunc3 = static_library('func3', 'func3.c', + install : false) +libfunc4 = static_library('func4', 'func4.c', + link_with : libfunc3, + install : true) diff --git a/test cases/unit/69 static link/meson.build b/test cases/unit/69 static link/meson.build index 5126df6..4d5d074 100644 --- a/test cases/unit/69 static link/meson.build +++ b/test cases/unit/69 static link/meson.build @@ -5,3 +5,7 @@ cc = meson.get_compiler('c') # Verify that installed libfunc2.a is usable func2_dep = cc.find_library('func2') test('test1', executable('test1', 'test1.c', dependencies : func2_dep)) + +# Verify that installed libfunc4.a is usable +func4_dep = cc.find_library('func4') +test('test2', executable('test2', 'test2.c', dependencies : func4_dep)) diff --git a/test cases/unit/69 static link/test2.c b/test cases/unit/69 static link/test2.c new file mode 100644 index 0000000..561422a --- /dev/null +++ b/test cases/unit/69 static link/test2.c @@ -0,0 +1,6 @@ +int func4(); + +int main(int argc, char *argv[]) +{ + return func4() == 2 ? 0 : 1; +} |