ellisk42 / ec

MIT License
485 stars 140 forks source link

cannot build ocaml libs #96

Open sneiman opened 2 years ago

sneiman commented 2 years ago

I am failing to rebuild ocaml libs using provided instructions. I am on the master branch, using Ubuntu 20.04, python 3.8.10, opam version 2.0.5, ocaml version 4.06.1. I am not using Singularity as it failed to install, hanging on initialization of tzdata. So, I installed in virtual environment - not conda. I did have to make some changes to requirements.txt to get everything to build as there were version inconsistencies. I removed all version references - causing installation of current versions, and install Box2D instead of Box2D-kengz.

I have successfully run training for list and text and generated some graphs. These produced good results.

I then decided to try to implement the 'demo' new domain. These errors occur on ANY attempt to build the ocaml libs - whether or not I add let primitive_increment2 = primitive "incr2" (tint @> tint) (fun x -> 2+x);; to program.ml. Here are the error messages:

cp _build/default/logoDrawString.exe \
    ../logoDrawString && \
  ln -s ../../logoDrawString \
    ../data/geom/logoDrawString
      menhir geomLib/lambdaParser.{ml,mli} (exit 1)
(cd _build/default/geomLib && /home/seth/.opam/4.06.1+flambda/bin/menhir lambdaParser.mly)
Error: the code back-end requires the type of every nonterminal symbol to be
known. Please specify the type of every symbol via %type declarations, or
enable type inference (look up --infer in the manual).
Type inference is automatically enabled when Menhir is used via Dune,
provided the dune-project file says (using menhir 2.0) or later.
The types of the following nonterminal symbols are unknown:
expr
someb
somev
var
      menhir geomLib/geomParser.{ml,mli} (exit 1)
(cd _build/default/geomLib && /home/seth/.opam/4.06.1+flambda/bin/menhir geomParser.mly)
Warning: 4 states have shift/reduce conflicts.
Warning: 4 shift/reduce conflicts were arbitrarily resolved.
Error: the code back-end requires the type of every nonterminal symbol to be
known. Please specify the type of every symbol via %type declarations, or
enable type inference (look up --infer in the manual).
Type inference is automatically enabled when Menhir is used via Dune,
provided the dune-project file says (using menhir 2.0) or later.
The types of the following nonterminal symbols are unknown:
expr
integrate
optional_comma
optional_integrate_accel
optional_integrate_angularAccel
optional_integrate_angularSpeed
optional_integrate_args
optional_integrate_d
optional_integrate_pen
optional_integrate_speed
optional_repeat_args
optional_turn_args
repeat
turn
value

any help much appreciated!

UPDATE: I can get past these issues by adding ((flags (--infer)) to the geomLib jbuild file instructions that use menhir. However this fails because it does not recognize modules Plumbing and Interpreter. Attempting to add open statements fails, claiming that open is a reserved word.

I am a jbuild/ocaml/menhir noob - any help appreciated.

sneiman commented 2 years ago

Here is a fix to build singularity container on Ubuntu 20.04. It currently fails with tzdata config interaction. To fix:

In the singularity file after %post and before apt-get update ... add:

    export TZ=America/Los_Angeles
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone**

Set TZ variable to the appropriate tzdata time zone phrase (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). Then run the singularity build line as provided in README.doc:

sudo singularity build container.img singularity

This works on Ubuntu 20.04. Still testing whether or not you can build the ocaml libs in the container.

UDPATE: Running in container does not fix ocaml build issues.

Seondong commented 2 years ago

I tried to build the ec directory in the singularity container and faced the same issue.

Before that, a test script did not run due to JSONDecodeError in the compression part, so I attempted to recompile this.

@sneiman Did you solve the ocaml build issues?

Singularity> make
rm -f data/geom/logoDrawString
cd solvers && \
  jbuilder build solver.exe && \
  jbuilder build versionDemo.exe && \
  jbuilder build helmholtz.exe && \
  jbuilder build logoDrawString.exe && \
  jbuilder build protonet-tester.exe && \
  jbuilder build compression.exe && \
  jbuilder build evolution.exe && \
  cp _build/default/compression.exe ../compression && \
  cp _build/default/versionDemo.exe ../versionDemo && \
  cp _build/default/evolution.exe ../evolution && \
  cp _build/default/solver.exe ../solver && \
  cp _build/default/helmholtz.exe ../helmholtz && \
  cp _build/default/protonet-tester.exe ../protonet-tester && \
  cp _build/default/logoDrawString.exe \
    ../logoDrawString # && \
  # ln -s ../../logoDrawString \
  #  ../data/geom/logoDrawString
      menhir geomLib/geomParser.{ml,mli} (exit 1)
(cd _build/default/geomLib && /container/.opam/4.06.1+flambda/bin/menhir geomParser.mly)
Warning: 4 states have shift/reduce conflicts.
Warning: 4 shift/reduce conflicts were arbitrarily resolved.
Error: the code back-end requires the type of every nonterminal symbol to be
known. Please specify the type of every symbol via %type declarations, or
enable type inference (look up --infer in the manual).
Type inference is automatically enabled when Menhir is used via Dune,
provided the dune-project file says (using menhir 2.0) or later.
The types of the following nonterminal symbols are unknown:
expr
integrate
optional_comma
optional_integrate_accel
optional_integrate_angularAccel
optional_integrate_angularSpeed
optional_integrate_args
optional_integrate_d
optional_integrate_pen
optional_integrate_speed
optional_repeat_args
optional_turn_args
repeat
turn
value
      menhir geomLib/lambdaParser.{ml,mli} (exit 1)
(cd _build/default/geomLib && /container/.opam/4.06.1+flambda/bin/menhir lambdaParser.mly)
Error: the code back-end requires the type of every nonterminal symbol to be
known. Please specify the type of every symbol via %type declarations, or
enable type inference (look up --infer in the manual).
Type inference is automatically enabled when Menhir is used via Dune,
provided the dune-project file says (using menhir 2.0) or later.
The types of the following nonterminal symbols are unknown:
expr
someb
somev
var
Goshagosha commented 2 years ago

After a couple of very painful weeks, I managed to debug this. Recent rewrite of menhir backend made typing enforced.
I have no idea how ocaml repos are organised, but interestingly on ubuntu 18 and younger this is not an issue, as the latest menhir version is not up to date in opam.

I have fixed this by downgrading menhir with opam install menhir.20211128.
Probably far more elegant way would be to pass menhir args in ./solvers/jbuild, but, again, I know nothing about ocaml, and as far as I gathered there is no straightforward way to do it without rewriting build files with dune.

mxbi commented 1 year ago

As of March 2023, I need to also pin the version of yojson, so the opam command is as follows:

opam install -y  ppx_jane core re2 yojson.1.6.0 vg cairo2 camlimages menhir.20211128 ocaml-protoc zmq utop jbuilder

With this, I am able to make with no issues.