ocaml-multicore / ocaml-multicore

Multicore OCaml
Other
762 stars 68 forks source link

4.12+domains+effects fails to compile batteries, with missing Printexc.get_continuation_callstack #599

Open ewanmellor opened 3 years ago

ewanmellor commented 3 years ago

Building batteries with 4.12+domains+effects fails with the following error. (Note that 4.12+domains does not fail in the same way.)

+ ocamlfind ocamlc -c -warn-error +26 -g -annot -bin-annot -safe-string -no-alias-deps -strict-sequence -w -3 -w -29 -package bigarray,num,str -warn-error -50 -package bytes -package oUnit,qcheck -I src -I toplevel -I testsuite -I qtest -I build -I benchsuite -I benchsuite/lib -o src/batteries_compattest.cmo src/batteries_compattest.ml
File "src/batteries_compattest.ml", line 53, characters 5-13:
53 |     (Printexc: sig
          ^^^^^^^^
Error: Signature mismatch:
       ...
       The value `get_continuation_callstack' is required but not provided
       File "printexc.mli", line 195, characters 0-76: Expected declaration

Compiler: 2f7fea603d (current HEAD of 4.12+domains+effects branch). Full build log: https://multicore.ci.ocamllabs.io:8100/job/2021-06-28/072651-ci-ocluster-build-e9f16c Successful build with 4.12+effects, for comparison: https://multicore.ci.ocamllabs.io:8100/job/2021-06-28/014040-ci-ocluster-build-3fef23 Successful build with stock 4.12, for comparison: https://multicore.ci.ocamllabs.io:8100/job/2021-06-28/014040-ci-ocluster-build-6d675f

To reproduce:

git clone --recursive "https://github.com/ocaml-batteries-team/batteries-included" -b "v3.3.0" && cd "batteries-included" && git reset --hard 9cce3afb
cat > Dockerfile <<'END-OF-DOCKERFILE'
FROM ocaml/opam@sha256:c46a1eff176d081b39e8c1d50935f37704cb4305c4995856681dc4d89b656b1d
# Variant: debian-10-4.12+domains+effects
USER 1000:1000
# Update opam-repository
WORKDIR /home/opam/opam-repository
RUN (git cat-file -e 443edb36615b1668d0ee814a77d8b697cb09b280 || git fetch origin master) && git reset -q --hard 443edb36615b1668d0ee814a77d8b697cb09b280 && git log --no-decorate -n1 --oneline && opam update -u
RUN eval $(opam env) && opam switch && ocamlrun -version
# Pin project opam files
WORKDIR /src
RUN mkdir -p './'
COPY --chown=1000:1000 batteries.opam ./
RUN opam pin add -yn batteries.dev './'
# Install opam deps
ENV DEPS base-bigarray.base base-bytes.base base-domains.base base-effects.base base-threads.base base-unix.base benchmark.1.6 dune.2.8.5 num.1.4 ocaml.4.12.0 ocaml-config.2 ocaml-option-nnp.1 ocaml-variants.4.12.0+domains+effects ocamlbuild.0.14.0 ocamlfind.1.9.1 ounit.2.2.4 ounit2.2.2.4 qcheck.0.13 qcheck-core.0.13 qcheck-ounit.0.13 qtest.2.11 stdlib-shims.0.3.0
RUN opam depext --update -y batteries.dev $DEPS
RUN opam install $DEPS
# Initialize project source
COPY --chown=1000:1000 . /src/
WORKDIR /src
# Run build
RUN opam exec -- make all test

END-OF-DOCKERFILE
docker build .
kit-ty-kate commented 3 years ago

I'm not really seeing a way to distinguish between +domains and +domains+effects without opam right now. In https://github.com/ocaml-batteries-team/batteries-included/pull/991 I had made batteries compatible with +domains, but +effects being so far away I didn't bother with it.

If you want a quick and dirty fix, here is a patch for batteries to make it work:

diff --git a/build/prefilter.ml b/build/prefilter.ml
index 22697380..7ec72007 100644
--- a/build/prefilter.ml
+++ b/build/prefilter.ml
@@ -54,6 +54,8 @@ let rec process_line loc line =
         cmp (major*100+minor) (ver_maj*100+ver_min)
       else if ver_string = "multicore" then
         cmp (if extra = "+multicore" then 5 else major) 5
+      else if ver_string = "effects" then (* HACK *)
+        cmp (if extra = "+multicore" then 5 else major) 5 (* HACK *)
       else
         failwith "Could not parse version string"
     in
diff --git a/src/batPrintexc.mliv b/src/batPrintexc.mliv
index bfeef612..d59d26d9 100644
--- a/src/batPrintexc.mliv
+++ b/src/batPrintexc.mliv
@@ -179,6 +179,15 @@ val print : _ BatInnerIO.output -> exn -> unit
 ##V>=4.2##    @since 2.2.0 and OCaml 4.01.0
 ##V>=4.2##*)
 ##V>=4.2##
+##V>=effects##(** {6 Continuations} *)
+##V>=effects##
+##V>=effects##val get_continuation_callstack: ('a,'b) continuation -> int -> raw_backtrace
+##V>=effects##(** [Printexc.get_continuation_callstack c n] returns a description of the top
+##V>=effects##    of the call stack on the continuation [c], with at most [n] entries. (Note:
+##V>=effects##    this function is not related to exceptions at all, despite being part of
+##V>=effects##    the [Printexc] module.)
+##V>=effects##*)
+##V>=effects##
 ##V>=4.2##(** {6 Uncaught exceptions} *)
 ##V>=4.2##
 ##V>=4.11##val default_uncaught_exception_handler: exn -> raw_backtrace -> unit