Quantcast
Channel: OCaml - Topics tagged dune
Viewing all articles
Browse latest Browse all 521

Supporting both standard and multicore compilers in a dune project

$
0
0

I am developing a library which uses multicore. However to support users on Mac M1, I would like to provide a version of the library which can be compiled with a standard (non-multicore) compiler.

All the multicore-related code is contained in one single module. To optionally support a standard compiler, my idea was to use virtual libraries in dune to provide a single-core implementation of this module. Here is the first part of my dune file:

(library
  (name multicore_compute)
  (virtual_modules multicore_compute))

(library
  (name multicore_compute_real)
  (libraries domainslib)
  (implements multicore_compute))

I hope the implementation can be swapped with

(library
  (name multicore_compute_fake)
  (implements multicore_compute))

However, dune fails with the following error message:

make -k
dune build --profile release @install
Internal error, please report upstream including the contents of _build/log.
Description:
  ("dependency cycle that does not involve any files",
  { frames = [ ("<unnamed>", ()); ("<unnamed>", ()); ("<unnamed>", ()) ] })
Raised at Stdune__code_error.raise in file "src/stdune/code_error.ml", line
  9, characters 30-62
Called from Stdune__exn_with_backtrace.map in file
  "src/stdune/exn_with_backtrace.ml", line 20, characters 40-45
Called from Stdune__exn_with_backtrace.map_and_reraise in file
  "src/stdune/exn_with_backtrace.ml", line 22, characters 35-45
Called from Fiber.Execution_context.forward_exn_with_bt in file
  "src/fiber/fiber.ml", line 138, characters 10-17

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.
make: *** [Makefile:5: all] Error 1

I am unsure whether this is a bug in dune or if there is a problem with my dune file.

Also, if there are better ways of supporting different compilers, I would be happy to learn about these.

8 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 521

Trending Articles