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
pull/8973/merge
Nirbheek Chauhan 3 years ago committed by Nirbheek Chauhan
parent 06b1132f82
commit 351aee8ace
  1. 8
      mesonbuild/backend/backends.py
  2. 4
      mesonbuild/mesonlib/universal.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))

@ -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

Loading…
Cancel
Save