Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to build with OCaml 4.08 version #957

Merged
merged 26 commits into from
Jan 23, 2020
Merged

Conversation

XVilka
Copy link
Contributor

@XVilka XVilka commented Jun 19, 2019

With the new OCaml 4.08 release there are lot of nice optimizations and features out of the box, even without changing the current code. Worth to make sure it builds. For now lets see if everything passes OK.

@XVilka
Copy link
Contributor Author

XVilka commented Jun 19, 2019

Strange error on 4.07 compiler:

- ocamldoc -html -d ../autodoc  -t "FrontC" cabs.ml cxml.ml cprint.ml ctoxml.ml frontc.ml
- ../autodoc/style.css: No such file or directory
- Fatal error: exception Failure("../autodoc/Cabs.html: No such file or directory")
- make[1]: *** [doc] Error 2

Also I don't get what is happening there - error message looks empty

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+ /home/travis/.opam/opam-init/hooks/sandbox.sh "build" "./configure" "--prefix=/home/travis/.opam/4.07.0" "--with-cxx=`which clang++`" "--with-llvm-version=5.0.0git-929163d" "--with-llvm-config=/usr/local/clang-5.0.0/bin/llvm-config" "--mandir=/home/travis/.opam/4.07.0/man" "--enable-everything" "--enable-tests" "--disable-ida" "--disable-fsi-benchmark" "--disable-objdump" (CWD=/home/travis/.opam/4.07.0/.opam-switch/build/bap.master)
[ERROR] The compilation of bap failed at
        "/home/travis/.opam/opam-init/hooks/sandbox.sh build ./configure
        --prefix=/home/travis/.opam/4.07.0 --with-cxx=`which clang++`
        --with-llvm-version=5.0.0git-929163d
        --with-llvm-config=/usr/local/clang-5.0.0/bin/llvm-config
        --mandir=/home/travis/.opam/4.07.0/man --enable-everything
        --enable-tests --disable-ida --disable-fsi-benchmark
        --disable-objdump".
#=== ERROR while compiling bap.master =========================================#
# context     2.0.4 | linux/x86_64 | ocaml-base-compiler.4.07.0 | pinned(file:///home/travis/build/BinaryAnalysisPlatform/bap)
# path        ~/.opam/4.07.0/.opam-switch/build/bap.master
# command     ~/.opam/opam-init/hooks/sandbox.sh build ./configure --prefix=/home/travis/.opam/4.07.0 --with-cxx=`which clang++` --with-llvm-version=5.0.0git-929163d --with-llvm-config=/usr/local/clang-5.0.0/bin/llvm-config --mandir=/home/travis/.opam/4.07.0/man --enable-everything --enable-tests --disable-ida --disable-fsi-benchmark --disable-objdump
# exit-code   1
# env-file    ~/.opam/log/bap-3530-05296d.env
# output-file ~/.opam/log/bap-3530-05296d.out
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build bap master
└─ 
╶─ No changes have been performed

@XVilka
Copy link
Contributor Author

XVilka commented Jun 19, 2019

Blocked by alavrik/piqi#62 and camlp4/camlp4#151

@XVilka
Copy link
Contributor Author

XVilka commented Jun 26, 2019

I checked the rest of the dependencies - they behave well for OCaml 4.08.0+, so once piqi is fixed, should be good.

@XVilka
Copy link
Contributor Author

XVilka commented Aug 6, 2019

Note that camlp5 7.08 was released, and piqi moved to use it instead of camlp4. So please rerun the Travis, to check the build.

@ivg
Copy link
Member

ivg commented Aug 6, 2019

Our Travis infrastructure is still relying on opam 1.x so we don't see the updated piqi package. That only means, that we have to update our Travis CI scripts. Indeed, it doesn't make sense to test installability with 1.x

@XVilka
Copy link
Contributor Author

XVilka commented Aug 12, 2019

I don't get the reason of 4.07 build failure:

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+ /home/travis/.opam/opam-init/hooks/sandbox.sh "build" "./configure" "--prefix=/home/travis/.opam/4.07.0" "--with-cxx=`which clang++`" "--with-llvm-version=5.0.0git-929163d" "--with-llvm-config=/usr/local/clang-5.0.0/bin/llvm-config" "--mandir=/home/travis/.opam/4.07.0/man" "--enable-everything" "--enable-tests" "--disable-ida" "--disable-fsi-benchmark" "--disable-objdump" (CWD=/home/travis/.opam/4.07.0/.opam-switch/build/bap.master)
[ERROR] The compilation of bap failed at
        "/home/travis/.opam/opam-init/hooks/sandbox.sh build ./configure
        --prefix=/home/travis/.opam/4.07.0 --with-cxx=`which clang++`
        --with-llvm-version=5.0.0git-929163d
        --with-llvm-config=/usr/local/clang-5.0.0/bin/llvm-config
        --mandir=/home/travis/.opam/4.07.0/man --enable-everything
        --enable-tests --disable-ida --disable-fsi-benchmark
        --disable-objdump".
