diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2024-04-11 09:13:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 09:13:24 +0200 |
commit | 1fe8e63481dfc115966ba3984c5b53dc38e6822c (patch) | |
tree | 7d6f519cc2bf6a316677760a87a4b0aa7216eac5 /var | |
parent | dfca2c285e624920db08f616072d518b9a7cac97 (diff) | |
download | spack-1fe8e63481dfc115966ba3984c5b53dc38e6822c.tar.gz spack-1fe8e63481dfc115966ba3984c5b53dc38e6822c.tar.bz2 spack-1fe8e63481dfc115966ba3984c5b53dc38e6822c.tar.xz spack-1fe8e63481dfc115966ba3984c5b53dc38e6822c.zip |
Reuse specs built with compilers not in config (#43539)
Allow reuse of specs that were built with compilers not in the current configuration. This means that specs from build caches don't need to have a matching compiler locally to be reused. Similarly when updating a distro. If a node needs to be built, only available compilers will be considered as candidates.
Diffstat (limited to 'var')
15 files changed, 110 insertions, 94 deletions
diff --git a/var/spack/repos/builtin/packages/cray-mpich/package.py b/var/spack/repos/builtin/packages/cray-mpich/package.py index fb7405f443..4b422bf38e 100644 --- a/var/spack/repos/builtin/packages/cray-mpich/package.py +++ b/var/spack/repos/builtin/packages/cray-mpich/package.py @@ -70,18 +70,19 @@ class CrayMpich(Package): env.set("MPICXX", join_path(self.prefix.bin, "mpicxx")) env.set("MPIF77", join_path(self.prefix.bin, "mpif77")) env.set("MPIF90", join_path(self.prefix.bin, "mpif90")) - else: + elif spack_cc is not None: env.set("MPICC", spack_cc) env.set("MPICXX", spack_cxx) env.set("MPIF77", spack_fc) env.set("MPIF90", spack_fc) def setup_dependent_build_environment(self, env, dependent_spec): - env.set("MPICH_CC", spack_cc) - env.set("MPICH_CXX", spack_cxx) - env.set("MPICH_F77", spack_f77) - env.set("MPICH_F90", spack_fc) - env.set("MPICH_FC", spack_fc) + dependent_module = dependent_spec.package.module + env.set("MPICH_CC", dependent_module.spack_cc) + env.set("MPICH_CXX", dependent_module.spack_cxx) + env.set("MPICH_F77", dependent_module.spack_f77) + env.set("MPICH_F90", dependent_module.spack_fc) + env.set("MPICH_FC", dependent_module.spack_fc) def setup_dependent_package(self, module, dependent_spec): spec = self.spec @@ -90,7 +91,7 @@ class CrayMpich(Package): spec.mpicxx = join_path(self.prefix.bin, "mpicxx") spec.mpifc = join_path(self.prefix.bin, "mpif90") spec.mpif77 = join_path(self.prefix.bin, "mpif77") - else: + elif spack_cc is not None: spec.mpicc = spack_cc spec.mpicxx = spack_cxx spec.mpifc = spack_fc diff --git a/var/spack/repos/builtin/packages/cray-mvapich2/package.py b/var/spack/repos/builtin/packages/cray-mvapich2/package.py index 88615093d2..b76d583c2b 100644 --- a/var/spack/repos/builtin/packages/cray-mvapich2/package.py +++ b/var/spack/repos/builtin/packages/cray-mvapich2/package.py @@ -27,24 +27,29 @@ class CrayMvapich2(Package): provides("mpi@3") def setup_run_environment(self, env): + if spack_cc is None: + return + env.set("MPICC", spack_cc) env.set("MPICXX", spack_cxx) env.set("MPIF77", spack_fc) env.set("MPIF90", spack_fc) def setup_dependent_build_environment(self, env, dependent_spec): - env.set("MPICH_CC", spack_cc) - env.set("MPICH_CXX", spack_cxx) - env.set("MPICH_F77", spack_f77) - env.set("MPICH_F90", spack_fc) - env.set("MPICH_FC", spack_fc) + dependent_module = dependent_spec.package.module + env.set("MPICH_CC", dependent_module.spack_cc) + env.set("MPICH_CXX", dependent_module.spack_cxx) + env.set("MPICH_F77", dependent_module.spack_f77) + env.set("MPICH_F90", dependent_module.spack_fc) + env.set("MPICH_FC", dependent_module.spack_fc) def setup_dependent_package(self, module, dependent_spec): spec = self.spec - spec.mpicc = spack_cc - spec.mpicxx = spack_cxx - spec.mpifc = spack_fc - spec.mpif77 = spack_f77 + dependent_module = dependent_spec.package.module + spec.mpicc = dependent_module.spack_cc + spec.mpicxx = dependent_module.spack_cxx + spec.mpifc = dependent_module.spack_fc + spec.mpif77 = dependent_module.spack_f77 spec.mpicxx_shared_libs = [ join_path(self.prefix.lib, "libmpicxx.{0}".format(dso_suffix)), diff --git a/var/spack/repos/builtin/packages/intel-mpi/package.py b/var/spack/repos/builtin/packages/intel-mpi/package.py index aa1ae55752..3e8ce47e9d 100644 --- a/var/spack/repos/builtin/packages/intel-mpi/package.py +++ b/var/spack/repos/builtin/packages/intel-mpi/package.py @@ -150,19 +150,21 @@ class IntelMpi(IntelPackage): depends_on("libfabric", when="+external-libfabric", type=("build", "link", "run")) depends_on("cpio", type="build") - def setup_dependent_build_environment(self, *args): + def setup_dependent_build_environment(self, env, dependent_spec): # Handle in callback, conveying client's compilers in additional arg. # CAUTION - DUP code in: # ../intel-mpi/package.py # ../intel-parallel-studio/package.py + dependent_module = dependent_spec.package.module self._setup_dependent_env_callback( - *args, + env, + dependent_spec, compilers_of_client={ - "CC": spack_cc, - "CXX": spack_cxx, - "F77": spack_f77, - "F90": spack_fc, - "FC": spack_fc, + "CC": dependent_module.spack_cc, + "CXX": dependent_module.spack_cxx, + "F77": dependent_module.spack_f77, + "F90": dependent_module.spack_fc, + "FC": dependent_module.spack_fc, }, ) diff --git a/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py b/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py index 973f6cb295..388f6cb742 100644 --- a/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py +++ b/var/spack/repos/builtin/packages/intel-oneapi-mpi/package.py @@ -151,11 +151,12 @@ class IntelOneapiMpi(IntelOneApiLibraryPackage): self.spec.mpifc = join_path(self.component_prefix.bin, "mpiifort") def setup_dependent_build_environment(self, env, dependent_spec): - env.set("I_MPI_CC", spack_cc) - env.set("I_MPI_CXX", spack_cxx) - env.set("I_MPI_F77", spack_f77) - env.set("I_MPI_F90", spack_fc) - env.set("I_MPI_FC", spack_fc) + dependent_module = dependent_spec.package.module + env.set("I_MPI_CC", dependent_module.spack_cc) + env.set("I_MPI_CXX", dependent_module.spack_cxx) + env.set("I_MPI_F77", dependent_module.spack_f77) + env.set("I_MPI_F90", dependent_module.spack_fc) + env.set("I_MPI_FC", dependent_module.spack_fc) # Set compiler wrappers for dependent build stage if "+generic-names" in self.spec: diff --git a/var/spack/repos/builtin/packages/intel-parallel-studio/package.py b/var/spack/repos/builtin/packages/intel-parallel-studio/package.py index b6ab4e405e..5a64a75820 100644 --- a/var/spack/repos/builtin/packages/intel-parallel-studio/package.py +++ b/var/spack/repos/builtin/packages/intel-parallel-studio/package.py @@ -666,19 +666,21 @@ class IntelParallelStudio(IntelPackage): msg="SSE3 is not supported on MacOS x86_64", ) - def setup_dependent_build_environment(self, *args): + def setup_dependent_build_environment(self, env, dependent_spec): # Handle in callback, conveying client's compilers in additional arg. # CAUTION - DUP code in: # ../intel-mpi/package.py # ../intel-parallel-studio/package.py + dependent_module = dependent_spec.package.module self._setup_dependent_env_callback( - *args, + env, + dependent_spec, compilers_of_client={ - "CC": spack_cc, - "CXX": spack_cxx, - "F77": spack_f77, - "F90": spack_fc, - "FC": spack_fc, + "CC": dependent_module.spack_cc, + "CXX": dependent_module.spack_cxx, + "F77": dependent_module.spack_f77, + "F90": dependent_module.spack_fc, + "FC": dependent_module.spack_fc, }, ) diff --git a/var/spack/repos/builtin/packages/mpich/package.py b/var/spack/repos/builtin/packages/mpich/package.py index 1143074eaf..b624bfe866 100644 --- a/var/spack/repos/builtin/packages/mpich/package.py +++ b/var/spack/repos/builtin/packages/mpich/package.py @@ -442,7 +442,7 @@ supported, and netmod is ignored if device is ch3:sock.""", # their run environments the code to make the compilers available. # For Cray MPIs, the regular compiler wrappers *are* the MPI wrappers. # Cray MPIs always have cray in the module name, e.g. "cray-mpich" - if self.spec.satisfies("platform=cray"): + if self.spec.satisfies("platform=cray") and spack_cc is not None: # This is intended to support external MPICH instances registered # by Spack on Cray machines prior to a879c87; users defining an # external MPICH entry for Cray should generally refer to the @@ -458,18 +458,19 @@ supported, and netmod is ignored if device is ch3:sock.""", env.set("MPIF90", join_path(self.prefix.bin, "mpif90")) def setup_dependent_build_environment(self, env, dependent_spec): - env.set("MPICH_CC", spack_cc) - env.set("MPICH_CXX", spack_cxx) - env.set("MPICH_F77", spack_f77) - env.set("MPICH_F90", spack_fc) - env.set("MPICH_FC", spack_fc) + dependent_module = dependent_spec.package.module + env.set("MPICH_CC", dependent_module.spack_cc) + env.set("MPICH_CXX", dependent_module.spack_cxx) + env.set("MPICH_F77", dependent_module.spack_f77) + env.set("MPICH_F90", dependent_module.spack_fc) + env.set("MPICH_FC", dependent_module.spack_fc) def setup_dependent_package(self, module, dependent_spec): spec = self.spec # For Cray MPIs, the regular compiler wrappers *are* the MPI wrappers. # Cray MPIs always have cray in the module name, e.g. "cray-mpich" - if self.spec.satisfies("platform=cray"): + if self.spec.satisfies("platform=cray") and spack_cc is not None: spec.mpicc = spack_cc spec.mpicxx = spack_cxx spec.mpifc = spack_fc diff --git a/var/spack/repos/builtin/packages/mpitrampoline/package.py b/var/spack/repos/builtin/packages/mpitrampoline/package.py index 39fa57564d..f6e440ebd4 100644 --- a/var/spack/repos/builtin/packages/mpitrampoline/package.py +++ b/var/spack/repos/builtin/packages/mpitrampoline/package.py @@ -90,10 +90,11 @@ class Mpitrampoline(CMakePackage): env.set("MPIF90", join_path(self.prefix.bin, "mpifc")) def setup_dependent_build_environment(self, env, dependent_spec): + dependent_module = dependent_spec.package.module # Use the Spack compiler wrappers under MPI - env.set("MPITRAMPOLINE_CC", spack_cc) - env.set("MPITRAMPOLINE_CXX", spack_cxx) - env.set("MPITRAMPOLINE_FC", spack_fc) + env.set("MPITRAMPOLINE_CC", dependent_module.spack_cc) + env.set("MPITRAMPOLINE_CXX", dependent_module.spack_cxx) + env.set("MPITRAMPOLINE_FC", dependent_module.spack_fc) fflags = [] if ( self.spec.satisfies("%apple-clang") diff --git a/var/spack/repos/builtin/packages/mpt/package.py b/var/spack/repos/builtin/packages/mpt/package.py index 7a1a01e482..e9a6c6f18c 100644 --- a/var/spack/repos/builtin/packages/mpt/package.py +++ b/var/spack/repos/builtin/packages/mpt/package.py @@ -36,9 +36,10 @@ class Mpt(BundlePackage): def setup_dependent_build_environment(self, env, dependent_spec): # use the Spack compiler wrappers under MPI - env.set("MPICC_CC", spack_cc) - env.set("MPICXX_CXX", spack_cxx) - env.set("MPIF90_F90", spack_fc) + dependent_module = dependent_spec.package.module + env.set("MPICC_CC", dependent_module.spack_cc) + env.set("MPICXX_CXX", dependent_module.spack_cxx) + env.set("MPIF90_F90", dependent_module.spack_fc) def setup_run_environment(self, env): # Because MPI is both runtime and compiler, we have to setup the mpi @@ -50,10 +51,11 @@ class Mpt(BundlePackage): def setup_dependent_package(self, module, dependent_spec): if "platform=cray" in self.spec: - self.spec.mpicc = spack_cc - self.spec.mpicxx = spack_cxx - self.spec.mpifc = spack_fc - self.spec.mpif77 = spack_f77 + dependent_module = dependent_spec.package.module + self.spec.mpicc = dependent_module.spack_cc + self.spec.mpicxx = dependent_module.spack_cxx + self.spec.mpifc = dependent_module.spack_fc + self.spec.mpif77 = dependent_module.spack_f77 else: self.spec.mpicc = self.prefix.bin.mpicc self.spec.mpicxx = self.prefix.bin.mpicxx diff --git a/var/spack/repos/builtin/packages/msmpi/package.py b/var/spack/repos/builtin/packages/msmpi/package.py index 5d05dd2c25..738e2e0550 100644 --- a/var/spack/repos/builtin/packages/msmpi/package.py +++ b/var/spack/repos/builtin/packages/msmpi/package.py @@ -41,14 +41,14 @@ class Msmpi(Package): return Version(ver_str.group(1)) if ver_str else None def setup_dependent_package(self, module, dependent_spec): - spec = self.spec # MSMPI does not vendor compiler wrappers, instead arguments should # be manually supplied to compiler by consuming package # Note: This is not typical of MPI installations - spec.mpicc = spack_cc - spec.mpicxx = spack_cxx - spec.mpifc = spack_fc - spec.mpif77 = spack_f77 + dependent_module = dependent_spec.package.module + self.spec.mpicc = dependent_module.spack_cc + self.spec.mpicxx = dependent_module.spack_cxx + self.spec.mpifc = dependent_module.spack_fc + self.spec.mpif77 = dependent_module.spack_f77 class GenericBuilder(GenericBuilder): diff --git a/var/spack/repos/builtin/packages/mvapich/package.py b/var/spack/repos/builtin/packages/mvapich/package.py index d2b429d3c1..bdb66c763d 100644 --- a/var/spack/repos/builtin/packages/mvapich/package.py +++ b/var/spack/repos/builtin/packages/mvapich/package.py @@ -215,16 +215,17 @@ class Mvapich(AutotoolsPackage): self.setup_compiler_environment(env) # use the Spack compiler wrappers under MPI - env.set("MPICH_CC", spack_cc) - env.set("MPICH_CXX", spack_cxx) - env.set("MPICH_F77", spack_f77) - env.set("MPICH_F90", spack_fc) - env.set("MPICH_FC", spack_fc) + dependent_module = dependent_spec.package.module + env.set("MPICH_CC", dependent_module.spack_cc) + env.set("MPICH_CXX", dependent_module.spack_cxx) + env.set("MPICH_F77", dependent_module.spack_f77) + env.set("MPICH_F90", dependent_module.spack_fc) + env.set("MPICH_FC", dependent_module.spack_fc) def setup_compiler_environment(self, env): # For Cray MPIs, the regular compiler wrappers *are* the MPI wrappers. # Cray MPIs always have cray in the module name, e.g. "cray-mvapich" - if self.spec.satisfies("platform=cray"): + if self.spec.satisfies("platform=cray") and spack_cc is not None: env.set("MPICC", spack_cc) env.set("MPICXX", spack_cxx) env.set("MPIF77", spack_fc) diff --git a/var/spack/repos/builtin/packages/mvapich2-gdr/package.py b/var/spack/repos/builtin/packages/mvapich2-gdr/package.py index a284f6ffa0..ae9ad23d02 100755 --- a/var/spack/repos/builtin/packages/mvapich2-gdr/package.py +++ b/var/spack/repos/builtin/packages/mvapich2-gdr/package.py @@ -166,13 +166,12 @@ class Mvapich2Gdr(AutotoolsPackage): def setup_dependent_build_environment(self, env, dependent_spec): self.setup_compiler_environment(env) - - # use the Spack compiler wrappers under MPI - env.set("MPICH_CC", spack_cc) - env.set("MPICH_CXX", spack_cxx) - env.set("MPICH_F77", spack_f77) - env.set("MPICH_F90", spack_fc) - env.set("MPICH_FC", spack_fc) + dependent_module = dependent_spec.package.module + env.set("MPICH_CC", dependent_module.spack_cc) + env.set("MPICH_CXX", dependent_module.spack_cxx) + env.set("MPICH_F77", dependent_module.spack_f77) + env.set("MPICH_F90", dependent_module.spack_fc) + env.set("MPICH_FC", dependent_module.spack_fc) def setup_compiler_environment(self, env): env.set("MPICC", join_path(self.prefix.bin, "mpicc")) diff --git a/var/spack/repos/builtin/packages/mvapich2/package.py b/var/spack/repos/builtin/packages/mvapich2/package.py index 7e9204ffbd..9ab54c3eaa 100644 --- a/var/spack/repos/builtin/packages/mvapich2/package.py +++ b/var/spack/repos/builtin/packages/mvapich2/package.py @@ -375,18 +375,18 @@ class Mvapich2(AutotoolsPackage): def setup_dependent_build_environment(self, env, dependent_spec): self.setup_compiler_environment(env) - # use the Spack compiler wrappers under MPI - env.set("MPICH_CC", spack_cc) - env.set("MPICH_CXX", spack_cxx) - env.set("MPICH_F77", spack_f77) - env.set("MPICH_F90", spack_fc) - env.set("MPICH_FC", spack_fc) + dependent_module = dependent_spec.package.module + env.set("MPICH_CC", dependent_module.spack_cc) + env.set("MPICH_CXX", dependent_module.spack_cxx) + env.set("MPICH_F77", dependent_module.spack_f77) + env.set("MPICH_F90", dependent_module.spack_fc) + env.set("MPICH_FC", dependent_module.spack_fc) def setup_compiler_environment(self, env): # For Cray MPIs, the regular compiler wrappers *are* the MPI wrappers. # Cray MPIs always have cray in the module name, e.g. "cray-mvapich" - if self.spec.satisfies("platform=cray"): + if self.spec.satisfies("platform=cray") and spack_cc is not None: env.set("MPICC", spack_cc) env.set("MPICXX", spack_cxx) env.set("MPIF77", spack_fc) @@ -400,7 +400,7 @@ class Mvapich2(AutotoolsPackage): def setup_dependent_package(self, module, dependent_spec): # For Cray MPIs, the regular compiler wrappers *are* the MPI wrappers. # Cray MPIs always have cray in the module name, e.g. "cray-mvapich" - if self.spec.satisfies("platform=cray"): + if self.spec.satisfies("platform=cray") and spack_cc is not None: self.spec.mpicc = spack_cc self.spec.mpicxx = spack_cxx self.spec.mpifc = spack_fc diff --git a/var/spack/repos/builtin/packages/mvapich2x/package.py b/var/spack/repos/builtin/packages/mvapich2x/package.py index b817f3cd34..5962ef6968 100644 --- a/var/spack/repos/builtin/packages/mvapich2x/package.py +++ b/var/spack/repos/builtin/packages/mvapich2x/package.py @@ -218,13 +218,13 @@ class Mvapich2x(AutotoolsPackage): def setup_dependent_build_environment(self, env, dependent_spec): self.setup_compiler_environment(env) - # use the Spack compiler wrappers under MPI - env.set("MPICH_CC", spack_cc) - env.set("MPICH_CXX", spack_cxx) - env.set("MPICH_F77", spack_f77) - env.set("MPICH_F90", spack_fc) - env.set("MPICH_FC", spack_fc) + dependent_module = dependent_spec.package.module + env.set("MPICH_CC", dependent_module.spack_cc) + env.set("MPICH_CXX", dependent_module.spack_cxx) + env.set("MPICH_F77", dependent_module.spack_f77) + env.set("MPICH_F90", dependent_module.spack_fc) + env.set("MPICH_FC", dependent_module.spack_fc) def setup_compiler_environment(self, env): # For Cray MPIs, the regular compiler wrappers *are* the MPI wrappers. diff --git a/var/spack/repos/builtin/packages/openmpi/package.py b/var/spack/repos/builtin/packages/openmpi/package.py index a995a271b4..abbf212857 100644 --- a/var/spack/repos/builtin/packages/openmpi/package.py +++ b/var/spack/repos/builtin/packages/openmpi/package.py @@ -845,10 +845,11 @@ class Openmpi(AutotoolsPackage, CudaPackage): def setup_dependent_build_environment(self, env, dependent_spec): # Use the spack compiler wrappers under MPI - env.set("OMPI_CC", spack_cc) - env.set("OMPI_CXX", spack_cxx) - env.set("OMPI_FC", spack_fc) - env.set("OMPI_F77", spack_f77) + dependent_module = dependent_spec.package.module + env.set("OMPI_CC", dependent_module.spack_cc) + env.set("OMPI_CXX", dependent_module.spack_cxx) + env.set("OMPI_FC", dependent_module.spack_fc) + env.set("OMPI_F77", dependent_module.spack_f77) # See https://www.open-mpi.org/faq/?category=building#installdirs for suffix in [ @@ -870,7 +871,7 @@ class Openmpi(AutotoolsPackage, CudaPackage): "PKGLIBDIR", "PKGINCLUDEDIR", ]: - env.unset("OPAL_%s" % suffix) + env.unset(f"OPAL_{suffix}") def setup_dependent_package(self, module, dependent_spec): self.spec.mpicc = join_path(self.prefix.bin, "mpicc") diff --git a/var/spack/repos/builtin/packages/spectrum-mpi/package.py b/var/spack/repos/builtin/packages/spectrum-mpi/package.py index ca7a55e599..eeb878b876 100644 --- a/var/spack/repos/builtin/packages/spectrum-mpi/package.py +++ b/var/spack/repos/builtin/packages/spectrum-mpi/package.py @@ -136,11 +136,11 @@ class SpectrumMpi(BundlePackage): env.set("MPIF77", os.path.join(self.prefix.bin, "mpif77")) env.set("MPIF90", os.path.join(self.prefix.bin, "mpif90")) - env.set("OMPI_CC", spack_cc) - env.set("OMPI_CXX", spack_cxx) - env.set("OMPI_FC", spack_fc) - env.set("OMPI_F77", spack_f77) - + dependent_module = dependent_spec.package.module + env.set("OMPI_CC", dependent_module.spack_cc) + env.set("OMPI_CXX", dependent_module.spack_cxx) + env.set("OMPI_FC", dependent_module.spack_fc) + env.set("OMPI_F77", dependent_module.spack_f77) env.prepend_path("LD_LIBRARY_PATH", self.prefix.lib) def setup_run_environment(self, env): |