Binary Distribution: Relocate RPATH on Cray (#18110)
* make_package_relative: relocate rpaths on cray * relocate_package: relocate rpaths on cray * platforms: add `binary_formats` property We need to know which binary formats are supported on a platform so we know which types of relocations to try. This adds a list of binary formats to the platform and removes a bunch of special cases from `binary_distribution.py`. Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
This commit is contained in:
parent
525a9f02ca
commit
1b965ac507
4 changed files with 27 additions and 19 deletions
|
@ -234,6 +234,10 @@ class Platform(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
priority = None # Subclass sets number. Controls detection order
|
priority = None # Subclass sets number. Controls detection order
|
||||||
|
|
||||||
|
#: binary formats used on this platform; used by relocation logic
|
||||||
|
binary_formats = ['elf']
|
||||||
|
|
||||||
front_end = None
|
front_end = None
|
||||||
back_end = None
|
back_end = None
|
||||||
default = None # The default back end target. On cray ivybridge
|
default = None # The default back end target. On cray ivybridge
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
import tempfile
|
import tempfile
|
||||||
import hashlib
|
import hashlib
|
||||||
import glob
|
import glob
|
||||||
import platform
|
|
||||||
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
import ruamel.yaml as yaml
|
import ruamel.yaml as yaml
|
||||||
|
@ -520,16 +519,16 @@ def make_package_relative(workdir, spec, allow_root):
|
||||||
for filename in buildinfo['relocate_binaries']:
|
for filename in buildinfo['relocate_binaries']:
|
||||||
orig_path_names.append(os.path.join(prefix, filename))
|
orig_path_names.append(os.path.join(prefix, filename))
|
||||||
cur_path_names.append(os.path.join(workdir, filename))
|
cur_path_names.append(os.path.join(workdir, filename))
|
||||||
if (spec.architecture.platform == 'darwin' or
|
|
||||||
spec.architecture.platform == 'test' and
|
platform = spack.architecture.get_platform(spec.platform)
|
||||||
platform.system().lower() == 'darwin'):
|
if 'macho' in platform.binary_formats:
|
||||||
relocate.make_macho_binaries_relative(cur_path_names, orig_path_names,
|
relocate.make_macho_binaries_relative(
|
||||||
old_layout_root)
|
cur_path_names, orig_path_names, old_layout_root)
|
||||||
if (spec.architecture.platform == 'linux' or
|
|
||||||
spec.architecture.platform == 'test' and
|
if 'elf' in platform.binary_formats:
|
||||||
platform.system().lower() == 'linux'):
|
relocate.make_elf_binaries_relative(
|
||||||
relocate.make_elf_binaries_relative(cur_path_names, orig_path_names,
|
cur_path_names, orig_path_names, old_layout_root)
|
||||||
old_layout_root)
|
|
||||||
relocate.raise_if_not_relocatable(cur_path_names, allow_root)
|
relocate.raise_if_not_relocatable(cur_path_names, allow_root)
|
||||||
orig_path_names = list()
|
orig_path_names = list()
|
||||||
cur_path_names = list()
|
cur_path_names = list()
|
||||||
|
@ -609,18 +608,16 @@ def is_backup_file(file):
|
||||||
]
|
]
|
||||||
# If the buildcache was not created with relativized rpaths
|
# If the buildcache was not created with relativized rpaths
|
||||||
# do the relocation of path in binaries
|
# do the relocation of path in binaries
|
||||||
if (spec.architecture.platform == 'darwin' or
|
platform = spack.architecture.get_platform(spec.platform)
|
||||||
spec.architecture.platform == 'test' and
|
if 'macho' in platform.binary_formats:
|
||||||
platform.system().lower() == 'darwin'):
|
|
||||||
relocate.relocate_macho_binaries(files_to_relocate,
|
relocate.relocate_macho_binaries(files_to_relocate,
|
||||||
old_layout_root,
|
old_layout_root,
|
||||||
new_layout_root,
|
new_layout_root,
|
||||||
prefix_to_prefix, rel,
|
prefix_to_prefix, rel,
|
||||||
old_prefix,
|
old_prefix,
|
||||||
new_prefix)
|
new_prefix)
|
||||||
if (spec.architecture.platform == 'linux' or
|
|
||||||
spec.architecture.platform == 'test' and
|
if 'elf' in platform.binary_formats:
|
||||||
platform.system().lower() == 'linux'):
|
|
||||||
relocate.relocate_elf_binaries(files_to_relocate,
|
relocate.relocate_elf_binaries(files_to_relocate,
|
||||||
old_layout_root,
|
old_layout_root,
|
||||||
new_layout_root,
|
new_layout_root,
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
class Darwin(Platform):
|
class Darwin(Platform):
|
||||||
priority = 89
|
priority = 89
|
||||||
|
|
||||||
|
binary_formats = ['macho']
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Darwin, self).__init__('darwin')
|
super(Darwin, self).__init__('darwin')
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,17 @@
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
|
||||||
|
import platform
|
||||||
from spack.architecture import Platform, Target
|
from spack.architecture import Platform, Target
|
||||||
from spack.architecture import OperatingSystem
|
from spack.architecture import OperatingSystem
|
||||||
|
|
||||||
|
|
||||||
class Test(Platform):
|
class Test(Platform):
|
||||||
priority = 1000000
|
priority = 1000000
|
||||||
|
|
||||||
|
if platform.system().lower() == 'darwin':
|
||||||
|
binary_formats = ['macho']
|
||||||
|
|
||||||
front_end = 'x86'
|
front_end = 'x86'
|
||||||
back_end = 'x86_64'
|
back_end = 'x86_64'
|
||||||
default = 'x86_64'
|
default = 'x86_64'
|
||||||
|
|
Loading…
Reference in a new issue