Skip to content

Full bootstrap: Use Dotty as the reference compiler #5923

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

Merged
merged 4 commits into from
Apr 22, 2019
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ pipeline:
# sbt scripted tests are slow and only run on nightly or deployment
event: [ tag, deployment ]

test_scala212:
group: test
image: lampepfl/dotty:2019-02-06
commands:
- cp -R . /tmp/5/ && cd /tmp/5/
- ./project/scripts/sbt ";++2.12.8 ;compile ;test"

# DOCUMENTATION:
documentation:
image: lampepfl/dotty:2019-02-06
Expand Down
1 change: 0 additions & 1 deletion compiler/test/dotty/tools/TestSources.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ object TestSources {
.map(_.toString)
.toList

assert(sources.nonEmpty)
sources
}
finally files.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {

// Positive tests ------------------------------------------------------------

@Test def posMacros: Unit = {
implicit val testGroup: TestGroup = TestGroup("compilePosMacros")
compileFilesInDir("tests/pos-macros", defaultOptions)
}.checkCompile()

@Test def posWithCompiler: Unit = {
implicit val testGroup: TestGroup = TestGroup("compilePosWithCompiler")
compileFilesInDir("tests/pos-with-compiler", withCompilerOptions) +
Expand Down Expand Up @@ -69,13 +74,23 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {

// Negative tests ------------------------------------------------------------

@Test def negAll: Unit = {
@Test def negMacros: Unit = {
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
compileFilesInDir("tests/neg-macros", defaultOptions)
}.checkExpectedErrors()

@Test def negWithCompiler: Unit = {
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
compileFilesInDir("tests/neg-with-compiler", withCompilerOptions)
}.checkExpectedErrors()

// Run tests -----------------------------------------------------------------

@Test def runMacros: Unit = {
implicit val testGroup: TestGroup = TestGroup("runMacros")
compileFilesInDir("tests/run-macros", defaultOptions)
}.checkRuns()

@Test def runWithCompiler: Unit = {
implicit val testGroup: TestGroup = TestGroup("runWithCompiler")
compileFilesInDir("tests/run-with-compiler", withCompilerOptions) +
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class CompilationTests extends ParallelTesting {
Array("-Ycheck-reentrant", "-Yemit-tasty-in-class")
)

val libraryDirs = List(Paths.get("library/src"), Paths.get("library/src-bootstrapped"))
val libraryDirs = List(Paths.get("library/src"), Paths.get("library/src-3.x"), Paths.get("library/src-bootstrapped"))
val librarySources = libraryDirs.flatMap(sources(_))

val lib =
Expand Down
7 changes: 6 additions & 1 deletion compiler/test/dotty/tools/repl/ScriptedTests.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package dotty.tools
package dotty
package tools
package repl

import java.io.{File => JFile}
import java.lang.System.{lineSeparator => EOL}

import org.junit.Assert._
import org.junit.Test
import org.junit.experimental.categories.Category

import scala.collection.mutable.ArrayBuffer
import scala.io.Source
Expand Down Expand Up @@ -91,4 +93,7 @@ class ScriptedTests extends ReplTest with MessageRendering {
@Test def replTests = scripts("/repl").foreach(testFile)

@Test def typePrinterTests = scripts("/type-printer").foreach(testFile)

@Category(Array(classOf[BootstrappedOnlyTests]))
@Test def replMacrosTests = scripts("/repl-macros").foreach(testFile)
}
Empty file added library/src-bootstrapped/.keep
Empty file.
Empty file.
86 changes: 57 additions & 29 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import scala.util.Properties.isJavaAtLeast

object Build {
val scalacVersion = "2.12.8"
val referenceVersion = "0.14.0-RC1"

val baseVersion = "0.15.0"
val baseSbtDottyVersion = "0.3.2"
Expand Down Expand Up @@ -182,21 +183,31 @@ object Build {
// Settings used for projects compiled only with Java
lazy val commonJavaSettings = commonSettings ++ Seq(
version := dottyVersion,
scalaVersion := scalacVersion,
scalaVersion := referenceVersion,
// To be removed once we stop cross-compiling with Scala 2
crossScalaVersions := Seq(referenceVersion, scalacVersion),
// Do not append Scala versions to the generated artifacts
crossPaths := false,
// Do not depend on the Scala library
autoScalaLibrary := false
)

// Settings used when compiling dotty using Scala 2
lazy val commonNonBootstrappedSettings = commonSettings ++ Seq(
// Settings used when compiling dotty (both non-boostrapped and bootstrapped)
lazy val commonDottySettings = commonSettings ++ Seq(
// Manually set the standard library to use
autoScalaLibrary := false
)

// Settings used when compiling dotty with the reference compiler
lazy val commonNonBootstrappedSettings = commonDottySettings ++ Seq(
version := dottyNonBootstrappedVersion,
scalaVersion := scalacVersion
scalaVersion := referenceVersion,
// To be removed once we stop cross-compiling with Scala 2
crossScalaVersions := Seq(referenceVersion, scalacVersion)
)

// Settings used when compiling dotty with a non-bootstrapped dotty
lazy val commonBootstrappedSettings = commonSettings ++ Seq(
lazy val commonBootstrappedSettings = commonDottySettings ++ Seq(
version := dottyVersion,
scalaVersion := dottyNonBootstrappedVersion,

Expand All @@ -219,11 +230,6 @@ object Build {
// sbt gets very unhappy if two projects use the same target
target := baseDirectory.value / ".." / "out" / "bootstrap" / name.value,

// The non-bootstrapped dotty-library is not necessary when bootstrapping dotty
autoScalaLibrary := false,
// ...but scala-library is
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion,

// Compile using the non-bootstrapped and non-published dotty
managedScalaInstance := false,
scalaInstance := {
Expand Down Expand Up @@ -463,13 +469,20 @@ object Build {
List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1")
else List()

val managedSrcDir = {
// Populate the directory
(managedSources in Compile).value

(sourceManaged in Compile).value
}

val jarOpts = List(
"-Ddotty.tests.dottyCompilerManagedSources=" + (sourceManaged in Compile).value,
"-Ddotty.tests.dottyCompilerManagedSources=" + managedSrcDir,
"-Ddotty.tests.classes.dottyInterfaces=" + jars("dotty-interfaces"),
"-Ddotty.tests.classes.dottyLibrary=" + jars("dotty-library"),
"-Ddotty.tests.classes.dottyCompiler=" + jars("dotty-compiler"),
"-Ddotty.tests.classes.compilerInterface=" + findLib(attList, "compiler-interface"),
"-Ddotty.tests.classes.scalaLibrary=" + findLib(attList, "scala-library"),
"-Ddotty.tests.classes.scalaLibrary=" + findLib(attList, "scala-library-"),
"-Ddotty.tests.classes.scalaAsm=" + findLib(attList, "scala-asm"),
"-Ddotty.tests.classes.scalaXml=" + findLib(attList, "scala-xml"),
"-Ddotty.tests.classes.jlineTerminal=" + findLib(attList, "jline-terminal"),
Expand Down Expand Up @@ -527,9 +540,6 @@ object Build {
} else if (scalaLib == "") {
println("Couldn't find scala-library on classpath, please run using script in bin dir instead")
} else if (args.contains("-with-compiler")) {
if (!isDotty.value) {
throw new MessageOnlyException("-with-compiler can only be used with a bootstrapped compiler")
}
val args1 = args.filter(_ != "-with-compiler")
val asm = findLib(attList, "scala-asm")
val dottyCompiler = jars("dotty-compiler")
Expand Down Expand Up @@ -578,9 +588,10 @@ object Build {
)

def runCompilerMain(repl: Boolean = false) = Def.inputTaskDyn {
val log = streams.value.log
val attList = (dependencyClasspath in Runtime).value
val jars = packageAll.value
val scalaLib = findLib(attList, "scala-library")
val scalaLib = findLib(attList, "scala-library-")
val dottyLib = jars("dotty-library")
val dottyCompiler = jars("dotty-compiler")
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
Expand All @@ -599,8 +610,8 @@ object Build {
var extraClasspath = s"$scalaLib${File.pathSeparator}$dottyLib"
if ((decompile || printTasty) && !args.contains("-classpath")) extraClasspath += s"${File.pathSeparator}."
if (args0.contains("-with-compiler")) {
if (!isDotty.value) {
throw new MessageOnlyException("-with-compiler can only be used with a bootstrapped compiler")
if (scalaVersion.value == referenceVersion) {
log.error("-with-compiler should only be used with a bootstrapped compiler")
}
extraClasspath += s"${File.pathSeparator}$dottyCompiler"
}
Expand Down Expand Up @@ -664,15 +675,32 @@ object Build {
// Settings shared between dotty-library and dotty-library-bootstrapped
lazy val dottyLibrarySettings = Seq(
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion,

// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath),

// To be removed once we stop cross-compiling with Scala 2
unmanagedSourceDirectories in Compile += {
val baseDir = baseDirectory.value
if (!isDotty.value)
baseDir / "src-2.x"
else
baseDir / "src-3.x"
},

// Add version-specific source directories:
// - files in src-non-bootstrapped will only be compiled by the reference compiler (scalac)
// - files in src-non-bootstrapped will only be compiled by the reference compiler
// - files in src-bootstrapped will only be compiled by the current dotty compiler (non-bootstrapped and bootstrapped)
unmanagedSourceDirectories in Compile += {
unmanagedSourceDirectories in Compile ++= {
val baseDir = baseDirectory.value
if (isDotty.value)
baseDir / "src-bootstrapped"
if (isDotty.value) {
if (scalaVersion.value == referenceVersion)
Seq(baseDir / "src-non-bootstrapped")
else
Seq(baseDir / "src-bootstrapped")
}
else
baseDir / "src-non-bootstrapped"
Seq()
}
)

Expand Down Expand Up @@ -949,8 +977,12 @@ object Build {
val updateCommunityBuild = taskKey[Unit]("Updates the community build.")

lazy val `community-build` = project.in(file("community-build")).
settings(commonNonBootstrappedSettings).
settings(commonSettings).
settings(
scalaVersion := referenceVersion,
// To be removed once we stop cross-compiling with Scala 2
crossScalaVersions := Seq(referenceVersion, scalacVersion),

prepareCommunityBuild := {
(publishLocal in `dotty-sbt-bridge`).value
(publishLocal in `dotty-interfaces`).value
Expand Down Expand Up @@ -1095,11 +1127,7 @@ object Build {
settings(dottyCompilerSettings)

def asDottyLibrary(implicit mode: Mode): Project = project.withCommonSettings.
settings(dottyLibrarySettings).
bootstrappedSettings(
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called.
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath)
)
settings(dottyLibrarySettings)

def asDottyDoc(implicit mode: Mode): Project = project.withCommonSettings.
dependsOn(dottyCompiler, dottyCompiler % "test->test").
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ object scalatest {
inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)}

def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = {
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(this.getClass.getClassLoader)
import refl._
val tree = condition.unseal
def exprStr: String = condition.show
Expand All @@ -30,4 +29,4 @@ object scalatest {
}
}
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ object scalatest {

def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = {
import refl._
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(this.getClass.getClassLoader)
val tree = condition.unseal
def exprStr: String = condition.show

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading