Change MUMPS to allow it to build with clang+xlf compiler combination (#8388)

The mumps package was unable to build using the llvm clang compiler
suite, as it defaulted to using mpif90 for linking and mpif90 cannot
be used for linking shared library code. This PR modifies the MUMPS
package.py to allow it to use IBM XL Fortran for linking. It also
eliminates the need for the existing MUMPS IBM XL patches by having
package.py specify the compiler-dependent "shared" flag to the
linker, and always using the compiler suite's Fortran compiler
for linking.
This commit is contained in:
Dan FitzGerald 2018-08-02 14:23:37 -04:00 committed by scheibelp
parent 51aa604ed2
commit e554add64b
4 changed files with 92 additions and 200 deletions

View File

@ -0,0 +1,41 @@
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -27,32 +27,32 @@
LIBSMUMPS = $(libdir)/libsmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
ssimpletest: $(LIBSMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) ssimpletest.o $(LIBSMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+ $(FL) -o $@ ssimpletest.o $(LIBSMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
LIBDMUMPS = $(libdir)/libdmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
dsimpletest: $(LIBDMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) dsimpletest.o $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+ $(FL) -o $@ dsimpletest.o $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
LIBCMUMPS = $(libdir)/libcmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
csimpletest: $(LIBCMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) csimpletest.o $(LIBCMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+ $(FL) -o $@ csimpletest.o $(LIBCMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
LIBZMUMPS = $(libdir)/libzmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
zsimpletest: $(LIBZMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) zsimpletest.o $(LIBZMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+ $(FL) -o $@ zsimpletest.o $(LIBZMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
c_example: $(LIBDMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) $@.o $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+ $(FL) -o $@ $@.o $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
multiple_arithmetics_example: $(LIBSMUMPS) $(LIBDMUMPS) $(LIBCMUMPS) $(LIBZMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) $@.o $(LIBSMUMPS) $(LIBDMUMPS) $(LIBCMUMPS) $(LIBZMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+ $(FL) -o $@ $@.o $(LIBSMUMPS) $(LIBDMUMPS) $(LIBCMUMPS) $(LIBZMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
.SUFFIXES: .c .F .o

View File

@ -1,75 +0,0 @@
diff -Naur MUMPS_5.0.1/Makefile MUMPS_5.0.1-patched/MUMPS_5.0.1/Makefile
--- ./Makefile 2015-07-23 13:08:29.000000000 -0400
+++ ./Makefile 2016-12-05 14:08:30.788638382 -0500
@@ -62,7 +62,7 @@
$(libdir)/libpord$(PLAT)$(LIBEXT):
if [ "$(LPORDDIR)" != "" ] ; then \
cd $(LPORDDIR); \
- $(MAKE) CC="$(CC)" CFLAGS="$(OPTC)" AR="$(AR)" RANLIB="$(RANLIB)" OUTC="$(OUTC)" LIBEXT=$(LIBEXT); \
+ $(MAKE) CC="$(CC)" CFLAGS="$(OPTC)" SAR="$(SAR)" RANLIB="$(RANLIB)" OUTC="$(OUTC)" LIBEXT=$(LIBEXT); \
fi;
if [ "$(LPORDDIR)" != "" ] ; then \
cp $(LPORDDIR)/libpord$(LIBEXT) $@; \
diff -Naur MUMPS_5.0.1/PORD/lib/Makefile MUMPS_5.0.1-patched/PORD/lib/MUMPS_5.0.1/Makefile
--- ./PORD/lib/Makefile 2015-07-23 13:08:29.000000000 -0400
+++ ./PORD/lib/Makefile 2016-12-05 11:26:24.785317467 -0500
@@ -25,7 +25,7 @@
$(CC) $(COPTIONS) -c $*.c $(OUTC)$*.o
libpord$(LIBEXT):$(OBJS)
- $(AR)$@ $(OBJS)
+ $(SAR)$@ $(OBJS)
$(RANLIB) $@
clean:
diff -Naur MUMPS_5.0.1/examples/Makefile MUMPS_5.0.1-patched/examples/Makefile
--- ./examples/Makefile 2015-07-23 13:08:32.000000000 -0400
+++ ./examples/Makefile 2016-12-05 14:36:10.692857906 -0500
@@ -25,37 +25,30 @@
LIBSMUMPS = $(libdir)/libsmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
-ssimpletest: $(LIBSMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) ssimpletest.o $(LIBSMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+ssimpletest: $(LIBSMUMPS) $$@.F
+ $(FC) -o $@ $(OPTF) $(INCS) -I. -I$(topdir)/include ssimpletest.F $(LIBSMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
LIBDMUMPS = $(libdir)/libdmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
-dsimpletest: $(LIBDMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) dsimpletest.o $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+dsimpletest: $(LIBDMUMPS) $$@.F
+ $(FC) -o $@ $(OPTF) $(INCS) -I. -I$(topdir)/include dsimpletest.F $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
LIBCMUMPS = $(libdir)/libcmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
-csimpletest: $(LIBCMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) csimpletest.o $(LIBCMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+csimpletest: $(LIBCMUMPS) $$@.F
+ $(FC) -o $@ $(OPTF) $(INCS) -I. -I$(topdir)/include csimpletest.F $(LIBCMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
LIBZMUMPS = $(libdir)/libzmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
-zsimpletest: $(LIBZMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) zsimpletest.o $(LIBZMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+zsimpletest: $(LIBZMUMPS) $$@.F
+ $(FC) -o $@ $(OPTF) $(INCS) -I. -I$(topdir)/include zsimpletest.F $(LIBZMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
-c_example: $(LIBDMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) $@.o $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
-
-
-.SUFFIXES: .c .F .o
-.F.o:
- $(FC) $(OPTF) $(INCS) -I. -I$(topdir)/include -c $*.F $(OUTF)$*.o
-.c.o:
- $(CC) $(OPTC) $(INCS) $(CDEFS) -I. -I$(topdir)/include -I$(topdir)/src -c $*.c $(OUTC)$*.o
+c_example: $(LIBDMUMPS) $$@.c
+ $(CC) -o $@ $(OPTC) $(INCS) -I. -I$(topdir)/include c_example.c $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
$(libdir)/libsmumps$(PLAT)$(LIBEXT):

View File

@ -1,79 +0,0 @@
diff -Naur MUMPS_5.0.1/Makefile MUMPS_5.0.1-patched/MUMPS_5.0.1/Makefile
--- ./Makefile 2015-07-23 13:08:29.000000000 -0400
+++ ./Makefile 2016-12-05 14:08:30.788638382 -0500
@@ -62,7 +62,7 @@
$(libdir)/libpord$(PLAT)$(LIBEXT):
if [ "$(LPORDDIR)" != "" ] ; then \
cd $(LPORDDIR); \
- $(MAKE) CC="$(CC)" CFLAGS="$(OPTC)" AR="$(AR)" RANLIB="$(RANLIB)" OUTC="$(OUTC)" LIBEXT=$(LIBEXT); \
+ $(MAKE) CC="$(CC)" CFLAGS="$(OPTC)" SAR="$(SAR)" RANLIB="$(RANLIB)" OUTC="$(OUTC)" LIBEXT=$(LIBEXT); \
fi;
if [ "$(LPORDDIR)" != "" ] ; then \
cp $(LPORDDIR)/libpord$(LIBEXT) $@; \
diff -Naur MUMPS_5.0.1/PORD/lib/Makefile MUMPS_5.0.1-patched/PORD/lib/MUMPS_5.0.1/Makefile
--- ./PORD/lib/Makefile 2015-07-23 13:08:29.000000000 -0400
+++ ./PORD/lib/Makefile 2016-12-05 11:26:24.785317467 -0500
@@ -25,7 +25,7 @@
$(CC) $(COPTIONS) -c $*.c $(OUTC)$*.o
libpord$(LIBEXT):$(OBJS)
- $(AR)$@ $(OBJS)
+ $(SAR)$@ $(OBJS)
$(RANLIB) $@
clean:
--- ./examples/Makefile 2017-06-07 15:40:49.366671322 -0400
+++ ./examples/Makefile 2017-06-07 15:47:55.666685772 -0400
@@ -26,40 +26,33 @@
LIBSMUMPS = $(libdir)/libsmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
-ssimpletest: $(LIBSMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) ssimpletest.o $(LIBSMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+ssimpletest: $(LIBSMUMPS) $$@.F
+ $(FC) -o $@ $(OPTF) $(INCS) -I. -I$(topdir)/include ssimpletest.F $(LIBSMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
LIBDMUMPS = $(libdir)/libdmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
-dsimpletest: $(LIBDMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) dsimpletest.o $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+dsimpletest: $(LIBDMUMPS) $$@.F
+ $(FC) -o $@ $(OPTF) $(INCS) -I. -I$(topdir)/include dsimpletest.F $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
LIBCMUMPS = $(libdir)/libcmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
-csimpletest: $(LIBCMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) csimpletest.o $(LIBCMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+csimpletest: $(LIBCMUMPS) $$@.F
+ $(FC) -o $@ $(OPTF) $(INCS) -I. -I$(topdir)/include csimpletest.F $(LIBCMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
LIBZMUMPS = $(libdir)/libzmumps$(PLAT)$(LIBEXT) $(LIBMUMPS_COMMON)
-zsimpletest: $(LIBZMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) zsimpletest.o $(LIBZMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+zsimpletest: $(LIBZMUMPS) $$@.F
+ $(FC) -o $@ $(OPTF) $(INCS) -I. -I$(topdir)/include zsimpletest.F $(LIBZMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
-c_example: $(LIBDMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) $@.o $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
+c_example: $(LIBDMUMPS) $$@.c
+ $(CC) -o $@ $(OPTC) $(INCS) -I. -I$(topdir)/include c_example.c $(LIBDMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
-multiple_arithmetics_example: $(LIBSMUMPS) $(LIBDMUMPS) $(LIBCMUMPS) $(LIBZMUMPS) $$@.o
- $(FL) -o $@ $(OPTL) $@.o $(LIBSMUMPS) $(LIBDMUMPS) $(LIBCMUMPS) $(LIBZMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
-
-
-.SUFFIXES: .c .F .o
-.F.o:
- $(FC) $(OPTF) $(INCS) -I. -I$(topdir)/include -c $*.F $(OUTF)$*.o
-.c.o:
- $(CC) $(OPTC) $(INCS) $(CDEFS) -I. -I$(topdir)/include -I$(topdir)/src -c $*.c $(OUTC)$*.o
+multiple_arithmetics_example: $(LIBSMUMPS) $(LIBDMUMPS) $(LIBCMUMPS) $(LIBZMUMPS) $$@.F
+ $(FC) -o $@ $(OPTF) $(INCS) -I. -I$(topdir)/include multiple_arithmetics_example.F $(LIBSMUMPS) $(LIBDMUMPS) $(LIBCMUMPS) $(LIBZMUMPS) $(LORDERINGS) $(LIBS) $(LIBBLAS) $(LIBOTHERS)
$(libdir)/libsmumps$(PLAT)$(LIBEXT):

View File

@ -69,10 +69,7 @@ class Mumps(Package):
depends_on('scalapack', when='+mpi')
depends_on('mpi', when='+mpi')
patch('mumps-5.0.2-spectrum-mpi-xl.patch', when='@5.0.2%xl^spectrum-mpi')
patch('mumps-5.0.2-spectrum-mpi-xl.patch', when='@5.0.2%xl_r^spectrum-mpi')
patch('mumps-5.1.1-spectrum-mpi-xl.patch', when='@5.1.1%xl^spectrum-mpi')
patch('mumps-5.1.1-spectrum-mpi-xl.patch', when='@5.1.1%xl_r^spectrum-mpi')
patch('examples.patch', when='@5.1.1%clang^spectrum-mpi')
# this function is not a patch function because in case scalapack
# is needed it uses self.spec['scalapack'].fc_link set by the
@ -133,6 +130,18 @@ def write_makefile_inc(self):
makefile_conf.append("ORDERINGSF = %s" % (' '.join(orderings)))
# Determine which compiler suite we are using
using_gcc = self.compiler.name == "gcc"
using_pgi = self.compiler.name == "pgi"
using_intel = self.compiler.name == "intel"
using_xl = self.compiler.name in ['xl', 'xl_r']
# The llvm compiler suite does not contain a Fortran compiler by
# default. Its possible that a Spack user may have configured
# ~/.spack/<platform>/compilers.yaml for using xlf.
using_xlf = using_xl or \
(spack_f77.endswith('xlf') or spack_f77.endswith('xlf_r'))
# when building shared libs need -fPIC, otherwise
# /usr/bin/ld: graph.o: relocation R_X86_64_32 against `.rodata.str1.1'
# can not be used when making a shared object; recompile with -fPIC
@ -140,32 +149,37 @@ def write_makefile_inc(self):
# TODO: test this part, it needs a full blas, scalapack and
# partitionning environment with 64bit integers
using_xl = self.compiler.name in ['xl', 'xl_r']
opt_level = '3' if using_xl else ''
if '+int64' in self.spec:
if self.compiler.name == "xl" or self.compiler.name == "xl_r":
makefile_conf.extend(
['OPTF = -O3',
'OPTL = %s -O3' % fpic,
'OPTC = %s -O3-DINTSIZE64' % fpic])
if using_xlf:
makefile_conf.append('OPTF = -O%s' % opt_level)
else:
makefile_conf.extend(
# the fortran compilation flags most probably are
# working only for intel and gnu compilers this is
# perhaps something the compiler should provide
['OPTF = %s -O -DALLOW_NON_INIT %s' % (fpic, '-fdefault-integer-8' if self.compiler.name == "gcc" else '-i8'), # noqa
'OPTL = %s -O ' % fpic,
'OPTC = %s -O -DINTSIZE64' % fpic])
# the fortran compilation flags most probably are
# working only for intel and gnu compilers this is
# perhaps something the compiler should provide
makefile_conf.extend([
'OPTF = %s -O -DALLOW_NON_INIT %s' % (
fpic,
'-fdefault-integer-8' if using_gcc
else '-i8'), # noqa
])
makefile_conf.extend([
'OPTL = %s -O%s' % (fpic, opt_level),
'OPTC = %s -O%s -DINTSIZE64' % (fpic, opt_level)
])
else:
if using_xl:
makefile_conf.extend(
['OPTF = -O3 -qfixed',
'OPTL = %s -O3' % fpic,
'OPTC = %s -O3' % fpic])
if using_xlf:
makefile_conf.append('OPTF = -O%s -qfixed' % opt_level)
else:
makefile_conf.extend(
['OPTF = %s -O -DALLOW_NON_INIT' % fpic,
'OPTL = %s -O ' % fpic,
'OPTC = %s -O ' % fpic])
makefile_conf.append('OPTF = %s -O%s -DALLOW_NON_INIT' % (
fpic, opt_level))
makefile_conf.extend([
'OPTL = %s -O%s' % (fpic, opt_level),
'OPTC = %s -O%s' % (fpic, opt_level)
])
if '+mpi' in self.spec:
scalapack = self.spec['scalapack'].libs if not shared \
@ -173,16 +187,9 @@ def write_makefile_inc(self):
makefile_conf.extend(
['CC = {0}'.format(self.spec['mpi'].mpicc),
'FC = {0}'.format(self.spec['mpi'].mpifc),
'FL = {0}'.format(self.spec['mpi'].mpifc),
"SCALAP = %s" % scalapack.ld_flags,
"MUMPS_TYPE = par"])
# The FL makefile variable is used for linking the examples and
# linking the shared mumps libraries (in some cases).
if using_xl and self.spec.satisfies('^spectrum-mpi'):
makefile_conf.extend(
['FL = {0}'.format(self.spec['mpi'].mpicc)])
else:
makefile_conf.extend(
['FL = {0}'.format(self.spec['mpi'].mpifc)])
else:
makefile_conf.extend(
["CC = cc",
@ -192,14 +199,14 @@ def write_makefile_inc(self):
# TODO: change the value to the correct one according to the
# compiler possible values are -DAdd_, -DAdd__ and/or -DUPPER
if self.compiler.name == 'intel' or self.compiler.name == 'pgi':
if using_intel or using_pgi:
# Intel & PGI Fortran compiler provides the main() function so
# C examples linked with the Fortran compiler require a
# hack defined by _DMAIN_COMP (see examples/c_example.c)
makefile_conf.append("CDEFS = -DAdd_ -DMAIN_COMP")
else:
if not using_xl:
makefile_conf.append("CDEFS = -DAdd_")
if not using_xlf:
makefile_conf.append("CDEFS = -DAdd_")
if '+shared' in self.spec:
# All Mumps libraries will be linked with 'inject_libs'.
@ -230,11 +237,16 @@ def write_makefile_inc(self):
'RANLIB=echo'
])
else:
if using_xlf:
build_shared_flag = "qmkshrobj"
else:
build_shared_flag = "shared"
makefile_conf.extend([
'LIBEXT=.so',
'AR=link_cmd() { $(FL) -shared -Wl,-soname '
'AR=link_cmd() { $(FL) -%s -Wl,-soname '
'-Wl,%s/$(notdir $@) -o "$$@" %s; }; link_cmd ' %
(prefix.lib, inject_libs),
(build_shared_flag, prefix.lib, inject_libs),
'RANLIB=ls'
])
# When building libpord, read AR from Makefile.inc instead of
@ -245,13 +257,6 @@ def write_makefile_inc(self):
'\\1\ninclude ../../Makefile.inc',
join_path('PORD', 'lib', 'Makefile'))
if using_xl:
# The patches for xl + spectrum-mpi use SAR for linking
# libpord.
makefile_conf.extend([
'SAR=%s -shared -Wl,-soname -Wl,%s/$(notdir $@) %s -o'
% (env['CC'], prefix.lib, inject_libs)
])
else:
makefile_conf.extend([
'LIBEXT = .a',