ocaml / dune

A composable build system for OCaml.
https://dune.build/
MIT License
1.64k stars 409 forks source link

dune-build-info transitively used from ppx rewriter #3336

Closed xclerc closed 4 years ago

xclerc commented 4 years ago

(note: I am not sure the use case below is supposed to be supported, as the documentation states that build info can be embedded in executables, but does not explicitly mention whether it can be embedded in libraries.)

Expected Behavior

Define a library depending on dune-build-info and have a ppx rewriter depending on said library.

Actual Behavior

Dune fails with:

File ".ppx/98cd9c27bc47def1a842c7a721af4e6b/_ppx.ml", line 1:
Error: No implementations provided for the following modules:
         Build_info__Build_info_data referenced from /Users/xclerc/.opam/4.10.0/lib/dune-build-info/build_info.cmxa(Build_info)

Reproduction

repro.zip

Specifications

ghost commented 4 years ago

Well, the build info are not filled during the build process. I.e. we just leave a blank in the executable and rewrite it at install time. So if we supported this, the lib would report dummy values. Though we could still support it just to avoid this error and so that you can use a library that depends on dune-build-info in a ppx.

xclerc commented 4 years ago

Sorry, I am a bit confused: it looks like executables in the _build directory do contain e.g. the version. I am pretty sure I have seen it working for an executable depending on a library itself depending on dune-build-info.

ghost commented 4 years ago

Only if it is known statically, i.e. if you are building from a release tarball. If the version comes from git, it will be left blank inside _build.

xclerc commented 4 years ago

Thanks for the clarification.

ghost commented 4 years ago

Do you want to take a look at this BTW?

xclerc commented 4 years ago

I am afraid my knowledge of dune's code base is wildly outdated...

rgrinberg commented 4 years ago

I think that this issue is caused by the fact that we don't handle link time code gen when build ppx exe's.

@jeremiedimino I recall you explained to me once why we had a separate compilation pipeline for ppx drivers instead of reusing Exe, but I wasn't entirely convinced. Do you mind explaining again? Exe would handle link time code gen for us.

ghost commented 4 years ago

I can't remember either.