FreeFem / FreeFem-sources

FreeFEM source code
https://freefem.org/
Other
755 stars 188 forks source link

Error building FreeFem v4.12 with Nix #254

Closed htngr closed 1 year ago

htngr commented 1 year ago

I am trying to package FreeFem++ for Nix. Nix builds packages in a strict sandbox with no access to network or hardware details, so I download all 3rd party packages before the build and put them in 3rdparty/pkg. Otherwise I follow the compilation instructions for Ubuntu from the installation guide. Everything builds successfully until almost the end, when building bem.cpp throws the following error:

In file included from common_hpddm.hpp:17,
                 from PETSc.hpp:6,
                 from PETSc-code.hpp:3,
                 from PETSc-complex.cpp:5:
bem.hpp: In function 'void ff_BIO_Generator_Maxwell(htool::VirtualGenerator<T>*&, BemKernel*, bemtool::Dof<bemtool::BasisFct<3, 2> >&, Complex)':
bem.hpp:1243:174: error: invalid new-expression of abstract class type 'bemtool::BIO_Generator<bemtool::BIOpKernel<4, 1, 3, bemtool::BasisFct<3, 2>, bemtool::BasisFct<3, 2> >, bemtool::BasisFct<3, 2> >'
 1243 |             case bemtool::SL_OP : generator=new bemtool::BIO_Generator<bemtool::BIOpKernel<MA,bemtool::SL_OP,3,bemtool::RT0_2D,bemtool::RT0_2D>,bemtool::RT0_2D>(dof,kappaRe1);
      |                                                                                                                                                                              ^
In file included from common_hpddm.hpp:16,
                 from PETSc.hpp:6,
                 from PETSc-code.hpp:3,
                 from PETSc-complex.cpp:5:
