mirage / alcotest

A lightweight and colourful test framework
ISC License
451 stars 80 forks source link

Source location reporting fails on some arches in OCaml 5.0 #373

Closed MisterDA closed 1 year ago

MisterDA commented 1 year ago

A run of opam-repo-ci showed that source code locations aren't retained when running OCaml 5.0 bytecode compiler under arm32, ppc64, s390x, and x86_32.

https://opam-ci.ci3.ocamllabs.io/github/ocaml/opam-repository/commit/ed16529ae0727fdbab41878c3a0fd02b3440bdcd

The problem can be reproduced with the following Dockerfile (using Docker buildx with qemu to emulate the arches):

FROM ocaml/opam:debian-11-ocaml-5.0
# debian-11-5.0_opam-2.1
USER 1000:1000
ENV CLICOLOR_FORCE="1"
ENV OPAMCOLOR="always"
WORKDIR /src
RUN sudo ln -f /usr/bin/opam-2.1 /usr/bin/opam
RUN opam init --reinit -ni
WORKDIR /src
RUN sudo chown opam /src
RUN cd ~/opam-repository && (git cat-file -e c5fc79e7b15c7e1f694867da6248cb0bace7682e || git fetch origin master) && git reset -q --hard c5fc79e7b15c7e1f694867da6248cb0bace7682e && git log --no-decorate -n1 --oneline && opam update -u
COPY --chown=1000:1000 alcotest.opam alcotest-mirage.opam alcotest-lwt.opam alcotest-js.opam alcotest-async.opam ./
RUN opam pin add -yn alcotest.dev './' && \
opam pin add -yn alcotest-mirage.dev './' && \
opam pin add -yn alcotest-lwt.dev './' && \
opam pin add -yn alcotest-js.dev './' && \
opam pin add -yn alcotest-async.dev './'
ENV DEPS="astring.0.8.5 async.v0.15.0 async_kernel.v0.15.0 async_rpc_kernel.v0.15.0 async_unix.v0.15.0 base.v0.15.1 base-bigarray.base base-bytes.base base-domains.base base-nnp.base base-threads.base base-unix.base base_bigstring.v0.15.0 base_quickcheck.v0.15.0 bin_prot.v0.15.0 cmdliner.1.1.1 core.v0.15.1 core_kernel.v0.15.0 core_unix.v0.15.2 cppo.1.6.9 csexp.1.5.1 dune.3.7.0 dune-configurator.3.7.0 duration.0.2.1 expect_test_helpers_core.v0.15.0 fieldslib.v0.15.0 fmt.0.9.0 int_repr.v0.15.0 jane-street-headers.v0.15.0 js_of_ocaml-compiler.5.0.1 jst-config.v0.15.1 logs.0.7.0 lwt.5.6.1 menhir.20220210 menhirLib.20220210 menhirSdk.20220210 mirage-clock.4.2.0 num.1.4 ocaml.5.0.0 ocaml-base-compiler.5.0.0 ocaml-compiler-libs.v0.12.4 ocaml-config.3 ocaml-options-vanilla.1 ocaml-syntax-shims.1.0.0 ocaml_intrinsics.v0.15.2 ocamlbuild.0.14.2 ocamlfind.1.9.5 ocplib-endian.1.2 parsexp.v0.15.0 ppx_assert.v0.15.0 ppx_base.v0.15.0 ppx_bench.v0.15.0 ppx_bin_prot.v0.15.0 ppx_cold.v0.15.0 ppx_compare.v0.15.0 ppx_custom_printf.v0.15.0 ppx_derivers.1.2.1 ppx_disable_unused_warnings.v0.15.0 ppx_enumerate.v0.15.0 ppx_expect.v0.15.1 ppx_fields_conv.v0.15.0 ppx_fixed_literal.v0.15.0 ppx_hash.v0.15.0 ppx_here.v0.15.0 ppx_ignore_instrumentation.v0.15.0 ppx_inline_test.v0.15.0 ppx_jane.v0.15.0 ppx_let.v0.15.0 ppx_log.v0.15.0 ppx_module_timer.v0.15.0 ppx_optcomp.v0.15.0 ppx_optional.v0.15.0 ppx_pipebang.v0.15.0 ppx_sexp_conv.v0.15.1 ppx_sexp_message.v0.15.0 ppx_sexp_value.v0.15.0 ppx_stable.v0.15.0 ppx_string.v0.15.0 ppx_typerep_conv.v0.15.0 ppx_variants_conv.v0.15.0 ppxlib.0.28.0 protocol_version_header.v0.15.0 re.1.10.4 seq.base sexp_pretty.v0.15.1 sexplib.v0.15.1 sexplib0.v0.15.1 spawn.v0.15.1 splittable_random.v0.15.0 stdio.v0.15.0 stdlib-shims.0.3.0 textutils.v0.15.0 textutils_kernel.v0.15.0 time_now.v0.15.0 timezone.v0.15.0 topkg.1.0.7 typerep.v0.15.0 uutf.1.0.3 variantslib.v0.15.0 yojson.2.0.2"
ENV CI="true"
ENV OCAMLCI="true"
RUN opam update --depexts && opam install --cli=2.1 --depext-only -y alcotest.dev alcotest-mirage.dev alcotest-lwt.dev alcotest-js.dev alcotest-async.dev $DEPS
RUN opam install $DEPS
COPY --chown=1000:1000 . /src
RUN opam exec -- dune build @install @check @runtest && rm -rf _build
git clone --recursive "https://github.com/mirage/alcotest.git" -b "main" && cd "alcotest" && git reset --hard 927088ff
# output the Dockerfile here
docker build --platform linux/i386 .
MisterDA commented 1 year ago

Run the bytecode executable with ocamlrun to always have debug information. Debug info is currently removed on complete bytecode executables with ocamlc' -output-complete-exe. CAML_LD_LIBRARY_PATH must also (portably) point to the directory containing the shared library build from Alcotest C stubs.