summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDom Heinzeller <dom.heinzeller@icloud.com>2023-01-18 05:32:16 -0700
committerGitHub <noreply@github.com>2023-01-18 13:32:16 +0100
commit548aa21b18a1f63ba64c0b23e6fe772a36455311 (patch)
treebee060e85e984809cb56c663e2fccabf2d1a443c /lib
parentc9775df0a4b2bd8410413da0188fbd8d0bc5ce72 (diff)
downloadspack-548aa21b18a1f63ba64c0b23e6fe772a36455311.tar.gz
spack-548aa21b18a1f63ba64c0b23e6fe772a36455311.tar.bz2
spack-548aa21b18a1f63ba64c0b23e6fe772a36455311.tar.xz
spack-548aa21b18a1f63ba64c0b23e6fe772a36455311.zip
Bug fix for duplicate rpath errors on macOS when creating build caches (#34375)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/relocate.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py
index ec864c2d84..d87fbc10b2 100644
--- a/lib/spack/spack/relocate.py
+++ b/lib/spack/spack/relocate.py
@@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import collections
+import itertools
import multiprocessing.pool
import os
import re
@@ -299,17 +300,24 @@ def modify_macho_object(cur_path, rpaths, deps, idpath, paths_to_paths):
if idpath:
new_idpath = paths_to_paths.get(idpath, None)
if new_idpath and not idpath == new_idpath:
- args += ["-id", new_idpath]
+ args += [("-id", new_idpath)]
+
for dep in deps:
new_dep = paths_to_paths.get(dep)
if new_dep and dep != new_dep:
- args += ["-change", dep, new_dep]
+ args += [("-change", dep, new_dep)]
+ new_rpaths = []
for orig_rpath in rpaths:
new_rpath = paths_to_paths.get(orig_rpath)
if new_rpath and not orig_rpath == new_rpath:
- args += ["-rpath", orig_rpath, new_rpath]
+ args_to_add = ("-rpath", orig_rpath, new_rpath)
+ if args_to_add not in args and new_rpath not in new_rpaths:
+ args += [args_to_add]
+ new_rpaths.append(new_rpath)
+ # Deduplicate and flatten
+ args = list(itertools.chain.from_iterable(llnl.util.lang.dedupe(args)))
if args:
args.append(str(cur_path))
install_name_tool = executable.Executable("install_name_tool")