diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2023-11-16 10:04:58 +0100 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2023-12-21 12:22:58 -0800 |
commit | 8371bb4e192f876978fd77ea81c728bcd3475768 (patch) | |
tree | 9fffeabd4a1af69f7f147dbe1e6532fb2d740052 /lib | |
parent | 0a5f2fc94d7093d57a5f1926f1ebbe035066ad9c (diff) | |
download | spack-8371bb4e192f876978fd77ea81c728bcd3475768.tar.gz spack-8371bb4e192f876978fd77ea81c728bcd3475768.tar.bz2 spack-8371bb4e192f876978fd77ea81c728bcd3475768.tar.xz spack-8371bb4e192f876978fd77ea81c728bcd3475768.zip |
gcc-runtime: add separate package for gcc runtime libs
The gcc-runtime package adds a separate node for gcc's dynamic runtime
libraries.
This should help with:
1. binary caches where rpaths for compiler support libs cannot be
relocated because the compiler is missing on the target system
2. creating "minimal" container images
The package is versioned like `gcc` (in principle it could be
unversioned, but Spack doesn't always guarantee not mixing compilers)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/main.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/package_base.py | 18 | ||||
-rw-r--r-- | lib/spack/spack/test/conftest.py | 5 |
3 files changed, 24 insertions, 1 deletions
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py index 56a4dc0e33..bcdc7d7599 100644 --- a/lib/spack/spack/main.py +++ b/lib/spack/spack/main.py @@ -36,6 +36,7 @@ import spack.cmd import spack.config import spack.environment as ev import spack.modules +import spack.package_base import spack.paths import spack.platforms import spack.repo @@ -607,6 +608,7 @@ def setup_main_options(args): [(key, [spack.paths.mock_packages_path])] ) spack.repo.PATH = spack.repo.create(spack.config.CONFIG) + spack.package_base.WITH_GCC_RUNTIME = False # If the user asked for it, don't check ssl certs. if args.insecure: diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py index 7d8f7104df..bf8ed56d95 100644 --- a/lib/spack/spack/package_base.py +++ b/lib/spack/spack/package_base.py @@ -53,6 +53,7 @@ import spack.url import spack.util.environment import spack.util.path import spack.util.web +from spack.directives import _depends_on from spack.filesystem_view import YamlFilesystemView from spack.install_test import ( PackageTest, @@ -76,6 +77,7 @@ FLAG_HANDLER_TYPE = Callable[[str, Iterable[str]], FLAG_HANDLER_RETURN_TYPE] """Allowed URL schemes for spack packages.""" _ALLOWED_URL_SCHEMES = ["http", "https", "ftp", "file", "git"] +WITH_GCC_RUNTIME = True #: Filename for the Spack build/install log. _spack_build_logfile = "spack-build-out.txt" @@ -371,6 +373,20 @@ def on_package_attributes(**attr_dict): return _execute_under_condition +class BinaryPackage: + """This adds a universal dependency on gcc-runtime.""" + + def maybe_depend_on_gcc_runtime(self): + # Do not depend on itself, and allow tests to disable this universal dep + if self.name == "gcc-runtime" or not WITH_GCC_RUNTIME: + return + for v in ["13", "12", "11", "10", "9", "8", "7", "6", "5", "4"]: + _depends_on(self, f"gcc-runtime@{v}:", type="link", when=f"%gcc@{v} platform=linux") + _depends_on(self, f"gcc-runtime@{v}:", type="link", when=f"%gcc@{v} platform=cray") + + _directives_to_be_executed = [maybe_depend_on_gcc_runtime] + + class PackageViewMixin: """This collects all functionality related to adding installed Spack package to views. Packages can customize how they are added to views by @@ -433,7 +449,7 @@ class PackageViewMixin: Pb = TypeVar("Pb", bound="PackageBase") -class PackageBase(WindowsRPath, PackageViewMixin, metaclass=PackageMeta): +class PackageBase(WindowsRPath, PackageViewMixin, BinaryPackage, metaclass=PackageMeta): """This is the superclass for all spack packages. ***The Package class*** diff --git a/lib/spack/spack/test/conftest.py b/lib/spack/spack/test/conftest.py index 785d986018..df9a43a123 100644 --- a/lib/spack/spack/test/conftest.py +++ b/lib/spack/spack/test/conftest.py @@ -57,6 +57,11 @@ from spack.fetch_strategy import URLFetchStrategy from spack.util.pattern import Bunch +@pytest.fixture(scope="session", autouse=True) +def drop_gcc_runtime(): + spack.package_base.WITH_GCC_RUNTIME = False + + def ensure_configuration_fixture_run_before(request): """Ensure that fixture mutating the configuration run before the one where the function is called. |