Subject: [bug#66516] [PATCH 2/2] gnu: dealii: Update to 9.5.1.

From: "Paul A. Patience" <[email-masked]>
Date: Fri, 13 Oct 2023 12:35:45 +0000

* gnu/packages/maths.scm (dealii): Update to 9.5.1.
[propagated-inputs]: Add kokkos.
[arguments]<#:phases>: Add 'unset-cpath' phase.
(dealii-openmpi)[propagated-inputs]: Remove kokkos.
[arguments]<#:phases>: Delete 'unset-cpath' phase.
---
 gnu/packages/maths.scm | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 2762e13a4f..e8d3cfed99 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -6613,17 +6613,17 @@ (define trilinos-for-dealii-openmpi
 (define-public dealii
   (package
     (name "dealii")
-    (version "9.4.0")
+    (version "9.5.1")
     (source
      (origin
        (method url-fetch)
        (uri (string-append "https://github.com/dealii/dealii/releases/"
                            "download/v" version "/dealii-" version ".tar.gz"))
        (sha256
-        (base32 "0v73q6f35f2yrjihaq6vh9lma07qc4cdv75nwmc3c5yrdh07g1i3"))
+        (base32 "0phgcfnil4rb41xipsdbm4lxrymlqxbiccakg3pkm3a8wqsva658"))
        (modules '((guix build utils)))
        (snippet
-        ;; Remove bundled boost, muparser, TBB and UMFPACK.
+        ;; Remove bundled boost, Kokkos, muparser, TBB and UMFPACK.
         #~(delete-file-recursively "bundled"))))
     (build-system cmake-build-system)
     (outputs '("out" "doc"))
@@ -6647,6 +6647,7 @@ (define-public dealii
      ;; the requisite interpreter to its native inputs.
      (list boost
            hdf5
+           kokkos
            suitesparse                  ; For UMFPACK.
            sundials
            tbb))
@@ -6671,6 +6672,18 @@ (define-public dealii
                                     "/examples")))
            #:phases
            #~(modify-phases %standard-phases
+               ;; Without unsetting CPATH, the build fails with the following
+               ;; error (similar to <https://bugs.gnu.org/30756>):
+               ;;
+               ;;   /gnu/store/…-gcc-11.3.0/include/c++/math.h:30:16: fatal error: math.h: No such file or directory
+               ;;      30 | # include_next <math.h>
+               ;;         |                ^~~~~~~~
+               ;;
+               ;; Why does unsetting CPATH magically fix the error?
+               ;; TODO: Properly fix this issue.
+               (add-after 'set-paths 'unset-cpath
+                 (lambda _
+                   (unsetenv "CPATH")))
                (add-after 'install 'remove-build-logs
                  ;; These build logs leak the name of the build directory by
                  ;; storing the values of CMAKE_SOURCE_DIR and
@@ -6702,7 +6715,7 @@ (define-public dealii-openmpi
                 scalapack)))
     (propagated-inputs
      (modify-inputs (package-propagated-inputs dealii)
-       (delete "hdf5" "sundials")
+       (delete "hdf5" "kokkos" "sundials")
        (prepend hdf5-parallel-openmpi
                 openmpi
                 p4est-openmpi
@@ -6713,7 +6726,12 @@ (define-public dealii-openmpi
     (arguments
      (substitute-keyword-arguments (package-arguments dealii)
        ((#:configure-flags flags)
-        #~(cons "-DDEAL_II_WITH_MPI=ON" #$flags))))
+        #~(cons "-DDEAL_II_WITH_MPI=ON" #$flags))
+       ((#:phases phases #~%standard-phases)
+        #~(modify-phases #$phases
+            ;; The build failure fixed by this phase does not manifest when
+            ;; Kokkos is included via Trilinos.
+            (delete 'unset-cpath)))))
     (synopsis "Finite element library (with MPI support)")))
 
 (define-public flann
-- 
2.41.0