Skip to content

dune.3.6.1 crashes when I try to cross-compile a little project with Esperanto #6843

@dinosaure

Description

@dinosaure

Currently, I tried to upgrade [esperanto][espereanto] with Cosmopolitan v2.2 and try to improve [lwt][lwt] to support Cosmopolitan C library. My current situation is:

  1. I use the toolchain esperanto available here: Cosmopolitan v2.2 dinosaure/esperanto#28
  2. I try to use the lwt version available here: Allow the Esperanto support for lwt ocsigen/lwt#945
  3. I'm currently on OCaml 4.14.1, I use dune.3.6.1 and ocamlfind.1.9.5
  4. for the static linking, I use opam-monorepo.0.3.4 to bring dependencies

Let's try a simple to compile a simple program:

$ opam pin add -y https://github.com/dinosaure/esperanto.git#cosmopolitan-v2.2
$ opam pin add -yn lwt https://github.com/dinosaure/lwt.git#esperanto
$ opam install dune ocamlfind opam-monorepo
$ cat >dune-workspace <<EOF
(lang dune 2.0)
(context (default))
(context
 (default
  (name esperanto)
  (toolchain esperanto)
  (host default)))
EOF
$ cat >cat.ml <<EOF
open Lwt.Infix

let rec full_write fd buf off len =
  Lwt_unix.write fd buf off len >>= fun len' ->
  if len - len' > 0
  then full_write fd buf (off + len') (len - len')
  else Lwt.return_unit

let tmp = Bytes.create 0x1000

let rec cat () =
  Lwt.catch begin fun () ->
  Lwt_unx.read Lwt_unix.stdin tmp 0 (Bytes.length tmp) >>= fun len ->
  match len with
  | 0 -> Lwt.return_unit
  | len -> full_write Lwt_unix.stdout tmp 0 len >>= cat
  end @@ function
  | End_of_file -> Lwt.return_unit
  | exn -> raise exn

let () = Lwt_main.run (cat ())
EOF
$ cat >cat.opam <<EOF
opam-version: "2.0"
name:         "cat"
maintainer:   [ "Romain Calascibetta <[email protected]>" ]
authors:      [ "Romain Calascibetta <[email protected]>" ]
homepage:     "https://github.com/dinosaure/esperanto"
bug-reports:  "https://github.com/dinosaure/esperanto/issues"
dev-repo:     "git+https://github.com/dinosaure/esperanto"
doc:          "https://dinosaure.github.io/esperanto/"
license:      "MIT"
synopsis:     "The cat.com tool produced by esperanto"
description:  "The cat.com tool produced by esperanto"

build: [
  [ "dune" "build" "-p" name "-j" jobs ]
]
install:  [
  [ "dune" "install" "-p" name ] {with-test}
]

depends: [
  "ocaml"           {>= "4.12.0"}
  "dune"            {>= "2.8.0"}
  "lwt"
]
EOF
$ opam monorepo lock
$ opam monorepo pull
$ dune build -x esperanto ./cat.exe
$ dune build -x esperanto ./cat.exe
Warning: No dune-project file has been found. A default one is assumed but
the project might break when dune is upgraded. Please create a dune-project
file.
Hint: generate the project file with: $ dune init project <name>
File "src/dune_rules/context.ml", line 755, characters 20-26:
File "src/dune_rules/context.ml", line 755, characters 20-26: Assertion
failed
Raised at Dune_rules__context.Instantiate.instantiate_impl in file
  "src/dune_rules/context.ml", line 755, characters 20-32
Called from Fiber__core.O.(>>|).(fun) in file "src/fiber/core.ml", line 250,
  characters 36-41
Called from Fiber__scheduler.exec in file "src/fiber/scheduler.ml", line 73,
  characters 8-11

I must not crash.  Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration.  I will fully express my cases. 
Execution will pass over me and through me.  And when it has gone past, I
will unwind the stack along its path.  Where the cases are handled there will
be nothing.  Only I will remain.

As far as I can say, previous versions of dune worked and it seems related to this line:

https://github.com/ocaml/dune/blame/63e6845a89eab969323c88673533271b9e3c0baf/src/dune_rules/context.ml#L754

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions