scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.89k stars 1.06k forks source link

build issue: compiler sources invalidated on sbt restart #19891

Closed lrytz closed 7 months ago

lrytz commented 8 months ago

I'm getting incremental compilation invalidated each time I start sbt.

So I run scala3-compiler/compile, then in the same session scala3-compiler/compile again does nothing as expected. But when I restart sbt I'm seeing compiling 11 Scala sources and then iteratively the entire project is recompiled.

sbt -debug shows

[debug] Invalidating '${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SimpleReporter.class' because ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SimpleReporter.class (farm(7c237075c92554f0)) != ${BASE}/interfaces/target/classes (absent)
[debug] Invalidating '${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SourcePosition.class' because ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SourcePosition.class (farm(61cada7333c6304e)) != ${BASE}/interfaces/target/classes (absent)
[debug] Invalidating '${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/CompilerCallback.class' because ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/CompilerCallback.class (farm(d453791edbb4746a)) != ${BASE}/interfaces/target/classes (absent)
[debug] Invalidating '${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/Diagnostic.class' because ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/Diagnostic.class (farm(fda0d1be9c77d054)) != ${BASE}/interfaces/target/classes (absent)
[debug] Invalidating '${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/DiagnosticRelatedInformation.class' because ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/DiagnosticRelatedInformation.class (farm(13ddc868943fe1)) != ${BASE}/interfaces/target/classes (absent)
[debug] Invalidating '${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/AbstractFile.class' because ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/AbstractFile.class (farm(9d6b19b87ec7bd3f)) != ${BASE}/interfaces/target/classes (absent)
[debug] Invalidating '${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/ReporterResult.class' because ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/ReporterResult.class (farm(3b8ade7409fd6eab)) != ${BASE}/interfaces/target/classes (absent)
[debug] Invalidating '${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SourceFile.class' because ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SourceFile.class (farm(42f57a64cdf31dc1)) != ${BASE}/interfaces/target/classes (absent)
[debug] > initialChanges = InitialChanges(Changes(added = Set(), removed = Set(), changed = Set(), unmodified = ...),Set(),Set(${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/DiagnosticRelatedInformation.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SimpleReporter.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/Diagnostic.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SourceFile.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/CompilerCallback.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/AbstractFile.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/ReporterResult.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SourcePosition.class),API Changes: Set())
[debug]
[debug] Initial source changes:
[debug]     removed: Set()
[debug]     added: Set()
[debug]     modified: Set()
[debug] Invalidated products: Set()
[debug] External API changes: API Changes: Set()
[debug] Modified binary dependencies: Set(${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/DiagnosticRelatedInformation.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SimpleReporter.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/Diagnostic.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SourceFile.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/CompilerCallback.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/AbstractFile.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/ReporterResult.class, ${BASE}/interfaces/target/classes/dotty/tools/dotc/interfaces/SourcePosition.class)
[debug] Initial directly invalidated classes: Set()
[debug] Sources indirectly invalidated by:
[debug]     product: Set()
[debug]     binary dep: Set(${BASE}/compiler/src/dotty/tools/backend/jvm/GenBCode.scala, ${BASE}/compiler/src/dotty/tools/backend/jvm/CodeGen.scala, ${BASE}/compiler/src/dotty/tools/dotc/semanticdb/DiagnosticOps.scala, ${BASE}/compiler/src/dotty/tools/dotc/util/SourcePosition.scala, ${BASE}/compiler/src/dotty/tools/dotc/Driver.scala, ${BASE}/compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala, ${BASE}/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala, ${BASE}/compiler/src/dotty/tools/dotc/reporting/Reporter.scala, ${BASE}/compiler/src/dotty/tools/dotc/core/Contexts.scala, ${BASE}/compiler/src/dotty/tools/dotc/util/SourceFile.scala, ${BASE}/compiler/src/dotty/tools/repl/ReplDriver.scala)
[debug]     external source: Set()
[debug] All initially invalidated classes: Set()
[debug] All initially invalidated sources:Set(${BASE}/compiler/src/dotty/tools/backend/jvm/GenBCode.scala, ${BASE}/compiler/src/dotty/tools/backend/jvm/CodeGen.scala, ${BASE}/compiler/src/dotty/tools/dotc/semanticdb/DiagnosticOps.scala, ${BASE}/compiler/src/dotty/tools/dotc/util/SourcePosition.scala, ${BASE}/compiler/src/dotty/tools/dotc/Driver.scala, ${BASE}/compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala, ${BASE}/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala, ${BASE}/compiler/src/dotty/tools/dotc/reporting/Reporter.scala, ${BASE}/compiler/src/dotty/tools/dotc/core/Contexts.scala, ${BASE}/compiler/src/dotty/tools/dotc/util/SourceFile.scala, ${BASE}/compiler/src/dotty/tools/repl/ReplDriver.scala)
SethTisue commented 8 months ago

might interest @Friendseeker ? though anyone who wants to look into it should go right ahead

Friendseeker commented 8 months ago

might interest @Friendseeker ? though anyone who wants to look into it should go right ahead

Sure! Due to my personal circumstance (As a 4th year Canadian undergrad student studying & SWE job searching in a post-apocalyptic job market), I am in a time management crisis right now. But I will work on it as soon as I am free.

lrytz commented 7 months ago

I can't reproduce the issue right now, so maybe this resolved itself, or it was something on my machine?

adpi2 commented 3 months ago

I was still having the bug on the latest commit, but it went away after I did a git clean -dfx.

It seems that Zinc didn't want to recompile scala3-interfaces, but its analysis was invalidating everything that depended on it. So cleaning scala3-interfaces should fix the issue.