mill icon indicating copy to clipboard operation
mill copied to clipboard

Incremental meta-build compile issues

Open lefou opened this issue 6 months ago • 3 comments

After changing a scalacOptions in a trait in the meta-build, I see a strange compile error. Example taken from Mill repo itself.

> mill --version
Mill Build Tool version 1.0.0-RC1
Java version: 17.0.14, vendor: Azul Systems, Inc., runtime: /home/lefou/.cache/coursier/arc/https/cdn.azul.com/zulu/bin/zulu17.56.15-ca-jdk17.0.14-linux_x64.tar.gz/zulu17.56.15-ca-jdk17.0.14-linux_x64
Default locale: de_DE, platform encoding: UTF-8
OS name: "Linux", version: 6.6.74-gentoo-x86_64, arch: amd64

> mill core.__.compile
...

> cat <<EOF | patch -p1
diff --git a/mill-build/src/millbuild/MillScalaModule.scala b/mill-build/src/millbuild/MillScalaModule.scala
index b06b535e054..9db5ac0e6ad 100644
--- a/mill-build/src/millbuild/MillScalaModule.scala
+++ b/mill-build/src/millbuild/MillScalaModule.scala
@@ -30,6 +30,7 @@ trait MillScalaModule extends ScalaModule with MillJavaModule /* with ScalafixMo
       "-feature"
     ) ++ (
       if (JvmWorkerUtil.isScala3(scalaVersion())) Seq(
+        "-explain-cyclic",
         // "-Werror",
         "-Wunused:all",
         // "-Xfatal-warnings",
EOF

> mill core.__.compile
[build.mill-63/68] compile
[build.mill-63] [info] compiling 1 Scala source to /home/lefou/work/opensource/mill/out/mill-build/compile.dest/classes ...
[build.mill-63] [error] -- [E164] Declaration Error: /home/lefou/work/opensource/mill/mill-build/src/millbuild/MillScalaModule.scala:85:8 
[build.mill-63] [error] 85 |  trait MillScalaTests extends ScalaTests with MillJavaModule with MillBaseTestsModule
[build.mill-63] [error]    |        ^
[build.mill-63] [error]    |error overriding method repositoriesTask in trait JavaTests of type => mill.define.Task[Seq[coursier.Repository]];
[build.mill-63] [error]    |  method repositoriesTask² in trait MillJavaModule of type => mill.define.Task[Seq[coursier.Repository]] trait MillScalaTests inherits conflicting members:
[build.mill-63] [error]    |  method repositoriesTask in trait JavaTests of type => mill.define.Task[Seq[coursier.Repository]]  and
[build.mill-63] [error]    |  method repositoriesTask in trait MillJavaModule of type => mill.define.Task[Seq[coursier.Repository]]
[build.mill-63] [error]    |(Note: this can be resolved by declaring an override in trait MillScalaTests.);
[build.mill-63] [error]    |other members with override errors are:: method mapDependencies
[build.mill-63] [error]    |
[build.mill-63] [error]    |where:    repositoriesTask  is a method in trait JavaTests
[build.mill-63] [error]    |          repositoriesTask² is a method in trait MillJavaModule
[build.mill-63] [error] -- [E164] Declaration Error: /home/lefou/work/opensource/mill/mill-build/src/millbuild/MillScalaModule.scala:12:6 
[build.mill-63] [error] 12 |trait MillScalaModule extends ScalaModule with MillJavaModule /* with ScalafixModule*/ { outer =>
[build.mill-63] [error]    |      ^
[build.mill-63] [error]    |error overriding method mapDependencies in trait ScalaModule of type => mill.define.Task[coursier.Dependency => coursier.Dependency];
[build.mill-63] [error]    |  method mapDependencies in trait MillJavaModule of type => mill.define.Task[coursier.Dependency => coursier.Dependency] trait MillScalaModule inherits conflicting members:
[build.mill-63] [error]    |  method mapDependencies in trait ScalaModule of type => mill.define.Task[coursier.Dependency => coursier.Dependency]  and
[build.mill-63] [error]    |  method mapDependencies in trait MillJavaModule of type => mill.define.Task[coursier.Dependency => coursier.Dependency]
[build.mill-63] [error]    |(Note: this can be resolved by declaring an override in trait MillScalaModule.)
[build.mill-63] [error] two errors found
[68/68, 1 failed] ============================== core.__.compile ============================== 11s
1 tasks failed
compile Compilation failed

lefou avatar May 28 '25 09:05 lefou

Non-incremental builds work though.

> rm -r out/mill-*

> mill core.__.compile
[mill-build/build.mill-61/66] compile
[mill-build/build.mill-61] [info] compiling 3 Scala sources to /home/lefou/work/opensource/mill/out/mill-build/mill-build/compile.dest/classes ...
[mill-build/build.mill-61] [info] done compiling
[build.mill-63/68] compile
[build.mill-63] [info] compiling 89 Scala sources to /home/lefou/work/opensource/mill/out/mill-build/compile.dest/classes ...
[build.mill-63] [info] done compiling
...

lefou avatar May 28 '25 09:05 lefou

We've had problems with incremental compiles since upgrading to Scala 3, both in build code and application code. I suspect the bug is likely with the Zinc incremental compiler rather than anything in our codebase

lihaoyi avatar May 28 '25 10:05 lihaoyi

TODOs:

  • [ ] minify reproducer
  • [ ] report and link upstream issue

lefou avatar May 28 '25 11:05 lefou