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

ppx_jane doesn't work with ocamlfind #6

Closed
ivg opened this issue Nov 5, 2020 · 3 comments
Closed

ppx_jane doesn't work with ocamlfind #6

ivg opened this issue Nov 5, 2020 · 3 comments
Labels
forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.

Comments

@ivg
Copy link

ivg commented Nov 5, 2020

Here is a minimal example,

$ cat example.ml 
let compare_int _ _ = 0
type t = int [@@deriving compare]

Here is the output

ocamlfind ocamlopt -package ppx_jane example.ml -verbose
Effective set of compiler predicates: pkg_base.base_internalhash_types,pkg_base.caml,pkg_base.shadow_stdlib,pkg_sexplib0,pkg_base,pkg_fieldslib,pkg_ppx_compare.runtime-lib,pkg_ppx_enumerate.runtime-lib,pkg_ppx_sexp_conv.runtime-lib,pkg_ppx_hash.runtime-lib,pkg_ppx_here.runtime-lib,pkg_ppx_assert.runtime-lib,pkg_ppx_bench.runtime-lib,pkg_ppx_inline_test.config,pkg_jane-street-headers,pkg_time_now,pkg_ppx_inline_test.runtime-lib,pkg_splittable_random,pkg_base_quickcheck,pkg_base.md5,pkg_unix,pkg_bigarray,pkg_variantslib,pkg_bin_prot.shape,pkg_bin_prot,pkg_ppx_expect.common,pkg_ppx_expect.config_types,pkg_ppx_expect.collector,pkg_ppx_expect.config,pkg_stdio,pkg_ppx_module_timer.runtime,pkg_typerep,pkg_ppx_jane,autolink,native
+ ocamlopt.opt -verbose -I /home/ivg/.opam/4.09.0/lib/base/base_internalhash_types -I /home/ivg/.opam/4.09.0/lib/base/caml -I /home/ivg/.opam/4.09.0/lib/base/shadow_stdlib -I /home/ivg/.opam/4.09.0/lib/sexplib0 -I /home/ivg/.opam/4.09.0/lib/base -I /home/ivg/.opam/4.09.0/lib/fieldslib -I /home/ivg/.opam/4.09.0/lib/ppx_compare/runtime-lib -I /home/ivg/.opam/4.09.0/lib/ppx_enumerate/runtime-lib -I /home/ivg/.opam/4.09.0/lib/ppx_sexp_conv/runtime-lib -I /home/ivg/.opam/4.09.0/lib/ppx_hash/runtime-lib -I /home/ivg/.opam/4.09.0/lib/ppx_here/runtime-lib -I /home/ivg/.opam/4.09.0/lib/ppx_assert/runtime-lib -I /home/ivg/.opam/4.09.0/lib/ppx_bench/runtime-lib -I /home/ivg/.opam/4.09.0/lib/ppx_inline_test/config -I /home/ivg/.opam/4.09.0/lib/jane-street-headers -I /home/ivg/.opam/4.09.0/lib/time_now -I /home/ivg/.opam/4.09.0/lib/ppx_inline_test/runtime-lib -I /home/ivg/.opam/4.09.0/lib/splittable_random -I /home/ivg/.opam/4.09.0/lib/base_quickcheck -I /home/ivg/.opam/4.09.0/lib/base/md5 -I /home/ivg/.opam/4.09.0/lib/variantslib -I /home/ivg/.opam/4.09.0/lib/bin_prot/shape -I /home/ivg/.opam/4.09.0/lib/bin_prot -I /home/ivg/.opam/4.09.0/lib/ppx_expect/common -I /home/ivg/.opam/4.09.0/lib/ppx_expect/config_types -I /home/ivg/.opam/4.09.0/lib/ppx_expect/collector -I /home/ivg/.opam/4.09.0/lib/ppx_expect/config -I /home/ivg/.opam/4.09.0/lib/stdio -I /home/ivg/.opam/4.09.0/lib/ppx_module_timer/runtime -I /home/ivg/.opam/4.09.0/lib/typerep -I /home/ivg/.opam/4.09.0/lib/ppx_jane -ppx "/home/ivg/.opam/4.09.0/lib/ppx_jane/./ppx.exe --as-ppx" example.ml
+ /home/ivg/.opam/4.09.0/lib/ppx_jane/./ppx.exe --as-ppx '/tmp/camlppxd6b65d' '/tmp/camlppx220929'
+ as  -o 'example.o' '/tmp/camlasmf70817.s'
File "example.ml", line 1:
Error: No implementations provided for the following modules:
         Ppx_module_timer_runtime referenced from example.cmx
ocamlopt.opt returned with exit code 2

@drvink
Copy link

drvink commented Nov 7, 2020

This works:

arch-vm[990]:~/hober% cat example.ml
let compare_int _ _ = 0
type t = int [@@deriving compare]
arch-vm[991]:~/hober% ocamlfind opt -package ppx_compare example.ml
arch-vm[992]:~/hober%

ocamlfind opt -package ppx_jane -linkpkg example.ml also works, so I guess ppx_jane is bringing in some unnecessary dependency.

kit-ty-kate pushed a commit to ocaml/opam-repository that referenced this issue Nov 7, 2020
This package is merely a copy of the ppx_jane with an amended set of
ppx rewriters, namely with the ppx_js_style removed, which makes it
impossible to use ppx_jane (and ppx_base) especially when the code is
generated, e.g., when the `findlib.dynload` library is used together
with ocamlfind, which requires the inclusion of a generated code that
triggers a fatal warning in ppx_js_style. We provided [a fix][1] for
that, which was ignored. Another example, is code generated by various
protocol compilers, namely piqi-ocaml, for which we also provided a
[fix][2] that got merged but was never released. In other words,
ppx_js_style is applying itself to the code that neither belongs to
Jane Street nor even to a user of the ppx_jane rewriter.

We have [been asking Jane Street][5] to remove ppx_js_style for a long
time but we were just ignored (no replies in 5 months). Therefore we
decided to create our own package with the set of ppx rewriters that
we use in BAP (which also solves another issue associated with
[ppx_jane][6]).

Once this package is merged we can move BAP to the newest versions of
OCaml, up to 4.11.1, see [the PR to BAP][5].

[1]: ocaml/ocamlfind#9
[2]: alavrik/piqi-ocaml#15
[3]: janestreet/ppx_jane#5
[4]: janestreet/ppx_jane#6
[5]: BinaryAnalysisPlatform/bap#1116
@github-iron github-iron added the forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system. label Nov 25, 2020
@v-gb
Copy link

v-gb commented Jan 14, 2021

Hum, the command line contains /home/ivg/.opam/4.09.0/lib/ppx_module_timer/runtime which is correct. However the command line does both compilation and linking, but it contains no cmxa for ppx_module_timer_runtime or anything else, so that can't work.

I don't know anything about ocamlfind, so I have no idea if you should provide more flags to it, or it doesn't support this kind of stuff, or some ocamlfind metadata is incorrect. Is using dune not an option? It would surely get this right.

@ivg
Copy link
Author

ivg commented Jan 14, 2021

Oops, sorry forgot to close it. Indeed, as @drvink pointed out, in order to link the runtime libraries the -linkpkg option is necessary.

For anyone who's stumbling with this linker error the correct invocation is,

ocamlfind ocamlopt -package ppx_jane -linkpkg example.ml

@ivg ivg closed this as completed Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.
Projects
None yet
Development

No branches or pull requests

4 participants