#=== ERROR while compiling bap.master =========================================#
# context     2.0.4 | linux/x86_64 | ocaml-base-compiler.4.07.0 | pinned(file:///home/travis/build/BinaryAnalysisPlatform/bap)
# path        ~/.opam/4.07.0/.opam-switch/build/bap.master
# command     ~/.opam/opam-init/hooks/sandbox.sh build ./configure --prefix=/home/travis/.opam/4.07.0 --with-cxx=`which clang++` --with-llvm-version=5.0.0git-929163d --with-llvm-config=/usr/local/clang-5.0.0/bin/llvm-config --mandir=/home/travis/.opam/4.07.0/man --enable-everything --enable-tests --disable-ida --disable-fsi-benchmark --disable-objdump
# exit-code   1
# env-file    ~/.opam/log/bap-5087-05296d.env
# output-file ~/.opam/log/bap-5087-05296d.out
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build bap master
└─ 
╶─ No changes have been performed
The packages you requested declare the following system dependencies. Please
make sure they are installed before retrying:
    clang dejagnu libcurl4-gnutls-dev libgmp-dev libzip-dev llvm llvm-3.8-dev
    m4 time
'opam install bap -v' failed.
'unset TESTS; OPAMYES=1 export OPAMYES; set -uex; opam install bap "-v"' exited 31. Terminating with 31
The command "bash -ex .travis_install.sh" exited with 31.
cache.2
store build cache

@ivg
Copy link
Member

ivg commented Aug 12, 2019

The build fails, because the oasis file wasn't updated (it also limits the version of OCaml). @gitoleg revived his old branch and managed to build everything for 4.08. While he is running his tests, here is the status update.

The 4.07 is the latest version supported by core_kernel.v0.11.0, so in order to switch to 4.08 we need to switch to a newer version of core_kernel. As always, the switch is not backward compatible, so we can't support both v0.11 and v0.12 (especially, since they renamed a couple of libraries). Therefore, the solution is to switch to v0.12 and drop the support for 4.04, 4.05, and 4.06. So that now we will support only 4.07 and 4.08.

I'm totally ready to switch to 4.08+core.v0.12 even today in bap-2.0 branch. The main question is whether we should backport this to 1.x. Basically, the list of options that we have:

  1. keep 1.6 on old compilers and update only 2.0
  2. switch both 1.6 and 2.0 to the new compilers
  3. fork 1.6 into 1.6.x, 1.7.0, and 2.0.0 with the latter two using v0.12 and the first still tracking the older compiler.

Opinions, other options?

@XVilka
Copy link
Contributor Author

XVilka commented Aug 13, 2019

I think the third option is the sanest one, keeping one with the modern world, without the breaking old things.

@ivg
Copy link
Member

ivg commented Aug 13, 2019

I think the third option is the sanest one, keeping one with the modern world, without the breaking old things.

Yep, but this implies lots of work and less clear work. If we will pursue this path, then we need to keep code compatible with different versions of OCaml (including the deprecation and removal of Pervasives and Genarray.*.map_file, which requires us to add a few shim libraries as dependencies, and use them as indirections in our code).

@XVilka
Copy link
Contributor Author

XVilka commented Aug 13, 2019 via email

@ivg
Copy link
Member

ivg commented Aug 15, 2019

This branch is go to go into the master (after a merge or rebase), see the related issue for more discussion

@XVilka
Copy link
Contributor Author

XVilka commented Aug 16, 2019

Rebased against the current master. Travis is drunk though. Sometimes it shows "Can't find the repository", sometimes - "can't find the build".

@XVilka
Copy link
Contributor Author

XVilka commented Aug 16, 2019

I don't get why it shows while it was fixed:

# + /home/travis/.opam/4.07.0/bin/ocamlfind ocamlc -c -g -annot -bin-annot -short-paths -I lib/monads -I lib/bap_strings -I lib/bitvec -I lib/bitvec_sexp -I lib/bitvec_binprot -I lib/bitvec_order -I lib/knowledge -I lib/bap_core_theory -I lib/regular -I lib/graphlib -w +a-4-6-7-9-27-29-32..42-44-45-48-50-60 -package zarith -package sexplib0 -package ppx_jane -package parsexp -package ocamlgraph[...]
# File "lib/bap_lisp/bap_lisp__resolve.ml", line 115, characters 6-39:
# Error: This expression has type (var * 'weak2) list List.Or_unequal_lengths.t
#        but an expression was expected of type 'weak5 option
# Command exited with code 2.
# make: *** [build] Error 1

Even the line number is wrong

@XVilka
Copy link
Contributor Author

XVilka commented Aug 16, 2019

Looks like Travis doesn't get the valid sources.

@XVilka
Copy link
Contributor Author

XVilka commented Aug 19, 2019

Note, that the piqi switched to sedlex, so no need for camlp4 and camlp5 dependency! \o/
BAP is more future-proof now. Waiting for the release now: alavrik/piqi#61

@XVilka
Copy link
Contributor Author

XVilka commented Aug 29, 2019

