Binary caching: avoid duplicate RPATHs, unnecessary updates (#19061)

* Remove duplication of reconstructed RPATHs caused by multiple
  identical entries in prefixes dictionary
* Don't rewrite RPATHs if relative RPATHs are unchanged because the
  directory layout is unchanged
This commit is contained in:
Patrick Gartung 2020-10-01 15:21:02 -05:00 committed by GitHub
parent 6aa9866b79
commit a2795519df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -615,12 +615,13 @@ def _transform_rpaths(orig_rpaths, orig_root, new_prefixes):
# Otherwise inspect the mapping and transform + append any prefix
# that starts with a registered key
# avoiding duplicates
for old_prefix, new_prefix in new_prefixes.items():
if orig_rpath.startswith(old_prefix):
new_rpaths.append(
re.sub(re.escape(old_prefix), new_prefix, orig_rpath)
)
new_rpath = re.sub(re.escape(old_prefix), new_prefix,
orig_rpath)
if new_rpath not in new_rpaths:
new_rpaths.append(new_rpath)
return new_rpaths
@ -668,6 +669,8 @@ def relocate_elf_binaries(binaries, orig_root, new_root,
new_rpaths = _make_relative(
new_binary, new_root, new_norm_rpaths
)
# check to see if relative rpaths are changed before rewriting
if sorted(new_rpaths) != sorted(orig_rpaths):
_set_elf_rpaths(new_binary, new_rpaths)
else:
new_rpaths = _transform_rpaths(