summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2022-09-02 12:48:46 +0200
committerGitHub <noreply@github.com>2022-09-02 12:48:46 +0200
commit80389911cce2daae5b0e4df069a3be9575954dc3 (patch)
treea305ed9af20c27372018484b9d377bf15fe27064 /lib
parenta2e829c7b99450240e7e37b163b811c97e970fe0 (diff)
downloadspack-80389911cce2daae5b0e4df069a3be9575954dc3.tar.gz
spack-80389911cce2daae5b0e4df069a3be9575954dc3.tar.bz2
spack-80389911cce2daae5b0e4df069a3be9575954dc3.tar.xz
spack-80389911cce2daae5b0e4df069a3be9575954dc3.zip
Update bootstrap buildcache to v0.3 (#32262)
This release allow to bootstrap patchelf from binaries.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/bootstrap.py51
-rw-r--r--lib/spack/spack/relocate.py8
2 files changed, 44 insertions, 15 deletions
diff --git a/lib/spack/spack/bootstrap.py b/lib/spack/spack/bootstrap.py
index 4acb8aa6f8..6951ad4946 100644
--- a/lib/spack/spack/bootstrap.py
+++ b/lib/spack/spack/bootstrap.py
@@ -15,6 +15,7 @@ import platform
import re
import sys
import sysconfig
+import uuid
import six
@@ -40,6 +41,7 @@ import spack.util.executable
import spack.util.path
import spack.util.spack_yaml
import spack.util.url
+import spack.version
#: Name of the file containing metadata about the bootstrapping source
METADATA_YAML_FILENAME = "metadata.yaml"
@@ -260,12 +262,11 @@ class _BootstrapperBase(object):
class _BuildcacheBootstrapper(_BootstrapperBase):
"""Install the software needed during bootstrapping from a buildcache."""
- config_scope_name = "bootstrap_buildcache"
-
def __init__(self, conf):
super(_BuildcacheBootstrapper, self).__init__(conf)
self.metadata_dir = spack.util.path.canonicalize_path(conf["metadata"])
self.last_search = None
+ self.config_scope_name = "bootstrap_buildcache-{}".format(uuid.uuid4())
@staticmethod
def _spec_and_platform(abstract_spec_str):
@@ -378,13 +379,12 @@ class _BuildcacheBootstrapper(_BootstrapperBase):
class _SourceBootstrapper(_BootstrapperBase):
"""Install the software needed during bootstrapping from sources."""
- config_scope_name = "bootstrap_source"
-
def __init__(self, conf):
super(_SourceBootstrapper, self).__init__(conf)
self.metadata_dir = spack.util.path.canonicalize_path(conf["metadata"])
self.conf = conf
self.last_search = None
+ self.config_scope_name = "bootstrap_source-{}".format(uuid.uuid4())
def try_import(self, module, abstract_spec_str):
info = {}
@@ -788,17 +788,46 @@ def ensure_gpg_in_path_or_raise():
def patchelf_root_spec():
"""Return the root spec used to bootstrap patchelf"""
- # TODO: patchelf is restricted to v0.13 since earlier versions have
- # TODO: bugs that we don't to deal with, while v0.14 requires a C++17
- # TODO: which may not be available on all platforms.
- return _root_spec("patchelf@0.13.1:0.13.99")
+ # 0.13.1 is the last version not to require C++17.
+ return _root_spec("patchelf@0.13.1:")
+
+
+def verify_patchelf(patchelf):
+ """Older patchelf versions can produce broken binaries, so we
+ verify the version here.
+
+ Arguments:
+
+ patchelf (spack.util.executable.Executable): patchelf executable
+ """
+ out = patchelf("--version", output=str, error=os.devnull, fail_on_error=False).strip()
+ if patchelf.returncode != 0:
+ return False
+ parts = out.split(" ")
+ if len(parts) < 2:
+ return False
+ try:
+ version = spack.version.Version(parts[1])
+ except ValueError:
+ return False
+ return version >= spack.version.Version("0.13.1")
def ensure_patchelf_in_path_or_raise():
"""Ensure patchelf is in the PATH or raise."""
- return ensure_executables_in_path_or_raise(
- executables=["patchelf"], abstract_spec=patchelf_root_spec()
- )
+ # The old concretizer is not smart and we're doing its job: if the latest patchelf
+ # does not concretize because the compiler doesn't support C++17, we try to
+ # concretize again with an upperbound @:13.
+ try:
+ return ensure_executables_in_path_or_raise(
+ executables=["patchelf"], abstract_spec=patchelf_root_spec(), cmd_check=verify_patchelf
+ )
+ except RuntimeError:
+ return ensure_executables_in_path_or_raise(
+ executables=["patchelf"],
+ abstract_spec=_root_spec("patchelf@0.13.1:0.13"),
+ cmd_check=verify_patchelf,
+ )
###
diff --git a/lib/spack/spack/relocate.py b/lib/spack/spack/relocate.py
index e2d362fe05..8212093a12 100644
--- a/lib/spack/spack/relocate.py
+++ b/lib/spack/spack/relocate.py
@@ -13,6 +13,7 @@ import macholib.MachO
import llnl.util.lang
import llnl.util.tty as tty
+from llnl.util.lang import memoized
from llnl.util.symlink import symlink
import spack.bootstrap
@@ -76,15 +77,14 @@ class BinaryTextReplaceError(spack.error.SpackError):
super(BinaryTextReplaceError, self).__init__(msg, err_msg)
+@memoized
def _patchelf():
"""Return the full path to the patchelf binary, if available, else None."""
if is_macos:
return None
- patchelf = executable.which("patchelf")
- if patchelf is None:
- with spack.bootstrap.ensure_bootstrap_configuration():
- patchelf = spack.bootstrap.ensure_patchelf_in_path_or_raise()
+ with spack.bootstrap.ensure_bootstrap_configuration():
+ patchelf = spack.bootstrap.ensure_patchelf_in_path_or_raise()
return patchelf.path