I think we also can drop these lines from the .travis-ocaml.sh:

  case "$OCAML_VERSION,$OPAM_VERSION" in
    3.12,1.2.2) OCAML_FULL_VERSION=3.12.1; brew install opam ;;
    4.00,1.2.2) OCAML_FULL_VERSION=4.00.1; brew install opam ;;
    4.01,1.2.2) OCAML_FULL_VERSION=4.01.0; brew install opam ;;
    4.02,1.2.2) OCAML_FULL_VERSION=4.02.3; brew install opam ;;
    4.02,1.3.0) OCAML_FULL_VERSION=4.02.3; brew install opam --HEAD ;;

https://github.com/BinaryAnalysisPlatform/bap/blob/master/.travis-ocaml.sh#L142
And other, similar cases too.

@XVilka
Copy link
Contributor Author

XVilka commented Sep 13, 2019

There is still no answer from piqi author, but maybe it's possible to pin the repo for a while?

@XVilka
Copy link
Contributor Author

XVilka commented Sep 29, 2019

Should be good to retry once ocaml/opam-repository#14947 is merged:

Changes

Piqi 0.6.15 (September 28, 2018)

Miscellaneous:

  • Switch from ulex to sedlex
  • Rely on opam for installing third-party dependencies
  • Bump minimal supported OCaml version from 4.02 to 4.03

P.S. We should try also the 4.09 too.

@XVilka
Copy link
Contributor Author

XVilka commented Oct 2, 2019

Still the same error. Travis seems out of sync with the git and opam.

@XVilka
Copy link
Contributor Author

XVilka commented Oct 11, 2019

So what do we do with this one?

@gitoleg
Copy link
Contributor

gitoleg commented Oct 15, 2019

@XVilka
We're currently working on the release of bap.2.0 that should happen before the end of this month. Right after that, we'll merge this PR.

@XVilka
Copy link
Contributor Author

XVilka commented Nov 21, 2019

@ivg completely agree. One of the interesting features of the new library is a deriver plugin for Python accessors generation: https://github.com/janestreet/ppx_python

Since BAP has Python bindings, it might be quite useful for making them better.

module Args : Applicative.Args with type 'a arg := 'a t

module Args : sig
type 'a arg = 'a t
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the arg type from the signature, it wasn't there before

List.for_all ~f:(fun (v,x) ->
f v.data.typ x)

let zip x y =
let open List.Or_unequal_lengths in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for this open, as now the compiler will take the constructors from the right place.

@@ -178,15 +178,15 @@ let pp_generic
| `this x -> fprintf ppf "%s" x
| `base -> pp_prefix ppf
| `auto ->
if Bitvec_order.(x >= (min (word 10) base))
if Z.Compare.(x >= (Z.min (word 10) base))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, it was a bug before... not that it was breaking before, but at least the code as written was not the code as meant.

let apply_map name get map skip blk ~f =
if List.mem ~equal:Polymorphic_compare.equal skip name
let apply_map ~equal name get map skip blk ~f =
if List.mem ~equal skip name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is fine to use the polymorphic compare here

Copy link
Member

@ivg ivg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple of changes and we're good to go

  1. restore ignore instead of Caml.ignore.
  2. remove the _ arg type from the Args interface

As a general note, it is fine to use polymorphic compare, so this PR could be much easier to digest if we would just do open Poly.

File "oasis/common.setup.ml.in", line 1773, characters 22-40:
Alert deprecated: module Stdlib.Pervasives
Use Stdlib instead.

If you need to stay compatible with OCaml < 4.07, you can use the
stdlib-shims library: https://github.com/ocaml/stdlib-shims
File "setup.ml", line 3467, characters 16-34:
3467 |                 Pervasives.compare o2 o1)
                       ^^^^^^^^^^^^^^^^^^
Alert deprecated: module Stdlib.Pervasives
Use Stdlib instead.

If you need to stay compatible with OCaml < 4.07, you can use the
stdlib-shims library: https://github.com/ocaml/stdlib-shims
@ivg ivg merged commit 1181879 into BinaryAnalysisPlatform:master Jan 23, 2020
gitoleg added a commit to gitoleg/bap that referenced this pull request Jan 27, 2020
Previously, we decided to disable the Jane Street code style checks as a
fast solution, but it turned out that it is easier to adopt their style
than to fight with it. To disable the checks, we used the _tags file,
but since we have a global repository the tags file affected all
subprojects, even those that do not use the ppx-jane preprocessor, thus
breaking packages that do not explicitly depend on ppx-jane.

Also, in BinaryAnalysisPlatform#957 we accidentally introduced a dependency on a newer version
of `zartith` by using the `Compare` module. We will now use plaincompare
et alas functions so that the old version of `zarith` could be still used
with BAP.
ivg pushed a commit that referenced this pull request Jan 27, 2020
Previously, we decided to disable the Jane Street code style checks as a
fast solution, but it turned out that it is easier to adopt their style
than to fight with it. To disable the checks, we used the _tags file,
but since we have a global repository the tags file affected all
subprojects, even those that do not use the ppx-jane preprocessor, thus
breaking packages that do not explicitly depend on ppx-jane.

Also, in #957 we accidentally introduced a dependency on a newer version
of `zartith` by using the `Compare` module. We will now use plaincompare
et alas functions so that the old version of `zarith` could be still used
with BAP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants