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

Revert zinc to 1.9.6 to fix incremental compilation in the build #3751

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ object Deps {
// The Scala version to use
// When updating, run "Publish Bridges" Github Actions for the new version
// and then add to it `bridgeScalaVersions`
val scalaVersion = "2.13.14"
val scala2Version = "2.13.14"
val scalaVersion = "2.13.13"
val scala2Version = "2.13.13"
// The Scala 2.12.x version to use for some workers
val workerScalaVersion212 = "2.12.19"

val testScala213Version = "2.13.14"
val testScala213Version = "2.13.13"
// Scala Native 4.2 will not get releases for new Scala version
val testScala213VersionForScalaNative42 = "2.13.8"
val testScala212Version = "2.12.6"
Expand Down Expand Up @@ -179,7 +179,7 @@ object Deps {
val sourcecode = ivy"com.lihaoyi::sourcecode:0.3.1"
val upickle = ivy"com.lihaoyi::upickle:3.3.1"
val windowsAnsi = ivy"io.github.alexarchambault.windows-ansi:windows-ansi:0.0.5"
val zinc = ivy"org.scala-sbt::zinc:1.10.2"
val zinc = ivy"org.scala-sbt::zinc:1.9.6"
// keep in sync with doc/antora/antory.yml
val bsp4j = ivy"ch.epfl.scala:bsp4j:2.2.0-M2"
val fansi = ivy"com.lihaoyi::fansi:0.5.0"
Expand Down Expand Up @@ -416,7 +416,7 @@ trait MillScalaModule extends ScalaModule with MillJavaModule with ScalafixModul
"-feature",
"-Xlint:unused",
"-Xlint:adapted-args",
"-Xsource:3",
// "-Xsource:3",
"-Wconf:msg=inferred type changes:silent",
"-Wconf:msg=case companions no longer extend FunctionN:silent",
"-Wconf:msg=access modifiers for:silent",
Expand Down
2 changes: 2 additions & 0 deletions ci/test-mill-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ git stash pop "$(git stash list | grep "preserve mill-release" | head -n1 | sed
# Prepare local build
ci/prepare-mill-bootstrap.sh

rm -rf out

# Run tests
target/mill-release -i "__.compile"
target/mill-release -i "example.scalalib.basic[1-simple].server.test"
2 changes: 1 addition & 1 deletion example/scalalib/basic/1-simple/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package build
import mill._, scalalib._

object `package` extends RootModule with ScalaModule {
def scalaVersion = "2.13.11"
def scalaVersion = "2.13.15"
def ivyDeps = Agg(
ivy"com.lihaoyi::scalatags:0.12.0",
ivy"com.lihaoyi::mainargs:0.6.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,15 @@ object CodeSigSubfolderTests extends UtestIntegrationTestSuite {
// Changing stuff in subfolder/package.mill does not invalidate unrelated tasks in build.mill
val cached3 = eval("foo")
assert(cached3.out == "")
// This should only compile 1 source but it seems there's an upstream bug in Zinc
// https://github.com/sbt/zinc/issues/1461
assert(cached3.err.contains("compiling 2 Scala sources"))
assert(cached3.err.contains("compiling 1 Scala source"))

modifyFile(
workspacePath / "subfolder/package.mill",
_.replace("running helperFoo", "running helperFoo2")
)
val mangledHelperFoo = eval("foo")
assert(mangledHelperFoo.out.linesIterator.toSeq == Seq("running foo2", "running helperFoo2"))
// This should only compile 1 source but it seems there's an upstream bug in Zinc
// https://github.com/sbt/zinc/issues/1461
assert(mangledHelperFoo.err.contains("compiling 2 Scala sources"))
assert(mangledHelperFoo.err.contains("compiling 1 Scala source"))

// Make sure changing `val`s, which only affects the Module constructor and
// not the Task method itself, causes invalidation
Expand All @@ -68,9 +64,8 @@ object CodeSigSubfolderTests extends UtestIntegrationTestSuite {
)
val mangledValFoo = eval("foo")
assert(mangledValFoo.out.linesIterator.toSeq == Seq("running foo2", "running helperFoo2"))
// This should only compile 1 source but it seems there's an upstream bug in Zinc
// https://github.com/sbt/zinc/issues/1461
assert(mangledValFoo.err.contains("compiling 2 Scala sources"))

assert(mangledValFoo.err.contains("compiling 1 Scala source"))

// Even modifying `val`s that do not affect the task invalidates it, because
// we only know that the constructor changed and don't do enough analysis to
Expand All @@ -85,9 +80,7 @@ object CodeSigSubfolderTests extends UtestIntegrationTestSuite {
"running helperFoo2"
))

// This should only compile 1 source but it seems there's an upstream bug in Zinc
// https://github.com/sbt/zinc/issues/1461
assert(mangledValFooUsedInBar.err.contains("compiling 2 Scala sources"))
assert(mangledValFooUsedInBar.err.contains("compiling 1 Scala source"))

val cached4 = eval("foo")
assert(cached4.out == "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import mill._

def foo = { println("running foo"); build_.subfolder.package_.helperFoo }

def dummy = Task{ 1 }
def dummy = Task{ 1 }
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ object ZincBuildCompilationTests extends UtestIntegrationTestSuite {
_.replace("running helperFoo", "running helperFoo2")
)
val mangledHelperFoo = eval(("dummy"))
// This should only compile 1 source but it seems there's an upstream bug in Zinc
// https://github.com/sbt/zinc/issues/1461
assert(mangledHelperFoo.err.contains("compiling 2 Scala source"))

assert(mangledHelperFoo.err.contains("compiling 1 Scala source"))
}
}
}
2 changes: 1 addition & 1 deletion runner/src/mill/runner/MillBuildBootstrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package mill.runner

import mill.util.{ColorLogger, PrefixLogger, Watchable}
import mill.main.{BuildInfo, RootModule, RunScript}
import mill.main.client.CodeGenConstants.*
import mill.main.client.CodeGenConstants._
import mill.api.{PathRef, SystemStreams, Val, internal}
import mill.eval.Evaluator
import mill.resolve.SelectMode
Expand Down
24 changes: 7 additions & 17 deletions scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import mill.scalalib.api.{CompilationResult, Versions, ZincWorkerApi, ZincWorker
import sbt.internal.inc.{
Analysis,
CompileFailed,
FileAnalysisStore,
FreshCompilerCache,
ManagedLoggedReporter,
MappedFileConverter,
Expand All @@ -22,13 +23,10 @@ import sbt.internal.inc.{
javac
}
import sbt.internal.inc.classpath.ClasspathUtil
import sbt.internal.inc.consistent.ConsistentFileAnalysisStore
import sbt.internal.util.{ConsoleAppender, ConsoleOut}
import sbt.mill.SbtLoggerUtils
import xsbti.compile.analysis.ReadWriteMappers
import xsbti.compile.{
AnalysisContents,
AnalysisStore,
AuxiliaryClassFileExtension,
ClasspathOptions,
CompileAnalysis,
Expand Down Expand Up @@ -333,7 +331,7 @@ class ZincWorkerImpl(
def discoverMainClasses(compilationResult: CompilationResult): Seq[String] = {
def toScala[A](o: Optional[A]): Option[A] = if (o.isPresent) Some(o.get) else None

toScala(fileAnalysisStore(compilationResult.analysisFile).get())
toScala(FileAnalysisStore.binary(compilationResult.analysisFile.toIO).get())
.map(_.getAnalysis)
.flatMap {
case analysis: Analysis =>
Expand Down Expand Up @@ -474,14 +472,6 @@ class ZincWorkerImpl(
}(f)
}

private def fileAnalysisStore(path: os.Path): AnalysisStore =
ConsistentFileAnalysisStore.binary(
file = path.toIO,
mappers = ReadWriteMappers.getEmptyMappers(),
// No need to utilize more that 8 cores to serialize a small file
parallelism = math.min(Runtime.getRuntime.availableProcessors(), 8)
)

private def compileInternal(
upstreamCompileOutput: Seq[CompilationResult],
sources: Agg[os.Path],
Expand All @@ -493,7 +483,7 @@ class ZincWorkerImpl(
reportCachedProblems: Boolean,
incrementalCompilation: Boolean,
auxiliaryClassFileExtensions: Seq[String],
zincCache: os.SubPath = os.sub / "zinc"
zincFile: os.SubPath = os.sub / "zinc"
)(implicit ctx: ZincWorkerApi.Ctx): Result[CompilationResult] = {
os.makeDir.all(ctx.dest)

Expand Down Expand Up @@ -559,14 +549,14 @@ class ZincWorkerImpl(
case _ => None
}
analysisFile match {
case Some(zincPath) => fileAnalysisStore(zincPath).get().map(_.getAnalysis)
case Some(zincPath) => FileAnalysisStore.binary(zincPath.toIO).get().map(_.getAnalysis)
case None => Optional.empty[CompileAnalysis]
}
}

val lookup = MockedLookup(analysisMap)

val store = fileAnalysisStore(ctx.dest / zincCache)
val store = FileAnalysisStore.binary((ctx.dest / zincFile).toIO)

// Fix jdk classes marked as binary dependencies, see https://github.com/com-lihaoyi/mill/pull/1904
val converter = MappedFileConverter.empty
Expand Down Expand Up @@ -595,7 +585,7 @@ class ZincWorkerImpl(
setup = ic.setup(
lookup = lookup,
skip = false,
cacheFile = zincCache.toNIO,
cacheFile = zincFile.toNIO,
cache = new FreshCompilerCache,
incOptions = incOptions,
reporter = newReporter,
Expand Down Expand Up @@ -639,7 +629,7 @@ class ZincWorkerImpl(
newResult.setup()
)
)
Result.Success(CompilationResult((ctx.dest / zincCache), PathRef(classesDir)))
Result.Success(CompilationResult((ctx.dest / zincFile), PathRef(classesDir)))
} catch {
case e: CompileFailed =>
Result.Failure(e.toString)
Expand Down
Loading