Added mixins to modularize common behaviors across build-systems.

Modifications:
  * added a mixin to filter compiler wrappers from files
  * modified hdf5, openmpi, mpich, mvapich2 to use it
This commit is contained in:
alalazo
2017-06-09 21:07:20 +02:00
committed by Todd Gamblin
parent 4d97b540a8
commit 28e129b087
8 changed files with 144 additions and 119 deletions

View File

@@ -26,7 +26,7 @@
import os
class Mpich(AutotoolsPackage):
class Mpich(AutotoolsPackage, FilterCompilerWrappersPackageMixin):
"""MPICH is a high performance and widely portable implementation of
the Message Passing Interface (MPI) standard."""
@@ -170,33 +170,11 @@ def configure_args(self):
return config_args
@run_after('install')
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."""
mpicc = join_path(self.prefix.bin, 'mpicc')
mpicxx = join_path(self.prefix.bin, 'mpicxx')
mpif77 = join_path(self.prefix.bin, 'mpif77')
mpif90 = join_path(self.prefix.bin, 'mpif90')
# Substitute Spack compile wrappers for the real
# underlying compiler
kwargs = {
'ignore_absent': True,
'backup': False,
'string': True
}
filter_file(env['CC'], self.compiler.cc, mpicc, **kwargs)
filter_file(env['CXX'], self.compiler.cxx, mpicxx, **kwargs)
filter_file(env['F77'], self.compiler.f77, mpif77, **kwargs)
filter_file(env['FC'], self.compiler.fc, mpif90, **kwargs)
# Remove this linking flag if present
# (it turns RPATH into RUNPATH)
for wrapper in (mpicc, mpicxx, mpif77, mpif90):
filter_file('-Wl,--enable-new-dtags', '', wrapper, **kwargs)
@property
def compiler_wrappers(self):
return [
join_path(self.prefix.bin, 'mpicc'),
join_path(self.prefix.bin, 'mpicxx'),
join_path(self.prefix.bin, 'mpif77'),
join_path(self.prefix.bin, 'mpif90')
]