diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py index 975cb9e56ded08b8ad95c5b63c7a0992b3b6c50f..e4a20759cfacc3822b4b10f54a8ab65bb53fe127 100644 --- a/lib/spack/spack/architecture.py +++ b/lib/spack/spack/architecture.py @@ -233,10 +233,14 @@ class Platform(object): Will return a instance of it once it is returned. """ - 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 back_end = None - default = None # The default back end target. On cray ivybridge + default = None # The default back end target. On cray ivybridge front_os = None back_os = None diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py index 220686f831563d03f9f6f42524bf6b2ecfb722e9..590f6e67109e98522ab9e88b9b6e5ca2ca6ba4b0 100644 --- a/lib/spack/spack/binary_distribution.py +++ b/lib/spack/spack/binary_distribution.py @@ -11,7 +11,6 @@ import tempfile import hashlib import glob -import platform from contextlib import closing import ruamel.yaml as yaml @@ -520,16 +519,16 @@ def make_package_relative(workdir, spec, allow_root): for filename in buildinfo['relocate_binaries']: orig_path_names.append(os.path.join(prefix, filename)) cur_path_names.append(os.path.join(workdir, filename)) - if (spec.architecture.platform == 'darwin' or - spec.architecture.platform == 'test' and - platform.system().lower() == 'darwin'): - relocate.make_macho_binaries_relative(cur_path_names, orig_path_names, - old_layout_root) - if (spec.architecture.platform == 'linux' or - spec.architecture.platform == 'test' and - platform.system().lower() == 'linux'): - relocate.make_elf_binaries_relative(cur_path_names, orig_path_names, - old_layout_root) + + platform = spack.architecture.get_platform(spec.platform) + if 'macho' in platform.binary_formats: + relocate.make_macho_binaries_relative( + cur_path_names, orig_path_names, old_layout_root) + + if 'elf' in platform.binary_formats: + relocate.make_elf_binaries_relative( + cur_path_names, orig_path_names, old_layout_root) + relocate.raise_if_not_relocatable(cur_path_names, allow_root) orig_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 # do the relocation of path in binaries - if (spec.architecture.platform == 'darwin' or - spec.architecture.platform == 'test' and - platform.system().lower() == 'darwin'): + platform = spack.architecture.get_platform(spec.platform) + if 'macho' in platform.binary_formats: relocate.relocate_macho_binaries(files_to_relocate, old_layout_root, new_layout_root, prefix_to_prefix, rel, old_prefix, new_prefix) - if (spec.architecture.platform == 'linux' or - spec.architecture.platform == 'test' and - platform.system().lower() == 'linux'): + + if 'elf' in platform.binary_formats: relocate.relocate_elf_binaries(files_to_relocate, old_layout_root, new_layout_root, diff --git a/lib/spack/spack/platforms/darwin.py b/lib/spack/spack/platforms/darwin.py index 9a3fffd8813038b7e22dd525e379203907841f7a..99a28cec9fd1100cb3008000452761c802ea8618 100644 --- a/lib/spack/spack/platforms/darwin.py +++ b/lib/spack/spack/platforms/darwin.py @@ -12,6 +12,8 @@ class Darwin(Platform): priority = 89 + binary_formats = ['macho'] + def __init__(self): super(Darwin, self).__init__('darwin') diff --git a/lib/spack/spack/platforms/test.py b/lib/spack/spack/platforms/test.py index 9be160731e0d3ac5befe76ef961b7c3eefad8919..3480275328c79450d50e937605c6d3ebaba91f68 100644 --- a/lib/spack/spack/platforms/test.py +++ b/lib/spack/spack/platforms/test.py @@ -3,12 +3,17 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import platform from spack.architecture import Platform, Target from spack.architecture import OperatingSystem class Test(Platform): priority = 1000000 + + if platform.system().lower() == 'darwin': + binary_formats = ['macho'] + front_end = 'x86' back_end = 'x86_64' default = 'x86_64'