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

per_module breaks .merlin output #1212

Closed
dra27 opened this issue Sep 2, 2018 · 25 comments
Closed

per_module breaks .merlin output #1212

dra27 opened this issue Sep 2, 2018 · 25 comments

Comments

@dra27
Copy link
Member

dra27 commented Sep 2, 2018

For the following dune file:

(library
  (name       Mercury)
  (preprocess (per_module ((pps ppx_pgsql) Mercury)))
  (modules    Mercury)
  (libraries  pgocaml))

Merlin doesn't load the PPX for Mercury.ml. If I change the preprocess stanza to just (pps ppx_pgsql) then .merlin gains the required:

FLG -ppx '/home/dra/ocamldefang/_build/default/.ppx/ppx_pgsql/ppx.exe --as-ppx --cookie '\''library-name="Mercury"'\'''
@rgrinberg
Copy link
Member

This is a known issue. We could improve the approximation of the merlin command by taking the union of ppx preprocessors, but we've been kind of dragging our feet on this stuff as we'd really like to see this issue fixed once and for all. Feel free to add a workaround for this for now if it's blocking you.

@trefis do we have an ETA on the new merlin interface?

@gares
Copy link
Contributor

gares commented Apr 15, 2019

Is there an open issue in the merlin issue tracker for this specific need? I could not find it, maybe we should add one?

@ghost
Copy link

ghost commented Apr 15, 2019

opening such an issue makes sense

@trefis
Copy link
Collaborator

trefis commented Sep 23, 2020

The new merlin interface is released, and I believe @voodoos is working on (and might already be done) improving this particular point on the dune side.

rgrinberg added a commit to rgrinberg/opam-repository that referenced this issue Jan 13, 2021
…ne-action-plugin, dune-private-libs and dune-glob (2.8.0)

CHANGES:

