[PATCH] gnu: mumps: Update to 5.2.1 and add shared libraries

  • Done
  • quality assurance status badge
Details
2 participants
  • Maurice Brémond
  • Ludovic Courtès
Owner
unassigned
Submitted by
Maurice Brémond
Severity
normal
M
M
Maurice Brémond wrote on 7 Oct 2019 16:00
(address . guix-patches@gnu.org)
87sgo4k657.fsf@inria.fr
---
gnu/packages/maths.scm | 53 ++++++++++------
gnu/packages/patches/shared-libseq.patch | 42 +++++++++++++
gnu/packages/patches/shared-mumps.patch | 63 +++++++++++++++++++
gnu/packages/patches/shared-pord.patch | 77 ++++++++++++++++++++++++
4 files changed, 218 insertions(+), 17 deletions(-)
create mode 100644 gnu/packages/patches/shared-libseq.patch
create mode 100644 gnu/packages/patches/shared-mumps.patch
create mode 100644 gnu/packages/patches/shared-pord.patch

Toggle diff (339 lines)
diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 03738c66ea..8e44233fb4 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -2160,7 +2160,7 @@ bindings to almost all functions of SLEPc.")
(define-public mumps
(package
(name "mumps")
- (version "5.1.2")
+ (version "5.2.1")
(source
(origin
(method url-fetch)
@@ -2168,8 +2168,11 @@ bindings to almost all functions of SLEPc.")
version ".tar.gz"))
(sha256
(base32
- "1s9asin08zqzmh08257sdghhivvy9vjif7c53fhaxaax2kd5qd7b"))
- (patches (search-patches "mumps-build-parallelism.patch"))))
+ "0jklh54x4y3ik1zkw6db7766kakjm5910diyaghfxxf8vwsgr26r"))
+ (patches (search-patches "mumps-build-parallelism.patch"
+ "shared-libseq.patch"
+ "shared-mumps.patch"
+ "shared-pord.patch"))))
(build-system gnu-build-system)
(inputs
`(("fortran" ,gfortran)
@@ -2177,16 +2180,21 @@ bindings to almost all functions of SLEPc.")
;; declare the dependency.
("blas" ,openblas)
("metis" ,metis)
+ ("patchelf" ,patchelf)
("scotch" ,scotch)))
(arguments
- `(#:modules ((ice-9 match)
+ `(#:modules ((guix build gnu-build-system)
+ (guix build utils)
+ (guix build rpath)
+ (ice-9 match)
(ice-9 popen)
- (srfi srfi-1)
- ,@%gnu-build-system-modules)
+ (srfi srfi-1))
+ #:imported-modules (,@%gnu-build-system-modules
+ (guix build rpath))
#:phases
(modify-phases %standard-phases
(replace 'configure
- (lambda* (#:key inputs #:allow-other-keys)
+ (lambda* (#:key inputs outputs #:allow-other-keys)
(call-with-output-file "Makefile.inc"
(lambda (port)
(format port "
@@ -2199,15 +2207,17 @@ CC = gcc
FC = gfortran
FL = gfortran
INCSEQ = -I$(topdir)/libseq
-LIBSEQ = -L$(topdir)/libseq -lmpiseq
+LIBSEQ = $(topdir)/libseq/libmpiseq.a
LIBSEQNEEDED = libseqneeded~;
CC = mpicc
FC = mpifort
FL = mpifort~]
AR = ar vr # rules require trailing space, ugh...
RANLIB = ranlib
-LIBBLAS = -L~a -lopenblas~@[
-SCALAP = -L~a -lscalapack~]
+BLASDIR = ~a
+LIBBLAS = -Wl,-rpath $(BLASDIR) -L$(BLASDIR) -lopenblas~@[
+SCALAPDIR = ~a
+SCALAP = -Wl,-rpath $(SCALAPDIR) -L$(SCALAPDIR) -lscalapack~]
LIBOTHERS = -pthread
CDEFS = -DAdd_
PIC = -fPIC
@@ -2218,18 +2228,18 @@ INCS = $(INCSEQ)
LIBS = $(SCALAP) $(LIBSEQ)
LPORDDIR = $(topdir)/PORD/lib
IPORD = -I$(topdir)/PORD/include
-LPORD = -L$(LPORDDIR) -lpord
+LPORD = $(LPORDDIR)/libpord.a
ORDERINGSF = -Dpord~@[
METISDIR = ~a
IMETIS = -I$(METISDIR)/include
-LMETIS = -L$(METISDIR)/lib -lmetis
+LMETIS = -Wl,-rpath $(METISDIR)/lib -L$(METISDIR)/lib -lmetis
ORDERINGSF += -Dmetis~]~@[~:{
SCOTCHDIR = ~a
ISCOTCH = -I$(SCOTCHDIR)/include
-LSCOTCH = -L$(SCOTCHDIR)/lib ~a-lesmumps -lscotch -lscotcherr
+LSCOTCH = -Wl,-rpath $(SCOTCHDIR)/lib -L$(SCOTCHDIR)/lib ~a-lesmumps -lscotch -lscotcherr
ORDERINGSF += ~a~}~]
ORDERINGSC = $(ORDERINGSF)
-LORDERINGS = $(LPORD) $(LMETIS) $(LSCOTCH)
+LORDERINGS = $(LPORD) $(LMETIS) $(LSCOTCH) $(LIBSEQ)
IORDERINGSF = $(ISCOTCH)
IORDERINGSC = $(IPORD) $(IMETIS) $(ISCOTCH)"
(assoc-ref inputs "mpi")
@@ -2277,18 +2287,28 @@ IORDERINGSC = $(IPORD) $(IMETIS) $(ISCOTCH)"
'("real" "real" "cmplx" "cmplx")))))
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
+ (use-modules (ice-9 popen)
+ (ice-9 rdelim))
(let* ((out (assoc-ref outputs "out"))
(libdir (string-append out "/lib")))
(copy-recursively "lib" libdir)
+ (every
+ (lambda (prec)
+ (augment-rpath (string-append libdir "/lib" prec "mumps-5.1.2.so") libdir))
+ '("s" "d" "c" "z"))
+ (augment-rpath (string-append libdir "/libmumps_common.so") libdir)
(copy-recursively "include" (string-append out "/include"))
(when (file-exists? "libseq/libmpiseq.a")
(install-file "libseq/libmpiseq.a" libdir))
+ (when (file-exists? "libseq/libmpiseq.so")
+ (install-file "libseq/libmpiseq.so" libdir)
+ (augment-rpath (string-append libdir "libmpiseq.so") libdir))
#t))))))
(home-page "http://mumps.enseeiht.fr")
(synopsis "Multifrontal sparse direct solver")
(description
"MUMPS (MUltifrontal Massively Parallel sparse direct Solver) solves a
-sparse system of linear equations A x = b using Gaussian elimination.")
+sparse system of linear equations A x = b using Guassian elimination.")
(license license:cecill-c)))
(define-public mumps-metis
@@ -2314,8 +2334,7 @@ sparse system of linear equations A x = b using Gaussian elimination.")
(replace 'check
(lambda _
((assoc-ref ,phases 'check)
- #:exec-prefix '("mpirun" "-n" "2"))))))))
- (synopsis "Multifrontal sparse direct solver (with MPI)")))
+ #:exec-prefix '("mpirun" "-n" "2" "-x" "LD_LIBRARY_PATH=../lib"))))))))))
(define-public mumps-metis-openmpi
(package (inherit mumps-openmpi)
diff --git a/gnu/packages/patches/shared-libseq.patch b/gnu/packages/patches/shared-libseq.patch
new file mode 100644
index 0000000000..feafcf123b
--- /dev/null
+++ b/gnu/packages/patches/shared-libseq.patch
@@ -0,0 +1,42 @@
+Create a shared version of the sequential library, MUST BE LAST IN SERIES
+
+Index: mumps/libseq/Makefile
+===================================================================
+--- mumps.orig/libseq/Makefile
++++ mumps/libseq/Makefile
+@@ -8,15 +8,17 @@ all: libmpiseq
+
+ include ../Makefile.inc
+
+-libmpiseq: libmpiseq$(PLAT)$(LIBEXT)
++libmpiseq: libmpiseq$(PLAT).a libmpiseq$(PLAT).so
+
+-libmpiseq$(PLAT)$(LIBEXT): mpi.o mpic.o elapse.o
+- $(AR)$@ mpi.o mpic.o elapse.o
++libmpiseq$(PLAT).a: mpi.o mpic.o elapse.o
++ $(AR) $@ mpi.o mpic.o elapse.o
+ $(RANLIB) $@
++libmpiseq$(PLAT).so: mpi.o mpic.o elapse.o
++ $(FC) -shared $^ -Wl,-soname,libmpiseq$(PLAT)-5.1.2.so -o libmpiseq$(PLAT)-5.1.2.so -Wl,-z,defs
+ .f.o:
+- $(FC) $(OPTF) -c $*.f $(OUTF)$*.o
++ $(FC) $(OPTF) -fPIC -c $*.f $(OUTF)$*.o
+ .c.o:
+- $(CC) $(OPTC) $(CDEFS) -I. -c $*.c $(OUTC)$*.o
++ $(CC) $(OPTC) $(CDEFS) -I. -fPIC -c $*.c $(OUTC)$*.o
+
+ clean:
+- $(RM) *.o *$(LIBEXT)
++ $(RM) *.o *.a *.so
+Index: mumps/Makefile
+===================================================================
+--- mumps.orig/Makefile
++++ mumps/Makefile
+@@ -60,6 +60,7 @@ requiredobj: Makefile.inc $(LIBSEQNEEDED
+
+ libseqneeded:
+ (cd libseq; $(MAKE))
++ cp libseq/lib* $(libdir)
+
+ # Build the libpord.a library and copy it into $(topdir)/lib
+ $(libdir)/libpord$(PLAT).a:
diff --git a/gnu/packages/patches/shared-mumps.patch b/gnu/packages/patches/shared-mumps.patch
new file mode 100644
index 0000000000..9e2491f300
--- /dev/null
+++ b/gnu/packages/patches/shared-mumps.patch
@@ -0,0 +1,63 @@
+Create a shared version of the MUMPS library.
+
+Index: mumps/src/Makefile
+===================================================================
+--- mumps.orig/src/Makefile
++++ mumps/src/Makefile
+@@ -23,8 +23,10 @@ z:
+
+ include $(topdir)/Makefile.inc
+
+-mumps_lib: $(libdir)/libmumps_common$(PLAT)$(LIBEXT) \
+- $(libdir)/lib$(ARITH)mumps$(PLAT)$(LIBEXT)
++mumps_lib: $(libdir)/libmumps_common$(PLAT).a \
++ $(libdir)/libmumps_common$(PLAT).so \
++ $(libdir)/lib$(ARITH)mumps$(PLAT).a \
++ $(libdir)/lib$(ARITH)mumps$(PLAT).so
+
+ OBJS_COMMON_MOD = \
+ lr_common.o \
+@@ -167,14 +169,22 @@ OBJS_OTHER = \
+ $(ARITH)tools.o\
+ $(ARITH)type3_root.o
+
+-$(libdir)/libmumps_common$(PLAT)$(LIBEXT): $(OBJS_COMMON_MOD) $(OBJS_COMMON_OTHER)
+- $(AR)$@ $?
++$(libdir)/libmumps_common$(PLAT).a: $(OBJS_COMMON_MOD) $(OBJS_COMMON_OTHER)
++ $(AR) $@ $?
+ $(RANLIB) $@
+
+-$(libdir)/lib$(ARITH)mumps$(PLAT)$(LIBEXT): $(OBJS_MOD) $(OBJS_OTHER)
+- $(AR)$@ $?
++$(libdir)/libmumps_common$(PLAT).so: $(OBJS_COMMON_MOD) $(OBJS_COMMON_OTHER)
++ $(FC) -shared $^ -Wl,-soname,libmumps_common$(PLAT)-5.1.2.so -L$(libdir) $(LORDERINGS) -lpthread $(MPIFLIB) $(MPICLIB) $(LEXTRAS) -o $(libdir)/libmumps_common$(PLAT)-5.1.2.so -Wl,-z,defs
++ ln -s libmumps_common$(PLAT)-5.1.2.so $@
++
++$(libdir)/lib$(ARITH)mumps$(PLAT).a: $(OBJS_MOD) $(OBJS_OTHER)
++ $(AR) $@ $?
+ $(RANLIB) $@
+
++$(libdir)/lib$(ARITH)mumps$(PLAT).so: $(OBJS_MOD) $(OBJS_OTHER)
++ $(FC) -shared $^ -Wl,-soname,lib$(ARITH)mumps$(PLAT)-5.1.2.so -L$(libdir) -lmumps_common$(PLAT) $(LORDERINGS) $(MPIFLIB) $(LEXTRAS) $(LIBBLAS) $(SCALAP) $(LAPACK) -o $(libdir)/lib$(ARITH)mumps$(PLAT)-5.1.2.so -Wl,-z,defs
++ ln -s lib$(ARITH)mumps$(PLAT)-5.1.2.so $@
++
+ # Dependencies between modules:
+ $(ARITH)mumps_load.o: $(ARITH)mumps_comm_buffer.o \
+ $(ARITH)mumps_struc_def.o \
+@@ -290,13 +300,13 @@ $(OBJS_OTHER):$(OBJS_COMMON_MOD) $(OBJS_
+
+ .SUFFIXES: .c .F .o
+ .F.o:
+- $(FC) $(OPTF) $(INCS) $(IORDERINGSF) $(ORDERINGSF) -I. -I../include -c $*.F $(OUTF)$*.o
++ $(FC) $(OPTF) $(INCS) $(IORDERINGSF) $(ORDERINGSF) -I. -I../include -fPIC -c $*.F $(OUTF)$*.o
+ .c.o:
+- $(CC) $(OPTC) $(INCS) -I../include $(CDEFS) $(IORDERINGSC) $(ORDERINGSC) -c $*.c $(OUTC)$*.o
++ $(CC) $(OPTC) $(INCS) -I../include $(CDEFS) $(IORDERINGSC) $(ORDERINGSC) -fPIC -c $*.c $(OUTC)$*.o
+
+ $(ARITH)mumps_c.o: mumps_c.c
+ $(CC) $(OPTC) $(INCS) $(CDEFS) -DMUMPS_ARITH=MUMPS_ARITH_$(ARITH) \
+- $(IORDERINGSC) $(ORDERINGSC) -I../include -c mumps_c.c $(OUTC)$@
++ $(IORDERINGSC) $(ORDERINGSC) -I../include -fPIC -c mumps_c.c $(OUTC)$@
+
+
+ clean:
diff --git a/gnu/packages/patches/shared-pord.patch b/gnu/packages/patches/shared-pord.patch
new file mode 100644
index 0000000000..48062d4f89
--- /dev/null
+++ b/gnu/packages/patches/shared-pord.patch
@@ -0,0 +1,77 @@
+Create static and shared versions of the PORD library.
+
+Index: mumps/PORD/lib/Makefile
+===================================================================
+--- mumps.orig/PORD/lib/Makefile
++++ mumps/PORD/lib/Makefile
+@@ -9,7 +9,7 @@
+
+ INCLUDES = -I../include
+
+-COPTIONS = $(INCLUDES) $(CFLAGS) $(OPTFLAGS)
++COPTIONS = $(INCLUDES) $(CFLAGS) $(OPTFLAGS) -fPIC
+
+ OBJS = graph.o gbipart.o gbisect.o ddcreate.o ddbisect.o nestdiss.o \
+ multisector.o gelim.o bucket.o tree.o \
+@@ -24,12 +24,16 @@ OBJS = graph.o gbipart.o gbisect.o ddcre
+ .c.o:
+ $(CC) $(COPTIONS) -c $*.c $(OUTC)$*.o
+
+-libpord$(LIBEXT):$(OBJS)
+- $(AR)$@ $(OBJS)
++libpord$(PLAT).a:$(OBJS)
++ $(AR) $@ $(OBJS)
+ $(RANLIB) $@
+
++libpord$(PLAT).so: $(OBJS)
++ $(CC) -shared $(OBJS) -Wl,-soname,libpord$(PLAT)-5.1.2.so -o libpord$(PLAT)-5.1.2.so -Wl,-z,defs
++ ln -s libpord$(PLAT)-5.1.2.so $@
++
+ clean:
+ rm -f *.o
+
+ realclean:
+- rm -f *.o libpord.a
++ rm -f *.o libpord*.a *.so
+Index: mumps/Makefile
+===================================================================
+--- mumps.orig/Makefile
++++ mumps/Makefile
+@@ -54,7 +54,7 @@ dexamples: d
+ multi_example: s d c z
+ (cd examples ; $(MAKE) multi)
+
+-requiredobj: Makefile.inc $(LIBSEQNEEDED) $(libdir)/libpord$(PLAT)$(LIBEXT)
++requiredobj: Makefile.inc $(LIBSEQNEEDED) $(libdir)/libpord$(PLAT).a $(libdir)/libpord$(PLAT).so
+
+ # dummy MPI library (sequential version)
+
+@@ -62,19 +62,25 @@ libseqneeded:
+ (cd libseq; $(MAKE))
+
+ # Build the libpord.a library and copy it into $(topdir)/lib
+-$(libdir)/libpord$(PLAT)$(LIBEXT):
++$(libdir)/libpord$(PLAT).a:
+ if [ "$(LPORDDIR)" != "" ] ; then \
+ cd $(LPORDDIR); \
+ $(MAKE) CC="$(CC)" CFLAGS="$(OPTC)" AR="$(AR)" RANLIB="$(RANLIB)" OUTC="$(OUTC)" LIBEXT=$(LIBEXT); \
+ fi;
+ if [ "$(LPORDDIR)" != "" ] ; then \
+- cp $(LPORDDIR)/libpord$(LIBEXT) $@; \
++ cp $(LPORDDIR)/libpord$(PLAT).a $@; \
+ fi;
+
++$(libdir)/libpord$(PLAT).so:
++ if [ "$(LPORDDIR)" != "" ] ; then \
++ cd $(LPORDDIR); make CC="$(CC)" CFLAGS="$(OPTC)" AR="$(AR)" ARFUNCT= RANLIB="$(RANLIB)" libpord$(PLAT).so; fi;
++ if [ "$(LPORDDIR)" != "" ] ; then \
++ cp -a $(LPORDDIR)/libpord*.so lib/; fi;
++
+ clean:
+ (cd src; $(MAKE) clean)
+ (cd examples; $(MAKE) clean)
+- (cd $(libdir); $(RM) *$(PLAT)$(LIBEXT))
++ (cd $(libdir); $(RM) *$(PLAT).a *$(PLAT).so)
+ (cd libseq; $(MAKE) clean)
+ if [ "$(LPORDDIR)" != "" ] ; then \
+ cd $(LPORDDIR); $(MAKE) realclean; \
--
2.17.1
L
L
Ludovic Courtès wrote on 14 Oct 2019 18:28
(name . Maurice Brémond)(address . Maurice.Bremond@inria.fr)(address . 37646-done@debbugs.gnu.org)
87r23fpa06.fsf@gnu.org
Hi Maurice,

Maurice Brémond <Maurice.Bremond@inria.fr> skribis:

Toggle quote (10 lines)
> ---
> gnu/packages/maths.scm | 53 ++++++++++------
> gnu/packages/patches/shared-libseq.patch | 42 +++++++++++++
> gnu/packages/patches/shared-mumps.patch | 63 +++++++++++++++++++
> gnu/packages/patches/shared-pord.patch | 77 ++++++++++++++++++++++++
> 4 files changed, 218 insertions(+), 17 deletions(-)
> create mode 100644 gnu/packages/patches/shared-libseq.patch
> create mode 100644 gnu/packages/patches/shared-mumps.patch
> create mode 100644 gnu/packages/patches/shared-pord.patch

Thanks for the patch! :-)

I took the liberty to split it: one patch for the update, and one patch
for shared library support.

I simplified shared library support by resorting to ‘$ORIGIN’ for the
RUNPATH instead of using PatchELF. And that’s about it.

The result is these two commits:

06e1239502 gnu: mumps: Build and install shared libraries.
5dbc79eb60 gnu: mumps: Update to 5.2.1.

Let me know if anything is amiss!

Thank you,
Ludo’.
Closed
?