summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2019-11-13 16:03:35 -0800
committerPeter Scheibel <scheibel1@llnl.gov>2019-11-13 16:03:35 -0800
commit43b0356e14a8227f33040302cf948d3c98508d59 (patch)
treea59ec1b4059693fb27c12d347496c80ad557a405 /lib
parentdc36b4737d16ea4aa49daa14fb782b5ea85b60e3 (diff)
downloadspack-43b0356e14a8227f33040302cf948d3c98508d59.tar.gz
spack-43b0356e14a8227f33040302cf948d3c98508d59.tar.bz2
spack-43b0356e14a8227f33040302cf948d3c98508d59.tar.xz
spack-43b0356e14a8227f33040302cf948d3c98508d59.zip
Allow binary relocation of strings in relative binaries (#13725)
Binaries with relative RPATHS currently do not relocate strings hard-coded in binaries This PR extends the best-effort relocation of strings hard-coded in binaries to those whose RPATHs have been relativized.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/binary_distribution.py17
-rw-r--r--lib/spack/spack/relocate.py23
2 files changed, 25 insertions, 15 deletions
diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py
index eafa1dcdb1..564903f333 100644
--- a/lib/spack/spack/binary_distribution.py
+++ b/lib/spack/spack/binary_distribution.py
@@ -536,7 +536,22 @@ def relocate_package(workdir, spec, allow_root):
newprefix=new_prefix)
# If the binary files in the package were not edited to use
# relative RPATHs, then the RPATHs need to be relocated
- if not rel:
+ if rel:
+ if old_path != new_path:
+ files_to_relocate = list(filter(
+ lambda pathname: not relocate.file_is_relocatable(
+ pathname, paths_to_relocate=[old_path, old_prefix]),
+ map(lambda filename: os.path.join(workdir, filename),
+ buildinfo['relocate_binaries'])))
+
+ if len(old_path) < len(new_path) and files_to_relocate:
+ tty.debug('Cannot do a binary string replacement with padding '
+ 'for package because %s is longer than %s.' %
+ (new_path, old_path))
+ else:
+ for path_name in files_to_relocate:
+ relocate.replace_prefix_bin(path_name, old_path, new_path)
+ else:
path_names = set()
for filename in buildinfo['relocate_binaries']:
path_name = os.path.join(workdir, filename)
diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py
index eec2ca918f..711c7d2341 100644
--- a/lib/spack/spack/relocate.py
+++ b/lib/spack/spack/relocate.py
@@ -651,7 +651,8 @@ def is_relocatable(spec):
return True
-def file_is_relocatable(file):
+def file_is_relocatable(
+ file, paths_to_relocate=[spack.store.layout.root, spack.paths.prefix]):
"""Returns True if the file passed as argument is relocatable.
Args:
@@ -704,19 +705,13 @@ def file_is_relocatable(file):
if idpath is not None:
set_of_strings.discard(idpath)
- if any(spack.store.layout.root in x for x in set_of_strings):
- # One binary has the root folder not in the RPATH,
- # meaning that this spec is not relocatable
- msg = 'Found "{0}" in {1} strings'
- tty.debug(msg.format(spack.store.layout.root, file))
- return False
-
- if any(spack.paths.prefix in x for x in set_of_strings):
- # One binary has the root folder not in the RPATH,
- # meaning that this spec is not relocatable
- msg = 'Found "{0}" in {1} strings'
- tty.debug(msg.format(spack.paths.prefix, file))
- return False
+ for path_to_relocate in paths_to_relocate:
+ if any(path_to_relocate in x for x in set_of_strings):
+ # One binary has the root folder not in the RPATH,
+ # meaning that this spec is not relocatable
+ msg = 'Found "{0}" in {1} strings'
+ tty.debug(msg.format(path_to_relocate, file))
+ return False
return True