/build/source/3rdparty/include/BemTool/bemtool/miscellaneous/htool_wrap.hpp:13:7: note:   because the following virtual functions are pure within 'bemtool::BIO_Generator<bemtool::BIOpKernel<4, 1, 3, bemtool::BasisFct<3, 2>, bemtool::BasisFct<3, 2> >, bemtool::BasisFct<3, 2> >':
   13 | class BIO_Generator : public htool::IMatrix<Cplx>{
      |       ^~~~~~~~~~~~~
In file included from /nix/store/k84hyv81q0nsh4s1r4ybwf9rissxqnrp-freefem-4.12/ff-petsc/c/include/htool/clustering/../misc/evp.hpp:4,
                 from /nix/store/k84hyv81q0nsh4s1r4ybwf9rissxqnrp-freefem-4.12/ff-petsc/c/include/htool/clustering/bounding_box_1.hpp:4,
                 from /nix/store/k84hyv81q0nsh4s1r4ybwf9rissxqnrp-freefem-4.12/ff-petsc/c/include/htool/htool.hpp:6,
                 from /build/source/3rdparty/include/BemTool/bemtool/miscellaneous/htool_wrap.hpp:4,
                 from common_hpddm.hpp:16,
                 from PETSc.hpp:6,
                 from PETSc-code.hpp:3,
                 from PETSc-complex.cpp:5:
/nix/store/k84hyv81q0nsh4s1r4ybwf9rissxqnrp-freefem-4.12/ff-petsc/c/include/htool/clustering/../misc/../types/matrix.hpp:30:17: note:     'int htool::IMatrix<T>::get_offset_i() const [with T = std::complex<double>]'
   30 |     virtual int get_offset_i() const = 0;
      |                 ^~~~~~~~~~~~
/nix/store/k84hyv81q0nsh4s1r4ybwf9rissxqnrp-freefem-4.12/ff-petsc/c/include/htool/clustering/../misc/../types/matrix.hpp:31:17: note:     'int htool::IMatrix<T>::get_offset_j() const [with T = std::complex<double>]'
   31 |     virtual int get_offset_j() const = 0;
      |                 ^~~~~~~~~~~~
/nix/store/k84hyv81q0nsh4s1r4ybwf9rissxqnrp-freefem-4.12/ff-petsc/c/include/htool/clustering/../misc/../types/matrix.hpp:33:18: note:     'void htool::IMatrix<T>::add_mvprod_row_major(const T*, T*, const int&, char, char) const [with T = std::complex<double>]'
   33 |     virtual void add_mvprod_row_major(const T *const in, T *const out, const int &mu, char transb = 'T', char op = 'N') const = 0;
      |                  ^~~~~~~~~~~~~~~~~~~~
In file included from bem.cpp:31:
bem.hpp: In function 'void ff_BIO_Generator_Maxwell(htool::VirtualGenerator<T>*&, BemKernel*, bemtool::Dof<bemtool::BasisFct<3, 2> >&, Complex)':
bem.hpp:1243:174: error: invalid new-expression of abstract class type 'bemtool::BIO_Generator<bemtool::BIOpKernel<4, 1, 3, bemtool::BasisFct<3, 2>, bemtool::BasisFct<3, 2> >, bemtool::BasisFct<3, 2> >'
 1243 |             case bemtool::SL_OP : generator=new bemtool::BIO_Generator<bemtool::BIOpKernel<MA,bemtool::SL_OP,3,bemtool::RT0_2D,bemtool::RT0_2D>,bemtool::RT0_2D>(dof,kappaRe1);
      |                                                                                                                                                                              ^
In file included from bem.cpp:19:
/build/source/3rdparty/include/BemTool/bemtool/miscellaneous/htool_wrap.hpp:13:7: note:   because the following virtual functions are pure within 'bemtool::BIO_Generator<bemtool::BIOpKernel<4, 1, 3, bemtool::BasisFct<3, 2>, bemtool::BasisFct<3, 2> >, bemtool::BasisFct<3, 2> >':
   13 | class BIO_Generator : public htool::IMatrix<Cplx>{
      |       ^~~~~~~~~~~~~
.......

Full log is attached here: freefem-nix.log The Nix derivation (or build script) is here: https://github.com/htngr/nixpkgs/blob/freefem/pkgs/applications/science/physics/freefem/default.nix.

prj- commented 1 year ago

Could you please try with the develop branch instead?

htngr commented 1 year ago

It compiles now :+1:

Although 2 tests fail now (full log):

make[4]: Entering directory '/build/source/examples/eigen'
PASS: BeamEigenValueperio.edp
PASS: BeamEigenValue.edp
../../bin/test-driver-ff: line 126: 398988 Segmentation fault      (core dumped) ${TEST_FFPP} ${FLAGS_FFPP_B} "$@" ${FLAGS_FFPP_A} > $log_file 2>&1
FAIL: LapComplexEigenValue.edp
PASS: free-cyl-axi.edp
PASS: neuman.edp
PASS: LapEigenValue.edp
PASS: LapnosymEigenValue.edp
PASS: VP-Steklov-Poincare.edp
PASS: condition-number.edp
PASS: LapEigenValueFuncV2.edp
FAIL: LapEigenValueFuncComplex.edp
PASS: LapEigenValueFunc.edp
PASS: Stokes-eigen.edp
PASS: Lap3dEigenValue.edp
PASS: WGM-sphere.edp
PASS: LapEigenBeltrami.edp
../../bin/test-driver-ff: line 126: 399015 Killed                  ${TEST_FFPP} ${FLAGS_FFPP_B} "$@" ${FLAGS_FFPP_A} > $log_file 2>&1
prj- commented 1 year ago

These tests use ARPACK, which I don’t recommend. If you have SLEPc shipped with the installation, then it’s not an issue.

htngr commented 1 year ago

Hmm, I did compile FreeFem as described in the docs with all dependencies and following flags:

--enable-download
--enable-optim
--enable-generic
--enable-opengl
--enable-summary

Also I make petsc-slepc, which should provide SLEPc.

prj- commented 1 year ago

You can leave it installed, just don’t use it.

htngr commented 1 year ago

I need the testsuite to pass for Nix. Should I just disable these two tests then?

prj- commented 1 year ago

I need the testsuite to pass for Nix.

I think you want the testsuite to pass, if you don’t make check, then why wouldn’t this get integrated? You could either disable those tests, allow them to fail, or just do cd examples/hpddm && make check (these are sufficient to test most FreeFEM features).

htngr commented 1 year ago

Alright, thanks a lot!