Skip to content

Commit

Permalink
Don't wipe out RPATHs specified by dependencies
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nirbheek committed Dec 22, 2021
1 parent 06b1132 commit 351aee8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mesonbuild/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,6 @@ def _libdir_is_system(libdir: str, compilers: T.Mapping[str, 'Compiler'], env: '
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:
Expand All @@ -719,6 +718,11 @@ def get_external_rpath_dirs(self, target: build.BuildTarget) -> T.Set[str]:
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,
Expand Down Expand Up @@ -777,6 +781,8 @@ def rpaths_for_non_system_absolute_shared_libraries(self, target: build.BuildTar
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))
Expand Down
4 changes: 4 additions & 0 deletions mesonbuild/mesonlib/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,10 @@ def update(self, iterable: T.Iterable[_T]) -> None:
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
Expand Down

0 comments on commit 351aee8

Please sign in to comment.