[bug#34780] gnu: openmpi: Add Java support.

Message ID 20190307111422.12381-1-rekado@elephly.net
State Accepted
Headers show
Series [bug#34780] gnu: openmpi: Add Java support. | expand

Checks

Context Check Description
cbaines/comparison success View comparison
cbaines/applying patch success Successfully applied

Commit Message

Ricardo Wurmus March 7, 2019, 11:14 a.m. UTC
* gnu/packages/mpi.scm (openmpi)[native-inputs]: Add openjdk11.
[outputs]: Add "java".
[arguments]: Add "--enable-mpi-java" to configure flags; add build phases
"set-JAVA_HOME" and "move-java".
---
 gnu/packages/mpi.scm | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

Comments

Ludovic Courtès March 18, 2019, 9:27 a.m. UTC | #1
Hi Ricardo,

Ricardo Wurmus <rekado@elephly.net> skribis:

> * gnu/packages/mpi.scm (openmpi)[native-inputs]: Add openjdk11.
> [outputs]: Add "java".
> [arguments]: Add "--enable-mpi-java" to configure flags; add build phases
> "set-JAVA_HOME" and "move-java".

Nice.

I’m uncomfortable adding OpenJDK as an input to Open MPI though, because
that puts more stress on the build times and potentially on platform
support as well.

Would it be an option to create a separate “openmpi-java” or would that
create problems down the road?

Thank you,
Ludo’.
Ricardo Wurmus March 18, 2019, 2:06 p.m. UTC | #2
Ludovic Courtès <ludovic.courtes@inria.fr> writes:

> Hi Ricardo,
>
> Ricardo Wurmus <rekado@elephly.net> skribis:
>
>> * gnu/packages/mpi.scm (openmpi)[native-inputs]: Add openjdk11.
>> [outputs]: Add "java".
>> [arguments]: Add "--enable-mpi-java" to configure flags; add build phases
>> "set-JAVA_HOME" and "move-java".
>
> Nice.
>
> I’m uncomfortable adding OpenJDK as an input to OpenMPI though, because
> that puts more stress on the build times and potentially on platform
> support as well.

I understad.

> Would it be an option to create a separate “openmpi-java” or would that
> create problems down the road?

I’ll give that a try.  I’m not sure if it’s possible to build the Java
parts in isolation, but that would be nice.
Ricardo Wurmus March 18, 2019, 5:26 p.m. UTC | #3
Ricardo Wurmus <rekado@elephly.net> writes:

>> Would it be an option to create a separate “openmpi-java” or would that
>> create problems down the road?
>
> I’ll give that a try.  I’m not sure if it’s possible to build the Java
> parts in isolation, but that would be nice.

This is done in commit fa5a25386620cec4b2543aae24fc9a0776aa3dca (it’s
called “java-openmpi”).

Thanks for the suggestion!

--
Ricardo
Ludovic Courtès March 19, 2019, 9:43 a.m. UTC | #4
Ricardo Wurmus <rekado@elephly.net> skribis:

> Ricardo Wurmus <rekado@elephly.net> writes:
>
>>> Would it be an option to create a separate “openmpi-java” or would that
>>> create problems down the road?
>>
>> I’ll give that a try.  I’m not sure if it’s possible to build the Java
>> parts in isolation, but that would be nice.
>
> This is done in commit fa5a25386620cec4b2543aae24fc9a0776aa3dca (it’s
> called “java-openmpi”).

Great, thank you!

Ludo’.

Patch

diff --git a/gnu/packages/mpi.scm b/gnu/packages/mpi.scm
index 10de6dee5b..316b2a5cd8 100644
--- a/gnu/packages/mpi.scm
+++ b/gnu/packages/mpi.scm
@@ -35,6 +35,7 @@ 
   #:use-module (gnu packages)
   #:use-module (gnu packages fabric-management)
   #:use-module (gnu packages gcc)
+  #:use-module (gnu packages java)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages pciutils)
@@ -190,8 +191,9 @@  bind processes, and much more.")
        ("slurm" ,slurm)))              ;for PMI support (launching via "srun")
     (native-inputs
      `(("pkg-config" ,pkg-config)
-       ("perl" ,perl)))
-    (outputs '("out" "debug"))
+       ("perl" ,perl)
+       ("jdk" ,openjdk11 "jdk")))
+    (outputs '("out" "debug" "java"))
     (arguments
      `(#:configure-flags `("--enable-mpi-ext=affinity" ;cr doesn't work
                            "--enable-memchecker"
@@ -200,6 +202,8 @@  bind processes, and much more.")
                            "--with-hwloc=external"
                            "--with-libevent"
 
+                           "--enable-mpi-java"
+
                            ;; InfiniBand support
                            "--enable-openib-control-hdr-padding"
                            "--enable-openib-dynamic-sl"
@@ -224,6 +228,14 @@  bind processes, and much more.")
                                              "/include/infiniband/:"
                                              (getenv "CPLUS_INCLUDE_PATH")))
                       #t))
+                  ;; We could provide the location of the JDK in the configure
+                  ;; flags, but since the configure flags are embedded in the
+                  ;; info binaries that would leave a reference to the JDK in
+                  ;; the "out" output.  To avoid this we set JAVA_HOME.
+                  (add-after 'unpack 'set-JAVA_HOME
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (setenv "JAVA_HOME" (assoc-ref inputs "jdk"))
+                      #t))
                   (add-before 'build 'remove-absolute
                     (lambda _
                       ;; Remove compiler absolute file names (OPAL_FC_ABSOLUTE
@@ -252,6 +264,26 @@  bind processes, and much more.")
                     (lambda* (#:key outputs #:allow-other-keys)
                       (let ((out (assoc-ref outputs "out")))
                         (for-each delete-file (find-files out "config.log"))
+                        #t)))
+                  (add-after 'install 'move-java
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let ((out  (assoc-ref outputs "out"))
+                            (java (assoc-ref outputs "java")))
+                        (for-each (lambda (item)
+                                    (let ((source (string-append out item))
+                                          (target (string-append java item)))
+                                      (mkdir-p (dirname target))
+                                      (rename-file source target)))
+                                  '("/share/man/man1/mpijavac.1"
+                                    "/share/doc/openmpi/javadoc-openmpi"
+                                    "/lib/mpi.jar"
+                                    "/lib/libmpi_java.la"
+                                    "/lib/libmpi_java.so.40.20.0"
+                                    "/lib/libmpi_java.so.40"
+                                    "/lib/libmpi_java.so"
+                                    "/bin/mpijavac.pl"
+                                    "/bin/mpijavac"
+                                    "/include/openmpi/ompi/mpi/java"))
                         #t))))))
     (home-page "http://www.open-mpi.org")
     (synopsis "MPI-3 implementation")