From f5d3b82bcd3019f62e932cd9724cbcd76c262f77 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 13 Aug 2020 20:25:55 +0200 Subject: Make mpich buildable without fortran (#17964) When the user explicitly sets ~fortran, mpich builds without fortran support. This will make building C/C++ libraries using clang easier, since clang does not offer a fortran compiler by default (yet). Since the user has to disable Fortran support explicitly, this change is not breaking. --- var/spack/repos/builtin/packages/mpich/package.py | 41 ++++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/var/spack/repos/builtin/packages/mpich/package.py b/var/spack/repos/builtin/packages/mpich/package.py index af24802b90..b120762bf9 100644 --- a/var/spack/repos/builtin/packages/mpich/package.py +++ b/var/spack/repos/builtin/packages/mpich/package.py @@ -69,6 +69,7 @@ spack package at this time.''', 'minimalistic implementation') variant('argobots', default=False, description='Enable Argobots support') + variant('fortran', default=True, description='Enable Fortran support') provides('mpi') provides('mpi@:3.0', when='@3:') @@ -209,21 +210,25 @@ spack package at this time.''', env.set('MPICH_FC', 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" - external_modules = self.spec.external_modules + external_modules = spec.external_modules if external_modules and 'cray' in external_modules[0]: - self.spec.mpicc = spack_cc - self.spec.mpicxx = spack_cxx - self.spec.mpifc = spack_fc - self.spec.mpif77 = spack_f77 + spec.mpicc = spack_cc + spec.mpicxx = spack_cxx + spec.mpifc = spack_fc + spec.mpif77 = spack_f77 else: - self.spec.mpicc = join_path(self.prefix.bin, 'mpicc') - self.spec.mpicxx = join_path(self.prefix.bin, 'mpic++') - self.spec.mpifc = join_path(self.prefix.bin, 'mpif90') - self.spec.mpif77 = join_path(self.prefix.bin, 'mpif77') + 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') - self.spec.mpicxx_shared_libs = [ + spec.mpicxx_shared_libs = [ join_path(self.prefix.lib, 'libmpicxx.{0}'.format(dso_suffix)), join_path(self.prefix.lib, 'libmpi.{0}'.format(dso_suffix)) ] @@ -243,9 +248,18 @@ spack package at this time.''', # Until we can pass variants such as +fortran through virtual # dependencies depends_on('mpi'), require Fortran compiler to # avoid delayed build errors in dependents. - if (self.compiler.f77 is None) or (self.compiler.fc is None): + # The user can work around this by disabling Fortran explicitly + # with ~fortran + + f77 = self.compiler.f77 + fc = self.compiler.fc + + fortran_missing = f77 is None or fc is None + + if '+fortran' in self.spec and fortran_missing: raise InstallError( - 'MPICH requires both C and Fortran compilers!' + 'mpich +fortran requires Fortran compilers. Configure ' + 'Fortran compiler or disable Fortran support with ~fortran' ) def configure_args(self): @@ -262,6 +276,9 @@ spack package at this time.''', spec else 'yes') ] + if '~fortran' in spec: + config_args.append('--disable-fortran') + if '+slurm' in spec: config_args.append('--with-slurm=yes') config_args.append('--with-slurm-include={0}'.format( -- cgit v1.2.3-70-g09d2