Skip to content

Add cmt files to public_cmi dir - #4905

Closed
voodoos wants to merge 3 commits into
ocaml:mainfrom
voodoos:cmt-in-public-dir
Closed

voodoos wants to merge 3 commits into
ocaml:mainfrom
voodoos:cmt-in-public-dir

Conversation

@voodoos

@voodoos voodoos commented Sep 8, 2021

Copy link
Copy Markdown
Collaborator

Fixes #4892

When private modules are used Dune hides corresponding cm files from Merlin by not adding the bytes folder to the build path. Exposed modules cm files are placed in a special public_cmi directory which is added to Merlin's build path.

However this directory was missing cmt[i] files causing Merlin's locate command to fail.

This PR enable the symlinking of cmt[i]s files into the public_cmi directory along with the cmi files.

@bobot

bobot commented Sep 8, 2021 •

Copy link
Copy Markdown
Contributor

Do we already play with symlink in this part of the code? Would it be simpler to just put the cmt[i] directly there? Oh no 💭 is it because we don't choose where the compiler put the files?

@voodoos

voodoos commented Sep 8, 2021

Copy link
Copy Markdown
Collaborator Author

Do we already play with symlink in this part of the code?

Yes, cmi files were already symlinked before when using private modules.

is it because we don't choose where the compiler put the files?

I am not sure but it looks like the compiler doesn't allow to specify different paths for different artefacts so that might be the case.

Command.Args.S
[ iflags libs Byte
; Hidden_deps (Lib_file_deps.deps libs ~groups:[ Cmi ])
; Hidden_deps (Lib_file_deps.deps libs ~groups:[ Cmi; Cmt; Cmti ])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong to me. if something depends on x, it does not mean we need to build x's cmt's and cmti's. Why are we adding the dependency here?

@voodoos voodoos Sep 13, 2021 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, the Cmts are built as soon as a compilation context has the bin_annot field set to true which appear to be the case for every CC used in Dune except for Menhir and when building ppx_driver.

So the cmts are already always built by Dune isn't it ? However I should add a check that the current CC has the bin_annot field set to true.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, cmt's are essentially always built by dune.

However I should add a check that the current CC has the bin_annot field set to true.

I'm not sure why you need this check. Sometimes the cmt's are explicitly turned off for some internally generated modules. That's about the only time when bin_annot is set to false.

@rgrinberg

Copy link
Copy Markdown
Member

@voodoos can we revive this PR?

Also, what about an alternative fix for this issue: making the byte directory always visible to merlin. Are there any downsides to exposing all the private modules to merlin?

@rgrinberg rgrinberg added the merlin Merlin editor support and its interface with dune label May 15, 2022
@voodoos

voodoos commented May 16, 2022

Copy link
Copy Markdown
Collaborator Author

making the byte directory always visible to merlin

If I understand way the current behaviour it would defeat the purpose of the public_cmi which is to hide from Merlin the artefact of "private" modules.

@rgrinberg

Copy link
Copy Markdown
Member

The purpose of the public_cmi is to hide it from the user. There's no goal of hiding anything from merlin.

@rgrinberg

Copy link
Copy Markdown
Member

Replaced by #6405

@rgrinberg rgrinberg closed this Nov 8, 2022
anmonteiro added a commit that referenced this pull request Aug 18, 2026
…odules (#15977)

Expose dependency object directories to Merlin as annotation-only CMT
paths. CMT paths have no bearing on auto-completion, but will still
allow locate to work.

Fixes #4892. Follows #15972.


This is an alternative to these:

- #4905
- #6405

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merlin Merlin editor support and its interface with dune

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Private modules cause missing build path (in the ocaml-merlin dump)

3 participants