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)
This commit is contained in:
Harmen Stoppels
2023-11-16 10:04:58 +01:00
committed by Todd Gamblin
parent 0a5f2fc94d
commit 8371bb4e19
6 changed files with 250 additions and 1 deletions

View File

@@ -36,6 +36,7 @@
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:

View File

@@ -53,6 +53,7 @@
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 @@
"""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 _wrapper(instance, *args, **kwargs):
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 @@ def remove_files_from_view(self, view, merge_map):
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***

View File

@@ -57,6 +57,11 @@
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.