- `dune rules` accepts aliases and other non-path rules (ocaml/dune#4063, @mrmr1993)

- Action `(diff reference test_result)` now accept `reference` to be absent and
  in that case consider that the reference is empty. Then running `dune promote`
  will create the reference file. (ocaml/dune#3795, @bobot)

- Ignore special files (BLK, CHR, FIFO, SOCKET), (ocaml/dune#3570, fixes ocaml/dune#3124, ocaml/dune#3546,
  @ejgallego)

- Experimental: Simplify loading of additional files (data or code) at runtime
  in programs by introducing specific installation sites. In particular it allow
  to define plugins to be installed in these sites. (ocaml/dune#3104, ocaml/dune#3794, fixes ocaml/dune#1185,
  @bobot)

- Move all temporary files created by dune to run actions to a single directory
  and make sure that actions executed by dune also use this directory by setting
  `TMPDIR` (or `TEMP` on Windows). (ocaml/dune#3691, fixes ocaml/dune#3422, @rgrinberg)

- Fix bootstrap script with custom configuration. (ocaml/dune#3757, fixes ocaml/dune#3774, @marsam)

- Add the `executable` field to `inline_tests` to customize the compilation
  flags of the test runner executable (ocaml/dune#3747, fixes ocaml/dune#3679, @lubegasimon)

- Add `(enabled_if ...)` to `(copy_files ...)` (ocaml/dune#3756, @nojb)

- Make sure Dune cleans up the status line before exiting (ocaml/dune#3767,
  fixes ocaml/dune#3737, @alan-j-hu)

- Add `{gitlab,bitbucket}` as options for defining project sources with `source`
  stanza `(source (<host> user/repo))` in the `dune-project` file.  (ocaml/dune#3813,
  @rgrinberg)

- Fix generation of `META` and `dune-package` files when some targets (byte,
  native, dynlink) are disabled. Previously, dune would generate all archives
  for regardless of settings. (ocaml/dune#3829, ocaml/dune#4041, @rgrinberg)

- Do not run ocamldep to for single module executables & libraries. The
  dependency graph for such artifacts is trivial (ocaml/dune#3847, @rgrinberg)

- Fix cram tests inside vendored directories not being interpreted correctly.
  (ocaml/dune#3860, fixes ocaml/dune#3843, @rgrinberg)

- Add `package` field to private libraries. This allows such libraries to be
  installed and to be usable by other public libraries in the same project
  (ocaml/dune#3655, fixes ocaml/dune#1017, @rgrinberg)

- Fix the `%{make}` variable on Windows by only checking for a `gmake` binary
  on UNIX-like systems as a unrelated `gmake` binary might exist on Windows.
  (ocaml/dune#3853, @kit-ty-kate)

- Fix `$ dune install` modifying the build directory. This made the build
  directory unusable when `$ sudo dune install` modified permissions. (fix
  ocaml/dune#3857, @rgrinberg)

- Fix handling of aliases given on the command line (using the `@` and `@@`
  syntax) so as to correctly handle relative paths. (ocaml/dune#3874, fixes ocaml/dune#3850, @nojb)

- Allow link time code generation to be used in preprocessing executable. This
  makes it possible to use the build info module inside the preprocessor.
  (ocaml/dune#3848, fix ocaml/dune#3848, @rgrinberg)

- Correctly call `git ls-tree` so unicode files are not quoted, this fixes
  problems with `dune subst` in the presence of unicode files. Fixes ocaml/dune#3219
  (ocaml/dune#3879, @ejgallego)

- `dune subst` now accepts common command-line arguments such as
  `--debug-backtraces` (ocaml/dune#3878, @ejgallego)

- `dune describe` now also includes information about executables in addition to
  that of libraries. (ocaml/dune#3892, ocaml/dune#3895, @nojb)

- instrumentation backends can now receive arguments via `(instrumentation
  (backend <name> <args>))`. (ocaml/dune#3906, ocaml/dune#3932, @nojb)

- Tweak auto-formatting of `dune` files to improve readability. (ocaml/dune#3928, @nojb)

- Add a switch argument to opam when context is not default. (ocaml/dune#3951, @tmattio)

- Avoid pager when running `$ git diff` (ocaml/dune#3912, @AltGr)

- Add `(root_module ..)` field to libraries & executables. This makes it
  possible to use library dependencies shadowed by local modules (ocaml/dune#3825,
  @rgrinberg)

- Allow `(formatting ...)` field in `(env ...)` stanza to set per-directory
  formatting specification. (ocaml/dune#3942, @nojb)

- [coq] In `coq.theory`, `:standard` for the `flags` field now uses the
  flags set in `env` profile flags (ocaml/dune#3931 , @ejgallego @rgrinberg)

- [coq] Add `-q` flag to `:standard` `coqc` flags , fixes ocaml/dune#3924, (ocaml/dune#3931 , @ejgallego)

- Add support for Coq's native compute compilation mode (@ejgallego, ocaml/dune#3210)

- Add a `SUFFIX` directive in `.merlin` files for each dialect with no
  preprocessing, to let merlin know of additional file extensions (ocaml/dune#3977,
  @vouillon)

- Stop promoting `.merlin` files. Write per-stanza Merlin configurations in
  binary form. Add a new subcommand `dune ocaml-merlin` that Merlin can use to
  query the configuration files. The `allow_approximate_merlin` option is now
  useless and deprecated. Dune now conflicts with `merlin < 3.4.0` and
  `ocaml-lsp-server < 1.3.0` (ocaml/dune#3554, @voodoos)

- Configurator: fix a bug introduced in 2.6.0 where the configurator V1 API
  doesn't work at all when used outside of dune. (ocaml/dune#4046, @aalekseyev)

- Fix `libexec` and `libexec-private` variables. In cross-compilation settings,
  they now point to the file in the host context. (ocaml/dune#4058, fixes ocaml/dune#4057,
  @TheLortex)

- When running `$ dune subst`, use project metadata as a fallback when package
  metadata is missing. We also generate a warning when `(name ..)` is missing in
  `dune-project` files to avoid failures in production builds.

- Remove support for passing `-nodynlink` for executables. It was bypassed in
  most cases and not correct in other cases in particular on arm32.
  (ocaml/dune#4085, fixes ocaml/dune#4069, fixes ocaml/dune#2527, @emillon)

- Generate archive rules compatible with 4.12. Dune longer attempt to generate
  an archive file if it's unnecessary (ocaml/dune#3973, fixes ocaml/dune#3766, @rgrinberg)

- Fix generated Merlin configurations when multiple preprocessors are defined
  for different modules in the same folder. (ocaml/dune#4092, fixes ocaml/dune#2596, ocaml/dune#1212 and
  ocaml/dune#3409, @voodoos)

- Add the option `use_standard_c_and_cxx_flags` to `dune-project` that 1.
  disables the unconditional use of the `ocamlc_cflags` and `ocamlc_cppflags`
  from `ocamlc -config` in C compiler calls, these flags will be present in the
  `:standard` set instead; and 2. enables the detection of the C compiler family
  and populates the `:standard` set of flags with common default values when
  building CXX stubs. (ocaml/dune#3875, ocaml/dune#3802, fix ocaml/dune#3718 and ocaml/dune#3528, @voodoos)
@voodoos
Copy link
Collaborator

voodoos commented Jan 14, 2021

This should be fixed in Dune 2.8. If it is not don't hesitate to warn us.

@voodoos voodoos closed this as completed Jan 14, 2021
@gares
Copy link
Contributor

gares commented Jan 16, 2021

Great thanks!

@gares
Copy link
Contributor

gares commented Jan 25, 2021

Hello, I tried to use this new feature but I can't get it to work.

This is my attempt: LPCIC/elpi#91 but if I open anything in src/*.ml then I don't get the pre-processing, e.g. data.ml is not getting [@@deriving] executed...

I'm on

gares@ollypat:~/LPCIC/elpi$ opam list | grep serv
ocaml-lsp-server         1.4.0       LSP Server for OCaml
gares@ollypat:~/LPCIC/elpi$ opam list | grep dune
dune                     2.8.2       Fast, portable, and opinionated build system
dune-build-info          2.8.2       Embed build informations inside executable
dune-configurator        2.8.2       Helper library for gathering system configuration
dune-private-libs        2.6.2       Private libraries of Dune

and I'm using vscode with ocaml-platform just installed (I had the reason thing before, since I like the syntax highlighting better, but I guess I have to switch now).

@gares
Copy link
Contributor

gares commented Jan 25, 2021

Side note: I had a single runtime.ml file and 2 copy_file directives, but apparently this does not work anymore, so I did make a symlink. I'm OK with that, just wanted to point out the change of behavior.

@voodoos
Copy link
Collaborator

voodoos commented Jan 25, 2021

@gares, thanks for trying this out, I will have a look when I have time.

It would be very useful if you could build a small, self-contained, reproduction !

@voodoos voodoos reopened this Jan 25, 2021
@gares
Copy link
Contributor

gares commented Jan 25, 2021

Hum, I can help debug but I don't know how to start. Maybe you can give a hint.
Is there a way to know which pp line is being used by ocamllsp? does it log?

@voodoos
Copy link
Collaborator

voodoos commented Jan 25, 2021

You can ask Dune to print the configurations for a source folder by calling
dune ocaml-merlin --dump-config="$(pwd)"
from this source folder. (or from elsewhere in the project with the correct path)

There is also the Merlin counterpart (i don't know if ocamllsp has a similar feature, @rgrinberg ?):
ocamlmerlin single dump-configuration -filename somefile.ml <somefile.ml | jq

And for reference there is a case in Dune test-suite for per-module config:
https://github.com/ocaml/dune/tree/main/test/blackbox-tests/test-cases/merlin/per-module-pp.t

@gares
Copy link
Contributor

gares commented Jan 25, 2021

My dune file has

  (preprocess (per_module
    ((action (run %{project_root}/ppxfindcache/ppxfindcache2.exe %{input-file}
                    --cache-file %{dep:.ppcache/API.ml}
                    --cache-file %{dep:.ppcache/API.mli}
                    --cache-file %{dep:.ppcache/util.ml}
                    --cache-file %{dep:.ppcache/util.mli}
                    --cache-file %{dep:.ppcache/ast.ml}
                    --cache-file %{dep:.ppcache/ast.mli}
                    --cache-file %{dep:.ppcache/data.ml}
                    --cache-file %{dep:.ppcache/compiler.ml}
                    --cache-file %{dep:.ppcache/compiler.mli}))
              API ast data compiler)

and the dump (for Data) is

Data
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))

@gares
Copy link
Contributor

gares commented Jan 25, 2021

I was expecting to see FLG (-pp .../ppxfindcache/ppxfindcache2.exe ....), which is not there, and explains why I don't get pre-processing in vscode.

@gares
Copy link
Contributor

gares commented Jan 25, 2021

Note that directories about the ppx I link in ppxfindcache2.exe are there:

 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)

For reference:

(executable
  (name ppxfindcache2)
  (modules ppxfindcache2)
  (libraries unix re ppxfindcache_aux
    (select ppxfindcache2.ml from
      (ppx_deriving.std -> ppxfindcache2.useppx.ml)  % HERE
      (-> ppxfindcache2.cacheonly.ml)))
  (flags -linkall))

@rgrinberg
Copy link
Member

I was expecting to see FLG (-pp .../ppxfindcache/ppxfindcache2.exe ....), which is not there, and explains why I don't get pre-processing in vscode.

This used to be supported in .merlin files. So this seems like a regression indeed.

@voodoos
Copy link
Collaborator

voodoos commented Jan 26, 2021

@gares, can you post the complete output of the configuration dump ?
I am wondering if the (FLG (-pp directives are also absent from the other modules selected in the per_module directive.

(In the Dune test case for the per_module merlin config which is simpler but similar to your project the -pp flag is added as expected.)

@gares
Copy link
Contributor

gares commented Jan 26, 2021

It is present for the parser, which calls camlp5.

    ((action (run camlp5o -I . -I +camlp5 pa_extend.cmo pa_lexer.cmo %{input-file})) parser)

Here the full output:

gares@ollypat:~/LPCIC/elpi/src$ dune ocaml-merlin --dump-config="$(pwd)"
Entering directory '/home/gares/LPCIC/elpi'
Util
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Runtime_trace_on
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Runtime_trace_off
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Ptmap
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Ppx_deriving_runtime_proxy
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Parser
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG
  (-pp
   "/home/gares/.opam/4.07.1/bin/camlp5o
   -I
   .
   -I
   +camlp5
   pa_extend.cmo
   pa_lexer.cmo"))
 (FLG (-open Elpi__ -linkall)))
Elpi
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Data
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Compiler
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Builtin_stdlib
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Builtin_set
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Builtin_map
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Builtin_checker
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Builtin
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Ast
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
API
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))
Elpi__
((EXCLUDE_QUERY_DIR)
 (B /home/gares/.opam/4.07.1/lib/camlp5)
 (B /home/gares/.opam/4.07.1/lib/ocaml)
 (B /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (B /home/gares/.opam/4.07.1/lib/re)
 (B /home/gares/.opam/4.07.1/lib/re/str)
 (B /home/gares/.opam/4.07.1/lib/result)
 (B /home/gares/.opam/4.07.1/lib/seq)
 (B /home/gares/LPCIC/elpi/_build/default/src/.elpi.objs/byte)
 (B
  /home/gares/LPCIC/elpi/_build/default/trace/runtime/.trace_ppx_runtime.objs/byte)
 (S /home/gares/.opam/4.07.1/lib/camlp5)
 (S /home/gares/.opam/4.07.1/lib/ocaml)
 (S /home/gares/.opam/4.07.1/lib/ppx_deriving/runtime)
 (S /home/gares/.opam/4.07.1/lib/re)
 (S /home/gares/.opam/4.07.1/lib/re/str)
 (S /home/gares/.opam/4.07.1/lib/result)
 (S /home/gares/.opam/4.07.1/lib/seq)
 (S /home/gares/LPCIC/elpi/src)
 (S /home/gares/LPCIC/elpi/trace/runtime)
 (FLG (-open Elpi__ -linkall)))

@voodoos
Copy link
Collaborator

voodoos commented Jan 27, 2021

@gares That makes little sense but it looks like putting the %{input-file} at the end of the command line make the flag appear in the Merlin configuration:

(preprocess (per_module
    ((action (run %{project_root}/ppxfindcache/ppxfindcache2.exe
                    --cache-file %{dep:.ppcache/API.ml}
                    --cache-file %{dep:.ppcache/API.mli}
                    --cache-file %{dep:.ppcache/util.ml}
                    --cache-file %{dep:.ppcache/util.mli}
                    --cache-file %{dep:.ppcache/ast.ml}
                    --cache-file %{dep:.ppcache/ast.mli}
                    --cache-file %{dep:.ppcache/data.ml}
                    --cache-file %{dep:.ppcache/compiler.ml}
                    --cache-file %{dep:.ppcache/compiler.mli}
                    %{input-file}))
              API ast data compiler)
    ((action (run %{project_root}/ppxfindcache/ppxfindcache.exe
                    --ppx-opt --cookie
                    --ppx-opt "elpi_trace=\"true\""
                    --cache-file %{dep:.ppcache/runtime_trace_on.ml}
                    --cache-file %{dep:.ppcache/runtime_trace_on.mli}
                    %{input-file}))
              runtime_trace_on)
    ((action (run %{project_root}/ppxfindcache/ppxfindcache.exe
                    --ppx-opt --cookie
                    --ppx-opt "elpi_trace=\"false\""
                    --cache-file %{dep:.ppcache/runtime_trace_off.ml}
                    --cache-file %{dep:.ppcache/runtime_trace_off.mli}
                     %{input-file}))
              runtime_trace_off)
    ((action (run camlp5o -I . -I +camlp5 pa_extend.cmo pa_lexer.cmo %{input-file})) parser)
    ))

Can you try it ?

@rgrinberg do you have an idea why the order of the parameters could be of significance here ?

@gares
Copy link
Contributor

gares commented Jan 27, 2021

Thanks @voodoos ! I would have never guessed this work around. Now I get my [%extensions] processed.

There is still a glitch, if you open src/runtime_trace_on.ml (or _off.ml) you get an error on the first line (which is a comment):
"This expression has type int but an expression was expected of type bool ocamllsp"

Is this related to the ppx handling?

EDIT: I spoke too early, I get that error on all files, even in src/parser.ml, so I guess it's not my ppx but the way it is invoked.

@gares
Copy link
Contributor

gares commented Jan 27, 2021

Actually I get errors like Unbound Constructor Caml1999M023 so I guess "merlin" expects some text and not a marshaled AST?

@voodoos
Copy link
Collaborator

voodoos commented Jan 27, 2021

Actually I get errors like Unbound Constructor Caml1999M023 so I guess "merlin" expects some text and not a marshaled AST?

I need to summon other magicians to answer that: @trefis, @let-def ?

@gares
Copy link
Contributor

gares commented Jan 27, 2021

OK, I understood a bit more: all run are commands that generate marshaled AST, but merlin gets a -pp option (and not a -ppx).

I don't know if run is expected to return sources, or is allowed to return both source and AST, but you assume source (hence you pick -pp for merlin). I guess you generate -ppx for pps directives.

Is there a way I can ask for a -ppx directive in the merlin conf file even if the ppx is run via run and not pps?

@gares
Copy link
Contributor

gares commented Jan 27, 2021

FTR ppxfindcache.exe is a thing of mine which does call a standard pps behind the scenes but also does other things like also saving the source of the generated AST on the side. I don't think I can turn it into a regular pps without major hacks.

@rgrinberg
Copy link
Member

do you have an idea why the order of the parameters could be of significance here ?

Because the way we handle action preprocessors are a hack. There's no way to pass a general action to merlin, so we do a best effort of converting an action to something that can be passed to merlin.

@voodoos
Copy link
Collaborator

voodoos commented Jan 28, 2021

So to sum-up:

  1. The ordering issue is due to the "best effort of converting an action to something that can be passed to merlin". We should at least mention it in the documentation, but a real improvement would be to have a better way to pass actions to Merlin.
  2. You have a PPS in disguise that you run with run and apparently Dune wrongly assumes it is outputting text (by opposition to marshaled AST). I feel like you should open a new issue about this... or try a less exotic setup :-)

Modulo 1, it seems that per-module configuration is working as expected, and we should close this issue and move the discussion elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants