From 4d03e496266e0437d788832987a5928d7e8cf0fc Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 29 Sep 2023 09:45:53 +0200 Subject: [PATCH] Use -Ystdlib to add Scala 2 lib TASTY to scalac (internal only) This flag only works on the `scala3-bootstrapped/scalac` in the dotty project. It is intended for internal testing. Currently it is a bit expensive to compile the Scala 2 library TASTy. One reason in for this is that we need to use `-Ycheck:all` when compiling it to make sure that `-Yscala2-stdlib` is working properly. We only allow `scala3-bootstrapped/scalac` and not `scalac` to have this dependency for two reasons. First, we do want to be able to compile and run `scalac` command fast to reduce development testing time. Second, we do not have a stable enough version of the Scala 2 library TASTy yet. We also do not enable the Scala 2 library TASTy by default on `scala3-bootstrapped/scalac` because we still need this command to test against the current version of the library. Stability is also a concern for this version of the command. --- project/Build.scala | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 0a3504c865c5..3ca5ddc9f248 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -723,22 +723,31 @@ object Build { val externalDeps = externalCompilerClasspathTask.value val jars = packageAll.value val scalaLib = findArtifactPath(externalDeps, "scala-library") + val scalaLibTastyOpt = jars.get("stdlib-bootstrapped-tasty") val dottyLib = jars("scala3-library") val dottyCompiler = jars("scala3-compiler") val args0: List[String] = spaceDelimited("").parsed.toList val decompile = args0.contains("-decompile") val printTasty = args0.contains("-print-tasty") + val useScala2LibraryTasty = args0.contains("-Yscala2-library-tasty") val debugFromTasty = args0.contains("-Ythrough-tasty") val args = args0.filter(arg => arg != "-repl" && arg != "-decompile" && - arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty") - + arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty" + && arg != "-Yscala2-library-tasty") val main = if (decompile) "dotty.tools.dotc.decompiler.Main" else if (printTasty) "dotty.tools.dotc.core.tasty.TastyPrinter" else if (debugFromTasty) "dotty.tools.dotc.fromtasty.Debug" else "dotty.tools.dotc.Main" - var extraClasspath = Seq(scalaLib, dottyLib) + var extraClasspath = + scalaLibTastyOpt match { + case Some(scalaLibTasty) if useScala2LibraryTasty => + Seq(scalaLibTasty, scalaLib, dottyLib) + case _ => + if (useScala2LibraryTasty) log.error("-Yscala2-library-tasty can only be used with a bootstrapped compiler") + Seq(scalaLib, dottyLib) + } if (decompile && !args.contains("-classpath")) extraClasspath ++= Seq(".") @@ -848,6 +857,7 @@ object Build { "scala3-staging" -> (LocalProject("scala3-staging") / Compile / packageBin).value.getAbsolutePath, "scala3-tasty-inspector" -> (LocalProject("scala3-tasty-inspector") / Compile / packageBin).value.getAbsolutePath, "tasty-core" -> (LocalProject("tasty-core-bootstrapped") / Compile / packageBin).value.getAbsolutePath, + "stdlib-bootstrapped-tasty" -> (LocalProject("stdlib-bootstrapped-tasty") / Compile / packageBin).value.getAbsolutePath, ) },