builtin.mock et al. : changes to packages

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
Massimiliano Culpo 2024-09-25 15:01:19 +02:00
parent 8c1a4de9e2
commit 18152b9b0f
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C
66 changed files with 239 additions and 51 deletions

View File

@ -16,5 +16,8 @@ class Bowtie(Package):
version("1.2.2", md5="1c837ecd990bb022d07e7aab32b09847")
version("1.2.0", md5="1c837ecd990bb022d07e7aab32b09847")
depends_on("c", type="build")
conflicts("%gcc@:4.5.0", when="@1.2.2")
conflicts("%gcc@:10.2.1", when="@:1.3.0")
conflicts("%gcc@:10.2.1", when="@:1.2.9")
conflicts("%gcc", when="@1.3")

View File

@ -14,6 +14,8 @@ class Callpath(Package):
version("0.9", md5="0123456789abcdef0123456789abcdef")
version("1.0", md5="0123456789abcdef0123456789abcdef")
depends_on("c", type="build")
depends_on("dyninst")
depends_on("mpi")

View File

@ -30,6 +30,8 @@ class CmakeClient(CMakePackage):
variant("single", description="", default="blue", values=("blue", "red", "green"), multi=False)
variant("truthy", description="", default=True)
depends_on("c", type="build")
callback_counter = 0
flipped = False

View File

@ -21,6 +21,9 @@ class Cmake(Package):
homepage = "https://www.cmake.org"
url = "https://cmake.org/files/v3.4/cmake-3.4.3.tar.gz"
depends_on("c", type="build")
depends_on("cxx", type="build")
version(
"3.23.1",
md5="4cb3ff35b2472aae70f542116d616e63",

View File

@ -15,6 +15,7 @@ class ConflictParent(Package):
version("1.0", md5="0123456789abcdef0123456789abcdef")
depends_on("conflict")
depends_on("c", type="build")
conflicts("^conflict~foo", when="@0.9")

View File

@ -18,6 +18,8 @@ class Conflict(Package):
conflicts("%clang", when="+foo")
depends_on("c", type="build")
def install(self, spec, prefix):
configure("--prefix=%s" % prefix)
make()

View File

@ -13,3 +13,5 @@ class DtDiamondBottom(Package):
url = "http://www.example.com/dt-diamond-bottom-1.0.tar.gz"
version("1.0", md5="0123456789abcdef0123456789abcdef")
depends_on("c", type="build")

View File

@ -15,3 +15,4 @@ class DtDiamondLeft(Package):
version("1.0", md5="0123456789abcdef0123456789abcdef")
depends_on("dt-diamond-bottom", type="build")
depends_on("c", type="build")

View File

@ -15,3 +15,4 @@ class DtDiamondRight(Package):
version("1.0", md5="0123456789abcdef0123456789abcdef")
depends_on("dt-diamond-bottom", type=("build", "link", "run"))
depends_on("c", type="build")

View File

@ -16,3 +16,5 @@ class DtDiamond(Package):
depends_on("dt-diamond-left")
depends_on("dt-diamond-right")
depends_on("c", type="build")

View File

@ -29,6 +29,8 @@ class Dyninst(Package):
depends_on("libelf")
depends_on("libdwarf")
depends_on("c", type="build")
def install(self, spec, prefix):
mkdirp(prefix)
touch(join_path(prefix, "dummyfile"))

View File

@ -19,4 +19,6 @@ class Fftw(Package):
variant("mpi", default=False, description="Enable MPI")
depends_on("c", type="build")
depends_on("mpi", when="+mpi")

View File

@ -0,0 +1 @@
../../builtin/packages/gcc-runtime

View File

@ -2,6 +2,7 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import os.path
from spack.package import *
@ -24,7 +25,9 @@ class Gcc(CompilerPackage, Package):
description="Compilers and runtime libraries to build",
)
depends_on("conflict", when="@3.0")
provides("c", when="languages=c")
provides("cxx", when="languages=c++")
provides("fortran", when="languages=fortran")
c_names = ["gcc"]
cxx_names = ["g++"]
@ -34,9 +37,100 @@ class Gcc(CompilerPackage, Package):
compiler_version_regex = r"(?<!clang version)\s?([0-9.]+)"
compiler_version_argument = ("-dumpfullversion", "-dumpversion")
link_paths = {
"c": os.path.join("gcc", "gcc"),
"cxx": os.path.join("gcc", "g++"),
"fortran": os.path.join("gcc", "gfortran"),
}
def install(self, spec, prefix):
# Create the minimal compiler that will fool `spack compiler find`
mkdirp(prefix.bin)
with open(prefix.bin.gcc, "w") as f:
f.write('#!/bin/bash\necho "%s"' % str(spec.version))
set_executable(prefix.bin.gcc)
@property
def cc(self):
msg = "cannot retrieve C compiler [spec is not concrete]"
assert self.spec.concrete, msg
if self.spec.external:
return self.spec.extra_attributes["compilers"].get("c", None)
result = None
if "languages=c" in self.spec:
result = str(self.spec.prefix.bin.gcc)
return result
@property
def cxx(self):
msg = "cannot retrieve C++ compiler [spec is not concrete]"
assert self.spec.concrete, msg
if self.spec.external:
return self.spec.extra_attributes["compilers"].get("cxx", None)
result = None
if "languages=c++" in self.spec:
result = os.path.join(self.spec.prefix.bin, "g++")
return result
@property
def fortran(self):
msg = "cannot retrieve Fortran compiler [spec is not concrete]"
assert self.spec.concrete, msg
if self.spec.external:
return self.spec.extra_attributes["compilers"].get("fortran", None)
result = None
if "languages=fortran" in self.spec:
result = str(self.spec.prefix.bin.gfortran)
return result
@classmethod
def runtime_constraints(cls, *, spec, pkg):
"""Callback function to inject runtime-related rules into the solver.
Rule-injection is obtained through method calls of the ``pkg`` argument.
Documentation for this function is temporary. When the API will be in its final state,
we'll document the behavior at https://spack.readthedocs.io/en/latest/
Args:
spec: spec that will inject runtime dependencies
pkg: object used to forward information to the solver
"""
pkg("*").depends_on(
"gcc-runtime",
when="%gcc",
type="link",
description="If any package uses %gcc, it depends on gcc-runtime",
)
pkg("*").depends_on(
f"gcc-runtime@{str(spec.version)}:",
when=f"^[deptypes=build] {spec.name}@{spec.versions}",
type="link",
description=f"If any package uses %{str(spec)}, "
f"it depends on gcc-runtime@{str(spec.version)}:",
)
gfortran_str = "libgfortran@5"
if spec.satisfies("gcc@:6"):
gfortran_str = "libgfortran@3"
elif spec.satisfies("gcc@7"):
gfortran_str = "libgfortran@4"
for fortran_virtual in ("fortran-rt", gfortran_str):
pkg("*").depends_on(
fortran_virtual,
when=f"^[virtuals=fortran deptypes=build] {spec.name}@{spec.versions}",
type="link",
description=f"Add a dependency on '{gfortran_str}' for nodes compiled with "
f"{str(spec)} and using the 'fortran' language",
)
# The version of gcc-runtime is the same as the %gcc used to "compile" it
pkg("gcc-runtime").requires(
f"@{str(spec.versions)}", when=f"^[deptypes=build] {spec.name}@{spec.versions}"
)
# If a node used %gcc@X.Y its dependencies must use gcc-runtime@:X.Y
# (technically @:X is broader than ... <= @=X but this should work in practice)
pkg("*").propagate(
f"gcc@:{str(spec.version)}", when=f"^[deptypes=build] {spec.name}@{spec.versions}"
)

View File

@ -27,6 +27,8 @@ class IntelOneapiCompilers(Package, CompilerPackage):
r"(?:(?:oneAPI DPC\+\+(?:\/C\+\+)? Compiler)|(?:\(IFORT\))|(?:\(IFX\))) (\S+)"
)
depends_on("c", type="build")
@property
def compiler_search_prefix(self):
return self.prefix.foo.bar.baz.bin

View File

@ -21,5 +21,8 @@ class Libdwarf(Package):
depends_on("libelf")
depends_on("c", type="build")
depends_on("cxx", type="build")
def install(self, spec, prefix):
touch(prefix.libdwarf)

View File

@ -16,5 +16,7 @@ class Libelf(Package):
patch("local.patch", when="@0.8.10")
depends_on("c", type="build")
def install(self, spec, prefix):
touch(prefix.libelf)

View File

