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

[3.17]backport #11248 fix(melange): use output of virtual library when compiling its source… #11371

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/changes/11248.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Fix a crash in the Melange rules that would prevent compiling public library
implementations of virtual libraries. (@amonteiro, #11248)

1 change: 1 addition & 0 deletions src/dune_rules/melange/melange_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ let setup_js_rules_libraries =
in
cmj_includes ~requires_link ~scope lib_config
in
let output = output_of_lib ~target_dir vlib in
parallel_build_source_modules
~sctx
~scope
Expand Down
50 changes: 50 additions & 0 deletions test/blackbox-tests/test-cases/melange/virtual-lib-public-impl.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Test virtual libraries where the virtual implementation is a public library

$ mkdir -p vlib js_impl test
$ cat > dune-project <<EOF
> (lang dune 3.13)
> (using melange 0.1)
> (package (name the_lib))
> (package (name concrete_lib))
> EOF
$ cat > vlib/dune <<EOF
> (library
> (name the_lib)
> (modes melange native)
> (public_name the_lib)
> (virtual_modules virt))
> EOF
$ cat > vlib/the_lib.mli <<EOF
> module Time : sig
> val gettimeofday : unit -> float
> end
> EOF
$ cat > vlib/the_lib.ml <<EOF
> module Time = struct
> let gettimeofday () = Virt.gettimeofday ()
> end
> EOF
$ cat > vlib/virt.mli <<EOF
> val gettimeofday : unit -> float
> EOF

$ cat > js_impl/dune <<EOF
> (library
> (name timeJs)
> (public_name concrete_lib)
> (implements the_lib)
> (modes melange)
> (preprocess (pps melange.ppx)))
> EOF
$ cat > js_impl/virt.ml <<EOF
> let gettimeofday : unit -> float = fun () -> 42.
> EOF

$ cat > test/dune <<EOF
> (melange.emit
> (target output)
> (libraries the_lib concrete_lib)
> (emit_stdlib false))
> EOF

$ dune build @melange
Loading