Skip to content

Commit 5b72961

Browse files
committed
Full bootstrap: Use Dotty as the reference compiler
The non-bootstrapped compiler is now compiled by Dotty 0.14.0-RC1 instead of Scala 2.12.8. The bootstrapped compiler is compiled using the non-bootstrapped compiler as before. For now, we still support compilation with Scala 2.12, this is achieved by having separate `src-2.x` and `src-3.x` directory for the library. To use Scala 2.12 as the reference compiler, run: ++2.12.8 in sbt, or change `referenceVersion` to "2.12.8" in Build.scala.
1 parent d39bca0 commit 5b72961

File tree

33 files changed

+63
-34
lines changed

33 files changed

+63
-34
lines changed

.drone.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ pipeline:
5252
# sbt scripted tests are slow and only run on nightly or deployment
5353
event: [ tag, deployment ]
5454

55+
test_scala212:
56+
group: test
57+
image: lampepfl/dotty:2019-02-06
58+
commands:
59+
- cp -R . /tmp/5/ && cd /tmp/5/
60+
- ./project/scripts/sbt ";++2.12.8 ;compile ;test"
61+
5562
# DOCUMENTATION:
5663
documentation:
5764
image: lampepfl/dotty:2019-02-06

compiler/test/dotty/tools/TestSources.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ object TestSources {
6565
.map(_.toString)
6666
.toList
6767

68-
assert(sources.nonEmpty)
6968
sources
7069
}
7170
finally files.close()

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class CompilationTests extends ParallelTesting {
232232
Array("-Ycheck-reentrant", "-Yemit-tasty-in-class")
233233
)
234234

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

238238
val lib =

library/src-bootstrapped/.keep

Whitespace-only changes.

library/src-non-bootstrapped/.keep

Whitespace-only changes.

project/Build.scala

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import scala.util.Properties.isJavaAtLeast
3030

