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

semanticdb files are deleted on every compilation #3077

Closed
lolgab opened this issue Mar 11, 2024 · 7 comments · Fixed by #3080
Closed

semanticdb files are deleted on every compilation #3077

lolgab opened this issue Mar 11, 2024 · 7 comments · Fixed by #3080
Labels
bug The issue represents an bug
Milestone

Comments

@lolgab
Copy link
Member

lolgab commented Mar 11, 2024

When using metals I noticed that the semanticdb files where deleted on every compilation and the out/semanticDbData.dest/data/META-INF/semanticdb/src/main/scala/app contained only the file from the last compilation.
I don't know if this has negative consequences for Metals but it doesn't seem right.
Files are deleted here

@lefou
Copy link
Member

lefou commented Mar 11, 2024

IIRC, that target dir gets recreated (by copying) from another directory, which is managed by zinc. So, even when compiling incrementally, it should contain the full set of files. I might be mistaken though. I'll review the code and the tests. Maybe, something (seemingly unrelated) has changed?

@lefou
Copy link
Member

lefou commented Mar 11, 2024

To check:

  • Is recreation of the directory an issue? Can we add/replace/remove per files instead by the whole directory?
  • Is the set of semanticDb files complete, even after incremental compilation?
  • Do Java / Scala / Mixed modules behave equally?

@lefou
Copy link
Member

lefou commented Mar 11, 2024

@lolgab Do you already have a reproducer by any chance?

@lefou
Copy link
Member

lefou commented Mar 11, 2024

I wrote incremental tests, but couldn't reproduce any issues with missing files yet.

@lefou
Copy link
Member

lefou commented Mar 12, 2024

Looks like my tests never compile incrementally, although they should.

@lolgab lolgab added the bug The issue represents an bug label Mar 24, 2024
@lolgab
Copy link
Member Author

lolgab commented Mar 24, 2024

This also breaks Scalafix when used together with incremental compilation. It works again after running mill clean.

@lefou
Copy link
Member

lefou commented Apr 25, 2024

I identified some issue but also found some possible bugs, e.g. we moved files instead of copied them. I fixed the copy issue in PR #3080.

Here are the other issues:

Here are some issues I identified with our current approach to generate semanticdb data in a Scala 2.13 module:

  • When we stop scalac after phase semanticdb-typer, zinc is not able to incrementally compile the next round, therefore we currently always generate all semanticdb files in each run

  • If we don't stop scalac after phase semanticdb-typer, we can generate semanticdb data incrementally, but we also unnecessarily compile all scala files to class files

  • Incremental compilation doesn't seem to clean semanticdb files for removed sources. So, we need to manually remove those that belong to non-existing source files

lefou added a commit that referenced this issue Apr 25, 2024
Added incremental test for `JavaModule.semanticDbData` and
`ScalaModule.semanticDbData`. Looks like zinc isn't compiling
incrementally at all when we stop at an early compiler phase. The test
don't really catch that, yet. But I also found a bug where we moved
files instead of copying them.

Fix #3077

Pull request: #3080
@lefou lefou added this to the 0.11.8 milestone Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue represents an bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants