diff options
author | Piotr BrzeziĆski <piotr@centricular.com> | 2024-06-28 14:06:25 +0200 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2024-06-29 23:40:59 -0400 |
commit | dc1b4be6be321e39d21604ab4287c9ce972be4da (patch) | |
tree | 9a557b71af4f3acada522572b5efe8b0668629d3 /unittests | |
parent | 7b43a2e19613f3702935872b21b1020f7d8c6a9b (diff) | |
download | meson-dc1b4be6be321e39d21604ab4287c9ce972be4da.zip meson-dc1b4be6be321e39d21604ab4287c9ce972be4da.tar.gz meson-dc1b4be6be321e39d21604ab4287c9ce972be4da.tar.bz2 |
linkers: Fix AppleDynamicLinker not returning any rpaths to remove
Fixes regression from commit 78e9009ff9d36925e04f329f9082841002ddd848.
The above commit relied on rpath_dirs_to_remove being present and
correctly filled, which was never the case for the AppleDynamicLinker.
The result was that all the build-dir-only RPATHs were being carried
over to the installed files.
This commit implements returning the list of RPATHs to remove in
AppleDynamicLinker, doing pretty much the same thing as what's in the
GnuLikeDynamicLinkerMixin. Thanks to that, depfixer now correctly
removes build-time Meson-created RPATHs, as it used to before 1.4.1.
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/baseplatformtests.py | 1 | ||||
-rw-r--r-- | unittests/darwintests.py | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py index e94a2ba..6e6a01d 100644 --- a/unittests/baseplatformtests.py +++ b/unittests/baseplatformtests.py @@ -78,6 +78,7 @@ class BasePlatformTests(TestCase): self.linuxlike_test_dir = os.path.join(src_root, 'test cases/linuxlike') self.objc_test_dir = os.path.join(src_root, 'test cases/objc') self.objcpp_test_dir = os.path.join(src_root, 'test cases/objcpp') + self.darwin_test_dir = os.path.join(src_root, 'test cases/darwin') # Misc stuff self.orig_env = os.environ.copy() diff --git a/unittests/darwintests.py b/unittests/darwintests.py index 7403104..afc663a 100644 --- a/unittests/darwintests.py +++ b/unittests/darwintests.py @@ -100,6 +100,12 @@ class DarwinTests(BasePlatformTests): self.assertIsNotNone(m, msg=out) return m.groups() + def _get_darwin_rpaths(self, fname: str) -> T.List[str]: + out = subprocess.check_output(['otool', '-l', fname], universal_newlines=True) + pattern = re.compile(r'path (.*) \(offset \d+\)') + rpaths = pattern.findall(out) + return rpaths + @skipIfNoPkgconfig def test_library_versioning(self): ''' @@ -154,3 +160,15 @@ class DarwinTests(BasePlatformTests): from mesonbuild.mesonlib import darwin_get_object_archs archs = darwin_get_object_archs('/bin/cat') self.assertEqual(archs, ['x86_64', 'aarch64']) + + def test_darwin_meson_rpaths_removed_on_install(self): + testdir = os.path.join(self.darwin_test_dir, '1 rpath removal on install') + self.init(testdir) + self.build() + # Meson-created RPATHs are usually only valid in the build directory + rpaths = self._get_darwin_rpaths(os.path.join(self.builddir, 'libbar.dylib')) + self.assertListEqual(rpaths, ['@loader_path/foo']) + self.install() + # 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, []) |