From a2795519df8f84526b1a1c3aef7488bb1c526446 Mon Sep 17 00:00:00 2001 From: Patrick Gartung Date: Thu, 1 Oct 2020 15:21:02 -0500 Subject: 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 --- lib/spack/spack/relocate.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py index bc475e6849..a87156902f 100644 --- a/lib/spack/spack/relocate.py +++ b/lib/spack/spack/relocate.py @@ -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,7 +669,9 @@ def relocate_elf_binaries(binaries, orig_root, new_root, new_rpaths = _make_relative( new_binary, new_root, new_norm_rpaths ) - _set_elf_rpaths(new_binary, new_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( orig_rpaths, orig_root, new_prefixes -- cgit v1.2.3-70-g09d2