From 22a45e010af069b2526b0e5d3d39e2cc8db1726f Mon Sep 17 00:00:00 2001 From: Peter Scheibel Date: Mon, 4 Jan 2021 17:19:08 -0800 Subject: [PATCH] Bugfix: Support old installations using Cray MPICH (#20663) #20076 moved Cray-specific MPICH support from the Spack MPICH package to a new cray-mpich Package. This broke existing package installs using external mpich on Cray systems. This PR keeps the cray-mpich package but restores the Cray-specific MPICH support for older installations. In the future this support should be removed from the Spack mpich package and users should be directed to use cray-mpich on Cray. --- .../repos/builtin/packages/mpich/package.py | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/var/spack/repos/builtin/packages/mpich/package.py b/var/spack/repos/builtin/packages/mpich/package.py index edc6f324ed..6d5d7b4373 100644 --- a/var/spack/repos/builtin/packages/mpich/package.py +++ b/var/spack/repos/builtin/packages/mpich/package.py @@ -301,10 +301,23 @@ def setup_build_environment(self, env): def setup_run_environment(self, env): # Because MPI implementations provide compilers, they have to add to # their run environments the code to make the compilers available. - env.set('MPICC', join_path(self.prefix.bin, 'mpicc')) - env.set('MPICXX', join_path(self.prefix.bin, 'mpic++')) - env.set('MPIF77', join_path(self.prefix.bin, 'mpif77')) - env.set('MPIF90', join_path(self.prefix.bin, 'mpif90')) + # For Cray MPIs, the regular compiler wrappers *are* the MPI wrappers. + # Cray MPIs always have cray in the module name, e.g. "cray-mpich" + external_modules = self.spec.external_modules + if external_modules and 'cray' in external_modules[0]: + # 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 + # "cray-mpich" package + env.set('MPICC', spack_cc) + env.set('MPICXX', spack_cxx) + env.set('MPIF77', spack_fc) + env.set('MPIF90', spack_fc) + else: + env.set('MPICC', join_path(self.prefix.bin, 'mpicc')) + env.set('MPICXX', join_path(self.prefix.bin, 'mpic++')) + env.set('MPIF77', join_path(self.prefix.bin, 'mpif77')) + env.set('MPIF90', join_path(self.prefix.bin, 'mpif90')) def setup_dependent_build_environment(self, env, dependent_spec): self.setup_run_environment(env) @@ -318,12 +331,21 @@ def setup_dependent_build_environment(self, env, dependent_spec): def setup_dependent_package(self, module, dependent_spec): spec = self.spec - spec.mpicc = join_path(self.prefix.bin, 'mpicc') - spec.mpicxx = join_path(self.prefix.bin, 'mpic++') + # For Cray MPIs, the regular compiler wrappers *are* the MPI wrappers. + # Cray MPIs always have cray in the module name, e.g. "cray-mpich" + external_modules = spec.external_modules + if external_modules and 'cray' in external_modules[0]: + spec.mpicc = spack_cc + spec.mpicxx = spack_cxx + spec.mpifc = spack_fc + spec.mpif77 = spack_f77 + else: + spec.mpicc = join_path(self.prefix.bin, 'mpicc') + spec.mpicxx = join_path(self.prefix.bin, 'mpic++') - if '+fortran' in spec: - spec.mpifc = join_path(self.prefix.bin, 'mpif90') - spec.mpif77 = join_path(self.prefix.bin, 'mpif77') + if '+fortran' in spec: + spec.mpifc = join_path(self.prefix.bin, 'mpif90') + spec.mpif77 = join_path(self.prefix.bin, 'mpif77') spec.mpicxx_shared_libs = [ join_path(self.prefix.lib, 'libmpicxx.{0}'.format(dso_suffix)),