Esmf fixes for Cray, OSX and mpich (#6768)

* esmf: put .mod files in the spack compiler search path

* esmf: allow building with Cray mpi

* esmf: create run-path dependent libraries on osx

* esmf: link fortran interface libraries when building with mpich
This commit is contained in:
Milton Woods 2018-01-03 12:43:55 +11:00 committed by Adam J. Stewart
parent e1e24ff80e
commit 6922ea5889
2 changed files with 31 additions and 3 deletions

View File

@ -0,0 +1,18 @@
--- a/build/common.mk 2017-11-25 17:16:31.000000000 +1100
+++ b/build/common.mk 2017-11-25 17:26:20.000000000 +1100
@@ -3415,11 +3415,11 @@
mkdir tmp_$$NEXTLIB ;\
cd tmp_$$NEXTLIB ;\
$(ESMF_AREXTRACT) ../$$NEXTLIB.a ;\
- echo $(ESMF_SL_LIBLINKER) $(ESMF_SL_LIBOPTS) -o $(ESMF_LDIR)/$$NEXTLIB.$(ESMF_SL_SUFFIX) *.o $(ESMF_SL_LIBLIBS) ;\
- $(ESMF_SL_LIBLINKER) $(ESMF_SL_LIBOPTS) -o $(ESMF_LDIR)/$$NEXTLIB.$(ESMF_SL_SUFFIX) *.o $(ESMF_SL_LIBLIBS) ;\
+ echo $(ESMF_SL_LIBLINKER) $(ESMF_SL_LIBOPTS) -Wl,-install_name -Wl,@rpath/$$NEXTLIB.$(ESMF_SL_SUFFIX) -o $(ESMF_LDIR)/$$NEXTLIB.$(ESMF_SL_SUFFIX) *.o $(ESMF_SL_LIBLIBS) ;\
+ $(ESMF_SL_LIBLINKER) $(ESMF_SL_LIBOPTS) -Wl,-install_name -Wl,@rpath/$$NEXTLIB.$(ESMF_SL_SUFFIX) -o $(ESMF_LDIR)/$$NEXTLIB.$(ESMF_SL_SUFFIX) *.o $(ESMF_SL_LIBLIBS) ;\
echo Converting $$NEXTLIB.a to $$NEXTLIB\_fullylinked.$(ESMF_SL_SUFFIX) ;\
- echo $(ESMF_SL_LIBLINKER) $(ESMF_SL_LIBOPTS) -o $(ESMF_LDIR)/$$NEXTLIB\_fullylinked.$(ESMF_SL_SUFFIX) *.o $(ESMF_CXXLINKOPTS) $(ESMF_CXXLINKPATHS) $(ESMF_CXXLINKRPATHS) $(ESMF_CXXLINKLIBS) ;\
- $(ESMF_SL_LIBLINKER) $(ESMF_SL_LIBOPTS) -o $(ESMF_LDIR)/$$NEXTLIB\_fullylinked.$(ESMF_SL_SUFFIX) *.o $(ESMF_CXXLINKOPTS) $(ESMF_CXXLINKPATHS) $(ESMF_CXXLINKRPATHS) $(ESMF_CXXLINKLIBS) ;\
+ echo $(ESMF_SL_LIBLINKER) $(ESMF_SL_LIBOPTS) -Wl,-install_name -Wl,@rpath/$$NEXTLIB\_fullylinked.$(ESMF_SL_SUFFIX) -o $(ESMF_LDIR)/$$NEXTLIB\_fullylinked.$(ESMF_SL_SUFFIX) *.o $(ESMF_CXXLINKOPTS) $(ESMF_CXXLINKPATHS) $(ESMF_CXXLINKRPATHS) $(ESMF_CXXLINKLIBS) ;\
+ $(ESMF_SL_LIBLINKER) $(ESMF_SL_LIBOPTS) -Wl,-install_name -Wl,@rpath/$$NEXTLIB\_fullylinked.$(ESMF_SL_SUFFIX) -o $(ESMF_LDIR)/$$NEXTLIB\_fullylinked.$(ESMF_SL_SUFFIX) *.o $(ESMF_CXXLINKOPTS) $(ESMF_CXXLINKPATHS) $(ESMF_CXXLINKRPATHS) $(ESMF_CXXLINKLIBS) ;\
cd .. ;\
$(ESMF_RM) -r tmp_$$NEXTLIB ;\
fi ;\

View File

@ -69,6 +69,10 @@ class Esmf(MakefilePackage):
# https://sourceforge.net/p/esmf/esmf/ci/34de0ccf556ba75d35c9687dae5d9f666a1b2a18/
patch('mvapich2.patch', when='@:7.0.99')
# Allow different directories for creation and
# installation of dynamic libraries on OSX:
patch('darwin_dylib_install_name.patch', when='platform=darwin')
# Make script from mvapich2.patch executable
@run_before('build')
@when('@:7.0.99')
@ -104,7 +108,7 @@ def edit(self, spec, prefix):
# bin/binO/Linux.gfortran.64.default.default
os.environ['ESMF_INSTALL_BINDIR'] = 'bin'
os.environ['ESMF_INSTALL_LIBDIR'] = 'lib'
os.environ['ESMF_INSTALL_MODDIR'] = 'mod'
os.environ['ESMF_INSTALL_MODDIR'] = 'include'
############
# Compiler #
@ -149,11 +153,17 @@ def edit(self, spec, prefix):
# ESMF_COMM must be set to indicate which MPI implementation
# is used to build the ESMF library.
if '+mpi' in spec:
if '^mvapich2' in spec:
if 'platform=cray' in self.spec:
os.environ['ESMF_COMM'] = 'mpi'
elif '^mvapich2' in spec:
os.environ['ESMF_COMM'] = 'mvapich2'
elif '^mpich' in spec:
# FIXME: mpich or mpich2?
# esmf@7.0.1 does not include configs for mpich3,
# so we start with the configs for mpich2:
os.environ['ESMF_COMM'] = 'mpich2'
# The mpich 3 series split apart the Fortran and C bindings,
# so we link the Fortran libraries when building C programs:
os.environ['ESMF_CXXLINKLIBS'] = '-lmpifort'
elif '^openmpi' in spec:
os.environ['ESMF_COMM'] = 'openmpi'
elif '^intel-parallel-studio+mpi' in spec: