Compiling Dotty with TeaVM #887
-
I gave a shot trying to compile Dotty, the Scala 3 compiler, with TeaVM. I know compiling such a big project with that many dependencies is probably not expected to work out of the box, but I wanted to record the steps I followed somewhere and thought here might be a good place. Dotty uses SBT as its build system. It can generate plain JARs, and I decided to try to use them directly with TeamVM CLI. I found no documentation about direct CLI usage, but found https://github.com/konsoletyper/teavm/blob/master/tools/cli/src/main/java/org/teavm/cli/TeaVMRunner.java which what I used. To run it, I used Coursier. Coursier automates downloading a package from Maven or another Java packages repository and running it. It enables me to run TeaVM CLI using:
Then, on the Dotty side, we can generate all JARs with:
This generate a bunch of JARs in
Let's check these JARs are indeed runnable:
Let's try to compile with TeaVM!
Mmh, but actually
After fiddling around for a while, I actually found I need
I tried without the wildcard, but got the same error. Then I tried to manually unzip my JARs:
Confirmed these classes are still runnable:
And tried to compile them with TeaVM:
Now TeaVM does actually compile my classes! 🥳
However, it shows many errors for missing classes:
These errors basically fall into 2 categories:
Then I read from the documentation:
So I wondered: where can I find a JAR with the TeaVM implementation of the Java standard library. I found the
What is the correct way to include the TeaVM version fo the Java standard library? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
TeaVM was never meant to be "JAR conversion tool", but rather "development tool", so CLI was never meant to be shipped to end users. I believe, there's 3rd-party plugin for SBT: https://github.com/sbt-teavm/sbt-teavm
The output parts you presented are missing important stack trace information. These aren't usual runtime stack traces, they are merely approximations, but still have enough information to find out what went wrong.
Please, don't do it!
The correct question here is: how do I compile Dotty. And there are plenty of ways to do that.
|
Beta Was this translation helpful? Give feedback.
-
Another useful approach is to write TeaVM plugin. There's no documentation on this, see source code (find |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for the pointers! I tried sbt-teavm: https://github.com/mbovel/sbt-teavm-scala3-test. It works well with Scala 3 as long as I don't use I will not pursue trying to compile the Dotty codebase with TeaVM for now, but will keep your advices in mind if I do in the future! |
Beta Was this translation helpful? Give feedback.
TeaVM was never meant to be "JAR conversion tool", but rather "development tool", so CLI was never meant to be shipped to end users. I believe, there's 3rd-party plugin for SBT: https://github.com/sbt-teavm/sbt-teavm
The output parts you presented are missing important stack trace information. These aren't usual runtime stack traces, they are merely approximations, but still have enough information to find out what went wrong.