From 0daa08416a0209a71b131fb9c8b4d58fa222474f Mon Sep 17 00:00:00 2001 From: Nicolas Richart Date: Wed, 9 Dec 2015 20:00:54 +0100 Subject: [PATCH] corrected filter_compilers + added it for mvapich2 --- var/spack/packages/mpich/package.py | 13 +++++++---- var/spack/packages/mvapich2/package.py | 30 +++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/var/spack/packages/mpich/package.py b/var/spack/packages/mpich/package.py index e018a08201..7cfa0a3b61 100644 --- a/var/spack/packages/mpich/package.py +++ b/var/spack/packages/mpich/package.py @@ -85,8 +85,13 @@ def filter_compilers(self): mpif77 = os.path.join(bin, 'mpif77') mpif90 = os.path.join(bin, 'mpif90') + spack_cc = os.environ['CC'] + spack_cxx = os.environ['CXX'] + spack_f77 = os.environ['F77'] + spack_fc = os.environ['FC'] + kwargs = { 'ignore_absent' : True, 'backup' : False, 'string' : True } - filter_file('CC="cc"', 'CC="%s"' % self.compiler.cc, mpicc, **kwargs) - filter_file('CXX="c++"', 'CXX="%s"' % self.compiler.cxx, mpicxx, **kwargs) - filter_file('F77="f77"', 'F77="%s"' % self.compiler.f77, mpif77, **kwargs) - filter_file('FC="f90"', 'FC="%s"' % self.compiler.fc, mpif90, **kwargs) + filter_file('CC="%s"' % spack_cc , 'CC="%s"' % self.compiler.cc, mpicc, **kwargs) + filter_file('CXX="%s"'% spack_cxx, 'CXX="%s"' % self.compiler.cxx, mpicxx, **kwargs) + filter_file('F77="%s"'% spack_f77, 'F77="%s"' % self.compiler.f77, mpif77, **kwargs) + filter_file('FC="%s"' % spack_fc , 'FC="%s"' % self.compiler.fc, mpif90, **kwargs) diff --git a/var/spack/packages/mvapich2/package.py b/var/spack/packages/mvapich2/package.py index dc2b2cb23f..23a11b3171 100644 --- a/var/spack/packages/mvapich2/package.py +++ b/var/spack/packages/mvapich2/package.py @@ -1,5 +1,5 @@ from spack import * - +import os class Mvapich2(Package): """MVAPICH2 is an MPI implementation for Infiniband networks.""" @@ -154,3 +154,31 @@ def install(self, spec, prefix): configure(*configure_args) make() make("install") + + self.filter_compilers() + + + def filter_compilers(self): + """Run after install to make the MPI compilers use the + compilers that Spack built the package with. + + If this isn't done, they'll have CC, CXX, F77, and FC set + to Spack's generic cc, c++, f77, and f90. We want them to + be bound to whatever compiler they were built with. + """ + bin = self.prefix.bin + mpicc = os.path.join(bin, 'mpicc') + mpicxx = os.path.join(bin, 'mpicxx') + mpif77 = os.path.join(bin, 'mpif77') + mpif90 = os.path.join(bin, 'mpif90') + + spack_cc = os.environ['CC'] + spack_cxx = os.environ['CXX'] + spack_f77 = os.environ['F77'] + spack_fc = os.environ['FC'] + + kwargs = { 'ignore_absent' : True, 'backup' : False, 'string' : True } + filter_file('CC="%s"' % spack_cc , 'CC="%s"' % self.compiler.cc, mpicc, **kwargs) + filter_file('CXX="%s"'% spack_cxx, 'CXX="%s"' % self.compiler.cxx, mpicxx, **kwargs) + filter_file('F77="%s"'% spack_f77, 'F77="%s"' % self.compiler.f77, mpif77, **kwargs) + filter_file('FC="%s"' % spack_fc , 'FC="%s"' % self.compiler.fc, mpif90, **kwargs)