eigen icon indicating copy to clipboard operation
eigen copied to clipboard

Opam Package Fails to Build

Open llee454 opened this issue 4 years ago • 1 comments

I ran opam install eigen on a laptop running Ubuntu. Opam failed with the following error message:

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[eigen.0.3.0] found in cache
[owl.0.8.0] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of eigen failed at "/home/larry/.opam/opam-init/hooks/sandbox.sh build dune build -p eigen -j 15".

#=== ERROR while compiling eigen.0.3.0 ========================================#
# context     2.0.5 | linux/x86_64 | ocaml-system.4.08.1 | https://opam.ocaml.org#5bb6b8b7
# path        ~/.opam/default/.opam-switch/build/eigen.0.3.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p eigen -j 15
# exit-code   1
# env-file    ~/.opam/log/eigen-75083-d0f245.env
# output-file ~/.opam/log/eigen-75083-d0f245.out
### output ###
# [...]
# x86_64-linux-gnu-gcc eigen_cpp/eigen_spmat.o (exit 1)
# (cd _build/default/eigen_cpp && /usr/bin/x86_64-linux-gnu-gcc -O2 -fno-strict-aliasing -fwrapv -fPIC -fPIC -ansi -pedantic -O3 -std=c++11 -w -Wno-invalid-partial-specialization -Ofast -march=native -funroll-loops -ffast-math -g -I /usr/lib/ocaml -I /home/larry/.opam/default/lib/bytes -I /home/larry/.opam/default/lib/ctypes -I /home/larry/.opam/default/lib/integers -I lib -I lib/unsupported -o[...]
# cc1plus: error: bad value (‘tigerlake’) for ‘-march=’ switch
...

The problem appears to be that opam is using x86_64-linux-gnu-gcc to compile the Eigen library. Also, this issue with the march value appears to be fixed in gcc-10 and g++-10 (https://stackoverflow.com/questions/64493692/cc1plus-error-bad-value-tigerlake-for-march-switch-compilation-error). I have both installed (/usr/bin/x86_64-linux-gnu-gcc-10) but opam clearly isn't using this.

Is there any way to instruct opam to use a different compiler, march flag, etc?

llee454 avatar Dec 17 '21 03:12 llee454

There is a way to use a different gcc, I can remember which flag you need to set, but it would require you to recompile everything- including ocaml-if I recall correctly.

you can, however, customise all the flags for owl and eigen. For eigen itself, you can read here: https://github.com/owlbarn/eigen#optional-configuration

there is a similar section on the readme for owl, if you need to also change it

mseri avatar Dec 17 '21 08:12 mseri