Skip to content

Commit

Permalink
binary_distribution: stop relocating tarballs with relative rpaths (s…
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie authored Jan 10, 2025
1 parent c1d385a commit 93cd216
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 550 deletions.
43 changes: 11 additions & 32 deletions lib/spack/spack/binary_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,12 @@ def relocate_package(spec):
old_spack_prefix = str(buildinfo.get("spackprefix"))
old_rel_prefix = buildinfo.get("relative_prefix")
old_prefix = os.path.join(old_layout_root, old_rel_prefix)
rel = buildinfo.get("relative_rpaths", False)

# Warn about old style tarballs created with the now removed --rel flag.
if buildinfo.get("relative_rpaths", False):
tty.warn(
f"Tarball for {spec} uses relative rpaths, " "which can cause library loading issues."
)

# In the past prefix_to_hash was the default and externals were not dropped, so prefixes
# were not unique.
Expand Down Expand Up @@ -2267,19 +2272,11 @@ def relocate_package(spec):

tty.debug("Relocating package from", "%s to %s." % (old_layout_root, new_layout_root))

# Old archives maybe have hardlinks repeated.
# Old archives may have hardlinks repeated.
dedupe_hardlinks_if_necessary(workdir, buildinfo)

def is_backup_file(file):
return file.endswith("~")

# Text files containing the prefix text
text_names = list()
for filename in buildinfo["relocate_textfiles"]:
text_name = os.path.join(workdir, filename)
# Don't add backup files generated by filter_file during install step.
if not is_backup_file(text_name):
text_names.append(text_name)
text_names = [os.path.join(workdir, f) for f in buildinfo["relocate_textfiles"]]

# If we are not installing back to the same install tree do the relocation
if old_prefix != new_prefix:
Expand All @@ -2290,29 +2287,11 @@ def is_backup_file(file):
# do the relocation of path in binaries
platform = spack.platforms.by_name(spec.platform)
if "macho" in platform.binary_formats:
relocate.relocate_macho_binaries(
files_to_relocate,
old_layout_root,
new_layout_root,
prefix_to_prefix_bin,
rel,
old_prefix,
new_prefix,
)
elif "elf" in platform.binary_formats and not rel:
relocate.relocate_macho_binaries(files_to_relocate, prefix_to_prefix_bin)
elif "elf" in platform.binary_formats:
# The new ELF dynamic section relocation logic only handles absolute to
# absolute relocation.
relocate.new_relocate_elf_binaries(files_to_relocate, prefix_to_prefix_bin)
elif "elf" in platform.binary_formats and rel:
relocate.relocate_elf_binaries(
files_to_relocate,
old_layout_root,
new_layout_root,
prefix_to_prefix_bin,
rel,
old_prefix,
new_prefix,
)
relocate.relocate_elf_binaries(files_to_relocate, prefix_to_prefix_bin)

# Relocate links to the new install prefix
links = [os.path.join(workdir, f) for f in buildinfo.get("relocate_links", [])]
Expand Down
Loading

0 comments on commit 93cd216

Please sign in to comment.