diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2021-11-15 20:34:38 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2021-12-22 12:12:11 +0530 |
commit | 351aee8ace6eec6b655da321a48a120b020b54c4 (patch) | |
tree | 0e6694edd06b70756d3d225a0cdc79dd58240a82 | |
parent | 06b1132f82eaaf805021b4b088701d9754e2af38 (diff) | |
download | meson-351aee8ace6eec6b655da321a48a120b020b54c4.zip meson-351aee8ace6eec6b655da321a48a120b020b54c4.tar.gz meson-351aee8ace6eec6b655da321a48a120b020b54c4.tar.bz2 |
Don't wipe out RPATHs specified by dependencies
Since we scan all dependencies for build-only RPATHs now (which are
removed on install), we must take care not to add build-only RPATHs
pointing to directories that dependencies explicitly add -Wl,-rpath
link args for, otherwise the paths will get wiped on install.
Caught by LinuxlikeTests::test_usage_pkgconfig_prefixes
-rw-r--r-- | mesonbuild/backend/backends.py | 8 | ||||
-rw-r--r-- | mesonbuild/mesonlib/universal.py | 4 |
2 files changed, 11 insertions, 1 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 177f24a..8e62d38 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -708,7 +708,6 @@ class Backend: return False def get_external_rpath_dirs(self, target: build.BuildTarget) -> T.Set[str]: - dirs: T.Set[str] = set() args: T.List[str] = [] for lang in LANGUAGES_USING_LDFLAGS: try: @@ -719,6 +718,11 @@ class Backend: args.extend(e) except Exception: pass + return self.get_rpath_dirs_from_link_args(args) + + @staticmethod + def get_rpath_dirs_from_link_args(args: T.List[str]) -> T.Set[str]: + dirs: T.Set[str] = set() # Match rpath formats: # -Wl,-rpath= # -Wl,-rpath, @@ -777,6 +781,8 @@ class Backend: paths.add(os.path.join(self.build_to_src, rel_to_src)) else: paths.add(libdir) + # Don't remove rpaths specified by the dependency + paths.difference_update(self.get_rpath_dirs_from_link_args(dep.link_args)) for i in chain(target.link_targets, target.link_whole_targets): if isinstance(i, build.BuildTarget): paths.update(self.rpaths_for_non_system_absolute_shared_libraries(i, exclude_system)) diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py index f193889..53e9514 100644 --- a/mesonbuild/mesonlib/universal.py +++ b/mesonbuild/mesonlib/universal.py @@ -1756,6 +1756,10 @@ class OrderedSet(T.MutableSet[_T]): def difference(self, set_: T.Union[T.Set[_T], 'OrderedSet[_T]']) -> 'OrderedSet[_T]': return type(self)(e for e in self if e not in set_) + def difference_update(self, iterable: T.Iterable[_T]) -> None: + for item in iterable: + self.discard(item) + def relpath(path: str, start: str) -> str: # On Windows a relative path can't be evaluated for paths on two different # drives (i.e. c:\foo and f:\bar). The only thing left to do is to use the |