-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
Hmm, @nicolasstucki do you remember how to debug this ? |
I usually printed the tasty files (source file or full tasty) along with the UUID. For this kind of bug, it usually was an older version of the tasty file with a newer class file. |
project/Build.scala
Outdated
@@ -30,6 +30,7 @@ import scala.util.Properties.isJavaAtLeast | |||
|
|||
object Build { | |||
val scalacVersion = "2.12.8" | |||
val referenceVersion = "0.13.0-bin-20190213-d7090ab-NIGHTLY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need a more recent nightly, because of quotes in StagedTuple and b32a4a8
@nicolasstucki I'm trying to patch this in locally for our explicit nulls work (we want to bootstrap the compiler with explicit nulls), and I'm seeing the same error
When you say
does that suggest that the fix is cleaning some sbt cache? Or do I need to do something else? Thanks! |
There's probably some classpath confusion somewhere, I'll investigate in the near future, but I'm not sure why this is needed for you given that dotty-bootstrapped/compile should already give you the information you want |
Ok, but I see the error when I run |
What error ? |
To clarify: Iwas saying that you don't need this PR to test the bootstrapped compiler since you can already do one stage of bootstrapping with the current build |
I'm confused. When we switch to explicit nulls, we'll need to use union types inside dotty. My understanding of the current bootstrapping process is
If we use union types inside dotty, then step 1) will fail, because scalac doesn't have union types, right? What am I missing? |
Ah ok, I see now, but can't you work around that by defining something like: type Nullable[T] = T | Null In a file which is only compiled by the bootstrapped compiler, and: type Nullable[T] = T in a file that is only compiled by Scala 2. Then everything else can cross-compile. |
a2dccf6
to
7d1f407
Compare
Both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM
Compiling a macro with a non-bootstrapped compiler is fine, but running that macro in a subsequent compiler run as is usually done in macro tests is problematic since the MacroClassLoader is created using the compiler classpath (which contains a bootstrapped library) with the regular JVM classpath as parent classloader (which contains a non-bootstrapped library), this is inconsistent and could lead to various weird problems depending on the order in which things get loaded. One possible way to run these tests would be to always put the bootstrapped library on the JVM classpath, even if we're using the non-bootstrapped compiler, but this would cause test failures every time we would break binary compatibility. Instead, this commit moves the relevant tests to {pos,neg,run}-macros which will only be run with a bootstrapped compiler. To speed up development, it might be useful to add a flag to `testCompilation` that would put the bootstrapped library on the JVM classpath and still run these tests, but this is left as future work.
Like explained in the previous commit this kind of tests should be bootstrapped-only.
Some check files were not deleted or moved when the corresponding test was deleted or moved.
@odersky @anatoliykmetyuk @biboudis @OlivierBlanvillain @liufengyun @AleksanderBG @milessabin @allanrenucci @sjrd This PR is finally in! Here's a few things to watch out for now that we use Dotty instead of Scala 2.12 as our reference compiler:
If at any point you need to go back to using Scala 2.12 as the reference compiler, you can do it very easily by running: ++2.12.8 Inside sbt. Or by changing https://github.com/lampepfl/dotty/blob/b8fddaf23fd1e7101e6fca5f8b45cd9f037179e6/project/Build.scala#L33 to Happy hacking! |
Before merging this I'd like to:
Change the nomenclature used in the build ("non-bootstrapped dotty"Will do this later.and "bootstrapped dotty" are not descriptive enough when the reference
compiler is also dotty).
accidentally start using Dotty features in case we need to revert this
PR (we'll start usin Dotty features eventually, but let's wait
until we're confident that this setup works well enough).