build: fix install name when linking with static library

A static library can specify a dynamic library in `link_with`.
This commit is contained in:
Mohamed Akram authored and Paolo Bonzini committed 2026-04-25 13:07:25 +02:00
1 parent c496e7448c
commit ee89525b91
4 files changed
+23 -4

No files matched your search

-3
View File
@@ -2451,9 +2451,6 @@ class StaticLibrary(BuildTarget):
suffix = 'ma'
return (prefix, suffix)
def get_link_deps_mapping(self, prefix: str) -> T.Mapping[str, str]:
return {}
def get_default_install_dir(self) -> T.Tuple[str, str]:
return self.environment.get_static_lib_dir(), '{libdir_static}'
@@ -0,0 +1,5 @@
#include "foo/foo.h"
int main() {
foo();
}
@@ -5,4 +5,13 @@ subdir('foo')
bar = library('bar', 'bar.c',
link_with: foo,
install: true,
)
)
bar_internal = static_library('bar-internal', 'bar.c',
link_with: foo,
)
main = executable('main', 'main.c',
link_with: bar_internal,
install: true,
)
+8
View File
@@ -108,6 +108,12 @@ class DarwinTests(BasePlatformTests):
rpaths = pattern.findall(out)
return rpaths
def _get_darwin_rpath_libraries(self, fname: str) -> T.List[str]:
out = subprocess.check_output(['otool', '-L', fname], universal_newlines=True)
pattern = re.compile(r'@rpath/\S+')
libs = pattern.findall(out)
return libs
@skipIfNoPkgconfig
def test_library_versioning(self):
'''
@@ -174,6 +180,8 @@ class DarwinTests(BasePlatformTests):
# Those RPATHs are no longer valid and should not be present after installation
rpaths = self._get_darwin_rpaths(os.path.join(self.installdir, 'usr/lib/libbar.dylib'))
self.assertListEqual(rpaths, [])
libs = self._get_darwin_rpath_libraries(os.path.join(self.installdir, 'usr/bin/main'))
self.assertListEqual(libs, [])
@skip_if_not_language('rust')
def test_rust_apple_framework_rlib(self):