Recursively include all objects from uninstalled static libraries

pull/5985/head
Xavier Claessens 5 years ago committed by Xavier Claessens
parent a3153747b9
commit dd5a0df3ec
  1. 9
      mesonbuild/build.py
  2. 4
      test cases/unit/69 static link/lib/func14.c
  3. 6
      test cases/unit/69 static link/lib/func15.c
  4. 6
      test cases/unit/69 static link/lib/func16.c
  5. 10
      test cases/unit/69 static link/lib/meson.build
  6. 4
      test cases/unit/69 static link/meson.build
  7. 6
      test cases/unit/69 static link/test5.c

@ -1110,9 +1110,16 @@ You probably should put it in link_with instead.''')
if isinstance(self, StaticLibrary):
# 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())
self.objects += t.extract_all_objects_recurse()
self.link_whole_targets.append(t)
def extract_all_objects_recurse(self):
objs = [self.extract_all_objects()]
for t in self.link_targets:
if t.is_internal():
objs += t.extract_all_objects_recurse()
return objs
def add_pch(self, language, pchlist):
if not pchlist:
return

@ -0,0 +1,4 @@
int func14()
{
return 1;
}

@ -0,0 +1,6 @@
int func14();
int func15()
{
return func14() + 1;
}

@ -0,0 +1,6 @@
int func15();
int func16()
{
return func15() + 1;
}

@ -56,3 +56,13 @@ libfunc12 = static_library('func12', 'func12.c',
link_with : [libfunc10, libfunc11],
install : false)
libfunc13 = shared_library('func13', link_whole : libfunc12)
# libfunc16 should contain func14(), func15() and func16()
libfunc14 = static_library('func14', 'func14.c',
install : false)
libfunc15 = static_library('func15', 'func15.c',
link_with : libfunc14,
install : false)
libfunc16 = static_library('func16', 'func16.c',
link_with : libfunc15,
install : true)

@ -26,3 +26,7 @@ test('test4-linkwhole', executable('test4-linkwhole', 'test4.c',
func9_linkwith_dep = cc.find_library('func9_linkwith')
test('test4-linkwith', executable('test4-linkwith', 'test4.c',
dependencies : [func7_dep, func9_linkwith_dep]))
# Verify that installed libfunc16.a is usable
libfunc16_dep = cc.find_library('func16')
test('test5', executable('test5', 'test5.c', dependencies: libfunc16_dep))

@ -0,0 +1,6 @@
int func16();
int main(int argc, char *argv[])
{
return func16() == 3 ? 0 : 1;
}
Loading…
Cancel
Save