Subject: OpenFOAM 4.1 fails to build

From: Ludovic Courtès <[email-masked]>
Date: Thu, 07 Oct 2021 10:57:51 +0200

Hello,

On 1327ec822fa6dd396e979efd8d4e1f7479f1d5b3 (current master),
OpenFOAM 4.1 fails to build (from
<https://ci.guix.gnu.org/build/396746/details>):

--8<---------------cut here---------------start------------->8---
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/finiteVolume/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/dynamicMesh/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/meshTools/lnInclude -IlnInclude -I. -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/OpenFOAM/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/OSspecific/POSIX/lnInclude   -fPIC -c moveMesh.C -o /tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/platforms/linux64GccDPInt32Opt/applications/utilities/mesh/manipulation/moveMesh/moveMesh.o
In file included from /gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/IO/Color.h:21:0,
                 from /gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/IO/io.h:30,
                 from /gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/Needs_parens_as_product.h:20,
                 from /gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/number_type_basic.h:45,
                 from /gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/basic.h:33,
                 from /gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/Delaunay_triangulation_3.h:22,
                 from lnInclude/CGALTriangulation3DKernel.H:36,
                 from lnInclude/CGALTriangulation3Ddefs.H:41,
                 from DelaunayMeshTools/DelaunayMeshTools.H:45,
                 from DelaunayMeshTools/DelaunayMeshTools.C:26:
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/array.h:72:44: error: ?std::index_sequence? has not been declared
 make_filled_array_aux(const T& value, std::index_sequence<Is...>)
                                            ^~~~~~~~~~~~~~
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/array.h:72:58: error: expected ?,? or ?...? before ?<? token
 make_filled_array_aux(const T& value, std::index_sequence<Is...>)
                                                          ^
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/array.h: In function ?constexpr std::array<T, N> CGAL::make_filled_array(const T&)?:
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/array.h:80:44: error: ?make_index_sequence? is not a member of ?std?
   return make_filled_array_aux(value, std::make_index_sequence<N>());
                                            ^~~~~~~~~~~~~~~~~~~
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/array.h:80:67: error: expected primary-expression before ?)? token
   return make_filled_array_aux(value, std::make_index_sequence<N>());
                                                                   ^
In file included from /gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/double.h:22:0,
                 from /gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/number_type_basic.h:51,
                 from /gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/basic.h:33,
                 from /gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/Delaunay_triangulation_3.h:22,
                 from lnInclude/CGALTriangulation3DKernel.H:36,
                 from lnInclude/CGALTriangulation3Ddefs.H:41,
                 from DelaunayMeshTools/DelaunayMeshTools.H:45,
                 from DelaunayMeshTools/DelaunayMeshTools.C:26:
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/number_utils.h: At global scope:
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/number_utils.h:319:10: error: expected primary-expression before ?auto?
 decltype(auto) approximate_sqrt(const NT& nt)
          ^~~~
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/number_utils.h:319:10: error: expected ?)? before ?auto?
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/number_utils.h:319:10: error: expected primary-expression before ?auto?
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/number_utils.h:319:10: error: expected primary-expression before ?auto?
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/number_utils.h:319:10: error: expected primary-expression before ?auto?
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/number_utils.h:319:10: error: expected primary-expression before ?auto?
/gnu/store/86p0n4k4ahkc0kg7n4qz1mfg02czhyhd-cgal-5.2.2/include/CGAL/number_utils.h:319:1: error: expected unqualified-id before ?decltype?
 decltype(auto) approximate_sqrt(const NT& nt)
 ^~~~~~~~
--8<---------------cut here---------------end--------------->8---

(It hasn’t been touched since 2017, so it might have been failing for a
long time.)

I naively tried building against CGAL 4.x (patch below) but that failed
elsewhere:

--8<---------------cut here---------------start------------->8---
g++ -std=c++0x -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -frounding-math -DNDEBUG -I/gnu/store/hwrhh7icnj2rsr208szblzys2j91gqq3-cgal-4.14.2/include -I/gnu/store/5jf395qa3v4amdi60850rz2a15zlsrza-mpfr-4.0.2/include -I/gnu/store/35afkywncrr5xsb4cxcljf6rpjcb7f61-gmp-6.2.0/include -I/gnu/store/vp2s1nxsc9vvc1ix66xpbf041f8nacxr-boost-1.72.0/include -I/usr/include -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/lnInclude -I../conformalVoronoi2DMesh/lnInclude -I../conformalVoronoiMesh/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/parallel/decompose/decompositionMethods/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/finiteVolume/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/meshTools/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/surfMesh/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/edgeMesh/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/dynamicMesh/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/mesh/extrudeModel/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/sampling/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/triSurface/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/fileFormats/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/mesh/snappyHexMesh/lnInclude -IlnInclude -I. -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/OpenFOAM/lnInclude -I/tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/src/OSspecific/POSIX/lnInclude   -fPIC -c foamyQuadMesh.C -o /tmp/guix-build-openfoam-4.1.drv-0/OpenFOAM-4.1/platforms/linux64GccDPInt32Opt/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/foamyQuadMesh.o
In file included from insertSurfaceNearPointPairs.C:26:0:
CV2D.H:352:51: error: ‘point’ does not name a type
             inline const point2D& toPoint2D(const point&) const;
                                                   ^~~~~
CV2D.H:354:20: error: ‘point’ does not name a type
             inline point toPoint3D(const point2D&) const;
                    ^~~~~
--8<---------------cut here---------------end--------------->8---

It would probably be best to upgrade, but that’s an intimidating piece
of software and it takes a lot of CPU time to build.

Thoughts?

Ludo’.

diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index 3f2be5766c..7f091c02e3 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015, 2016 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2015, 2016, 2021 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2015 Tomáš Čech <[email-masked]>
 ;;; Copyright © 2016, 2019 Leo Famulari <[email-masked]>
 ;;; Copyright © 2016, 2017, 2019 Ricardo Wurmus <[email-masked]>
@@ -796,6 +796,19 @@ (define-public cgal
     ;; permissive licenses.
     (license license:gpl3+)))
 
+(define-public cgal-4
+  (package
+    (inherit cgal)
+    (version "4.14.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/CGAL/cgal/releases/download/v" version
+                    "/CGAL-" version ".tar.xz"))
+              (sha256
+               (base32
+                "08lrp3hfwdypggz4138bnkh6bjxn441zg2y9xnq5mrjfc5ini6w1"))))))
+
 (define-public ilmbase
   (package
     (name "ilmbase")
diff --git a/gnu/packages/simulation.scm b/gnu/packages/simulation.scm
index 23580322bb..f95356d913 100644
--- a/gnu/packages/simulation.scm
+++ b/gnu/packages/simulation.scm
@@ -88,7 +88,7 @@ (define-public openfoam
     (build-system gnu-build-system)
     (inputs
      `(("boost" ,boost)
-       ("cgal" ,cgal)
+       ("cgal" ,cgal-4)
        ("flex" ,flex)
        ("git" ,git)
        ("gmp" ,gmp)