3131
object Build {
3232
val scalacVersion = "2.12.8"
33+
val referenceVersion = "0.14.0-RC1"
3334

3435
val baseVersion = "0.15.0"
3536
val baseSbtDottyVersion = "0.3.2"
@@ -182,21 +183,31 @@ object Build {
182183
// Settings used for projects compiled only with Java
183184
lazy val commonJavaSettings = commonSettings ++ Seq(
184185
version := dottyVersion,
185-
scalaVersion := scalacVersion,
186+
scalaVersion := referenceVersion,
187+
// To be removed once we stop cross-compiling with Scala 2
188+
crossScalaVersions := Seq(referenceVersion, scalacVersion),
186189
// Do not append Scala versions to the generated artifacts
187190
crossPaths := false,
188191
// Do not depend on the Scala library
189192
autoScalaLibrary := false
190193
)
191194

192-
// Settings used when compiling dotty using Scala 2
193-
lazy val commonNonBootstrappedSettings = commonSettings ++ Seq(
195+
// Settings used when compiling dotty (both non-boostrapped and bootstrapped)
196+
lazy val commonDottySettings = commonSettings ++ Seq(
197+
// Manually set the standard library to use
198+
autoScalaLibrary := false
199+
)
200+
201+
// Settings used when compiling dotty with the reference compiler
202+
lazy val commonNonBootstrappedSettings = commonDottySettings ++ Seq(
194203
version := dottyNonBootstrappedVersion,
195-
scalaVersion := scalacVersion
204+
scalaVersion := referenceVersion,
205+
// To be removed once we stop cross-compiling with Scala 2
206+
crossScalaVersions := Seq(referenceVersion, scalacVersion)
196207
)
197208

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

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

222-
// The non-bootstrapped dotty-library is not necessary when bootstrapping dotty
223-
autoScalaLibrary := false,
224-
// ...but scala-library is
225-
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion,
226-
227233
// Compile using the non-bootstrapped and non-published dotty
228234
managedScalaInstance := false,
229235
scalaInstance := {
@@ -463,13 +469,20 @@ object Build {
463469
List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1")
464470
else List()
465471

472+
val managedSrcDir = {
473+
// Populate the directory
474+
(managedSources in Compile).value
475+
476+
(sourceManaged in Compile).value
477+
}
478+
466479
val jarOpts = List(
467-
"-Ddotty.tests.dottyCompilerManagedSources=" + (sourceManaged in Compile).value,
480+
"-Ddotty.tests.dottyCompilerManagedSources=" + managedSrcDir,
468481
"-Ddotty.tests.classes.dottyInterfaces=" + jars("dotty-interfaces"),
469482
"-Ddotty.tests.classes.dottyLibrary=" + jars("dotty-library"),
470483
"-Ddotty.tests.classes.dottyCompiler=" + jars("dotty-compiler"),
471484
"-Ddotty.tests.classes.compilerInterface=" + findLib(attList, "compiler-interface"),
472-
"-Ddotty.tests.classes.scalaLibrary=" + findLib(attList, "scala-library"),
485+
"-Ddotty.tests.classes.scalaLibrary=" + findLib(attList, "scala-library-"),
473486
"-Ddotty.tests.classes.scalaAsm=" + findLib(attList, "scala-asm"),
474487
"-Ddotty.tests.classes.scalaXml=" + findLib(attList, "scala-xml"),
475488
"-Ddotty.tests.classes.jlineTerminal=" + findLib(attList, "jline-terminal"),
@@ -527,9 +540,6 @@ object Build {
527540
} else if (scalaLib == "") {
528541
println("Couldn't find scala-library on classpath, please run using script in bin dir instead")
529542
} else if (args.contains("-with-compiler")) {
530-
if (!isDotty.value) {
531-
throw new MessageOnlyException("-with-compiler can only be used with a bootstrapped compiler")
532-
}
533543
val args1 = args.filter(_ != "-with-compiler")
534544
val asm = findLib(attList, "scala-asm")
535545
val dottyCompiler = jars("dotty-compiler")
@@ -580,7 +590,7 @@ object Build {
580590
def runCompilerMain(repl: Boolean = false) = Def.inputTaskDyn {
581591
val attList = (dependencyClasspath in Runtime).value
582592
val jars = packageAll.value
583-
val scalaLib = findLib(attList, "scala-library")
593+
val scalaLib = findLib(attList, "scala-library-")
584594
val dottyLib = jars("dotty-library")
585595
val dottyCompiler = jars("dotty-compiler")
586596
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
@@ -598,12 +608,8 @@ object Build {
598608

599609
var extraClasspath = s"$scalaLib${File.pathSeparator}$dottyLib"
600610
if ((decompile || printTasty) && !args.contains("-classpath")) extraClasspath += s"${File.pathSeparator}."
601-
if (args0.contains("-with-compiler")) {
602-
if (!isDotty.value) {
603-
throw new MessageOnlyException("-with-compiler can only be used with a bootstrapped compiler")
604-
}
611+
if (args0.contains("-with-compiler"))
605612
extraClasspath += s"${File.pathSeparator}$dottyCompiler"
606-
}
607613

608614
val fullArgs = main :: insertClasspathInArgs(args, extraClasspath)
609615

@@ -664,15 +670,32 @@ object Build {
664670
// Settings shared between dotty-library and dotty-library-bootstrapped
665671
lazy val dottyLibrarySettings = Seq(
666672
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion,
673+
674+
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called
675+
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath),
676+
677+
// To be removed once we stop cross-compiling with Scala 2
678+
unmanagedSourceDirectories in Compile += {
679+
val baseDir = baseDirectory.value
680+
if (!isDotty.value)
681+
baseDir / "src-2.x"
682+
else
683+
baseDir / "src-3.x"
684+
},
685+
667686
// Add version-specific source directories:
668-
// - files in src-non-bootstrapped will only be compiled by the reference compiler (scalac)
687+
// - files in src-non-bootstrapped will only be compiled by the reference compiler
669688
// - files in src-bootstrapped will only be compiled by the current dotty compiler (non-bootstrapped and bootstrapped)
670-
unmanagedSourceDirectories in Compile += {
689+
unmanagedSourceDirectories in Compile ++= {
671690
val baseDir = baseDirectory.value
672-
if (isDotty.value)
673-
baseDir / "src-bootstrapped"
691+
if (isDotty.value) {
692+
if (scalaVersion.value == referenceVersion)
693+
Seq(baseDir / "src-non-bootstrapped")
694+
else
695+
Seq(baseDir / "src-bootstrapped")
696+
}
674697
else
675-
baseDir / "src-non-bootstrapped"
698+
Seq()
676699
}
677700
)
678701

@@ -949,8 +972,12 @@ object Build {
949972
val updateCommunityBuild = taskKey[Unit]("Updates the community build.")
950973

951974
lazy val `community-build` = project.in(file("community-build")).
952-
settings(commonNonBootstrappedSettings).
975+
settings(commonSettings).
953976
settings(
977+
scalaVersion := referenceVersion,
978+
// To be removed once we stop cross-compiling with Scala 2
979+
crossScalaVersions := Seq(referenceVersion, scalacVersion),
980+
954981
prepareCommunityBuild := {
955982
(publishLocal in `dotty-sbt-bridge`).value
956983
(publishLocal in `dotty-interfaces`).value
@@ -1095,11 +1122,7 @@ object Build {
10951122
settings(dottyCompilerSettings)
10961123

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

11041127
def asDottyDoc(implicit mode: Mode): Project = project.withCommonSettings.
11051128
dependsOn(dottyCompiler, dottyCompiler % "test->test").

0 commit comments

Comments
 (0)