@ -18,6 +18,8 @@ class Llvm(Package, CompilerPackage):
"clang", default=True, description="Build the LLVM C/C++/Objective-C compiler frontend"
)
provides("c", "cxx", when="+clang")
c_names = ["clang"]
cxx_names = ["clang++"]
fortran_names = ["flang"]
@ -28,3 +30,36 @@ def install(self, spec, prefix):
with open(prefix.bin.gcc, "w") as f:
f.write('#!/bin/bash\necho "%s"' % str(spec.version))
set_executable(prefix.bin.gcc)
@property
def cc(self):
msg = "cannot retrieve C compiler [spec is not concrete]"
assert self.spec.concrete, msg
if self.spec.external:
return self.spec.extra_attributes["compilers"].get("c", None)
result = None
if "+clang" in self.spec:
result = os.path.join(self.spec.prefix.bin, "clang")
return result
@property
def cxx(self):
msg = "cannot retrieve C++ compiler [spec is not concrete]"
assert self.spec.concrete, msg
if self.spec.external:
return self.spec.extra_attributes["compilers"].get("cxx", None)
result = None
if "+clang" in self.spec:
result = os.path.join(self.spec.prefix.bin, "clang++")
return result
@property
def fortan(self):
msg = "cannot retrieve Fortran compiler [spec is not concrete]"
assert self.spec.concrete, msg
if self.spec.external:
return self.spec.extra_attributes["compilers"].get("fc", None)
result = None
if "+flang" in self.spec:
result = os.path.join(self.spec.prefix.bin, "flang")
return result

View File

@ -27,6 +27,10 @@ class Mpich(Package):
provides("mpi@:3", when="@3:")
provides("mpi@:1", when="@:1")
depends_on("c", type="build")
depends_on("cxx", type="build")
depends_on("fortran", type="build")
def install(self, spec, prefix):
touch(prefix.mpich)

View File

@ -25,6 +25,8 @@ class Mpich2(Package):
provides("mpi@:2.1", when="@1.1:")
provides("mpi@:2.2", when="@1.2:")
depends_on("c", type="build")
def install(self, spec, prefix):
configure("--prefix=%s" % prefix)
make()

View File

@ -25,6 +25,8 @@ class Mpileaks(Package):
depends_on("mpi")
depends_on("callpath")
depends_on("c", type="build")
# Will be used to try raising an exception
libs = None

View File

@ -26,6 +26,7 @@ class Multimethod(MultimethodBase):
variant("mpi", default=False, description="")
depends_on("mpi", when="+mpi")
depends_on("c", type="build")
#
# These functions are only valid for versions 1, 3, and 4.
@ -80,7 +81,7 @@ def mpi_version(self):
def has_a_default(self):
return "default"
@when("%gcc")
@when("%gcc@10:")
def has_a_default(self):
return "gcc"

View File

@ -42,3 +42,5 @@ class MultivalueVariant(Package):
depends_on("callpath")
depends_on("pkg-a")
depends_on("pkg-a@1.0", when="fee=barbaz")
depends_on("c", type="build")

View File

@ -15,3 +15,4 @@ class OpenblasWithLapack(Package):
version("0.2.15", md5="b1190f3d3471685f17cfd1ec1d252ac9")
provides("lapack", "blas")
depends_on("c", type="build")

View File

@ -19,6 +19,8 @@ class Openblas(Package):
variant("shared", default=True, description="Build shared libraries")
depends_on("c", type="build")
# See #20019 for this conflict
conflicts("%gcc@:4.4", when="@0.2.14:")

View File

@ -36,6 +36,8 @@ class PkgA(AutotoolsPackage):
depends_on("pkg-b", when="foobar=bar")
depends_on("test-dependency", type="test")
depends_on("c", type="build")
parallel = False

View File

@ -19,4 +19,5 @@ class PkgB(Package):
"foo", description="", values=any_combination_of("bar", "baz", "fee").with_default("bar")
)
depends_on("c", type="build")
depends_on("test-dependency", type="test")

View File

@ -12,4 +12,16 @@ class PkgC(Package):
homepage = "http://www.example.com"
url = "http://www.example.com/c-1.0.tar.gz"
# Needed to test CDash reporting
phases = ["configure", "build", "install"]
version("1.0", md5="0123456789abcdef0123456789abcdef")
def configure(self, spec, prefix):
pass
def build(self, spec, prefix):
pass
def install(self, spec, prefix):
touch(prefix.pkg_c)

View File

@ -16,3 +16,5 @@ class RequiresClang(Package):
version("0.9", md5="abcd456789abcdef0123456789abcdef")
requires("%clang", msg="can only be compiled with Clang")
depends_on("c", type="build")

View File

@ -16,3 +16,5 @@ class RequiresClangOrGcc(Package):
version("0.9", md5="abcd456789abcdef0123456789abcdef")
requires("%gcc", "%clang", policy="one_of")
depends_on("c", type="build")

View File

@ -29,3 +29,5 @@ class SimpleInheritance(BaseWithDirectives):
depends_on("openblas", when="+openblas")
provides("lapack", when="+openblas")
depends_on("c", type="build")

View File

@ -15,3 +15,5 @@ class StickyVariantDependent(AutotoolsPackage):
depends_on("sticky-variant")
conflicts("%gcc", when="^sticky-variant~allow-gcc")
depends_on("c", type="build")

View File

@ -16,3 +16,5 @@ class StickyVariant(AutotoolsPackage):
variant("allow-gcc", description="", default=False, sticky=True)
conflicts("%gcc", when="~allow-gcc")
depends_on("c", type="build")

View File

@ -15,6 +15,8 @@ class WithConstraintMet(Package):
version("2.0", md5="0123456789abcdef0123456789abcdef")
version("1.0", md5="0123456789abcdef0123456789abcdef")
depends_on("c", type="build")
with when("@1.0"):
depends_on("pkg-b")
conflicts("%gcc", when="+foo")

View File

@ -16,4 +16,6 @@ class Zmpi(Package):
version("1.0", md5="0123456789abcdef0123456789abcdef")
provides("mpi@:10.0")
depends_on("fake")
depends_on("c", type="build")

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gcc

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gcc-runtime

View File

@ -1,13 +0,0 @@
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
class GccRuntime(Package):
homepage = "https://example.com"
has_code = False
tags = ["runtime"]
requires("%gcc")

View File

@ -1,35 +0,0 @@
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
class Gcc(Package):
homepage = "http://www.example.com/"
has_code = False
version("13.2.0")
version("12.3.0")
@classmethod
def runtime_constraints(cls, *, spec, pkg):
pkg("*").depends_on(
"gcc-runtime",
when="%gcc",
type="link",
description="If any package uses %gcc, it depends on gcc-runtime",
)
pkg("*").depends_on(
f"gcc-runtime@{str(spec.version)}:",
when=f"%{str(spec)}",
type="link",
description=f"If any package uses %{str(spec)}, "
f"it depends on gcc-runtime@{str(spec.version)}:",
)
# The version of gcc-runtime is the same as the %gcc used to "compile" it
pkg("gcc-runtime").requires(f"@={str(spec.version)}", when=f"%{str(spec)}")
# If a node used %gcc@X.Y its dependencies must use gcc-runtime@:X.Y
pkg("*").propagate(f"%gcc@:{str(spec.version)}", when=f"%{str(spec)}")

View File

@ -0,0 +1 @@
../../builtin.mock/packages/glibc

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gmake

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gnuconfig

View File

@ -11,3 +11,6 @@ class PkgA(Package):
version("1.0")
depends_on("pkg-b")
depends_on("c", type="build")
depends_on("cxx", type="build")

View File

@ -10,3 +10,6 @@ class PkgB(Package):
has_code = False
version("1.0")
depends_on("c", type="build")
depends_on("cxx", type="build")

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gcc

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gcc-runtime

View File

@ -0,0 +1 @@
../../builtin.mock/packages/glibc

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gnuconfig

View File

@ -0,0 +1 @@
../../builtin.mock/packages/llvm

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gcc

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gcc-runtime

View File

@ -0,0 +1 @@
../../builtin.mock/packages/glibc

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gmake

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gnuconfig

View File

@ -0,0 +1 @@
../../builtin.mock/packages/llvm

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gcc

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gcc-runtime

View File

@ -0,0 +1 @@
../../builtin.mock/packages/glibc

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gmake/

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gnuconfig

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gcc

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gcc-runtime

View File

@ -0,0 +1 @@
../../builtin.mock/packages/glibc

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gmake/

View File

@ -0,0 +1 @@
../../builtin.mock/packages/gnuconfig

View File

@ -0,0 +1 @@
../../builtin.mock/packages/llvm