-
Notifications
You must be signed in to change notification settings - Fork 83
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
Update Scala.js to 1.8.0 #597
Conversation
I think you also need to update https://github.com/scalameta/mdoc/blob/main/project/plugins.sbt#L4 |
Hmm, anywhere else to change it? |
Looks like Scala 3 doesn't yet support it. Maybe updating to 3.1.1-RC2 would help? (change all |
That's right, now that Scala.js compiler plugin is built-in to Scala 3 it no longer has an independent release cycle. I don't think I see a PR upgrading Scala 3 to Scala.js 1.8 in https://github.com/lampepfl/dotty/pulls?q=is%3Apr+author%3Asjrd+. So then, the real problem is that the |
Maybe we could just add:
in https://github.com/scalameta/mdoc/blob/main/build.sbt#L394 ? |
We think the same! :) |
Btw, I am also concerned this setting will depend on Scala 2/3. Right now it's 1.8.0, so we'll see what happens. Line 441 in 7ee8081
The tricky part is, IIUC this property is usually derived automatically by the sbt-mdoc plugin. So I fear that we may have to introduce some custom logic in the plugin to not let this exceed the maximum supported Scala.js version when using with Scala 3. |
Hmm, pinning Scala 3 to 1.7.1 still didn't fix it. Locally if I run Edit: also checked Edit 2: problem is in
Edit 3: checked one of my Scala 3.1 / Scala.js 1.8 projects which works fine, and it has this:
|
This reverts commit 7ee8081.
@sjrd would you mind helping us understand what might be happening here? Thanks. |
build.sbt
Outdated
def scala2js = "1.8.0" | ||
def scala3js = "1.7.1" |
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.
There's no reason to make those different. You can always use 1.8.0, since Scala.js IR is backward binary compatible.
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.
Right, except we seem to be running into forward-compatibility problem here only on Scala 3.
mdoc.internal.markdown.ModifierException: mdoc:js exception
Caused by: org.scalajs.ir.IRVersionNotSupportedException: Failed to deserialize a file compiled with Scala.js 1.8 (supported up to: 1.7): /home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-library_2.13/1.8.0/scalajs-library_2.13-1.8.0.jar:/scala/volatile.sjsir
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.
That must be due to something in your infrastructure that I am not familiar with. This is because the linker being used is 1.7.x instead of being 1.8.0. But Scala 3 per se doesn't even get to choose that. It must be something else in your infrastructure that selects the 1.7.x linker, whereas it should always select the 1.8.0 linker.
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.
Thanks. So @tgodzik it's back to my original question, where else do I need to change the version number 😆
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.
No idea 😓 There seem to be no place where we define 1.7
linker so that must be brought in by the compiler maybe? Doesn't the Scala 3 compiler need to be able to read 1.8 ?
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.
For locally released version everything seems to be correct:
cs resolve -t org.scalameta:mdoc-js_3:2.2.22+71-5ab2f66a+20211222-1821-SNAPSHOT | grep -B 12 -A 10 linker
Result:
└─ org.scalameta:mdoc-js_3:2.2.22+71-5ab2f66a+20211222-1821-SNAPSHOT
├─ org.scala-js:scalajs-linker_2.13:1.8.0
│ ├─ com.google.javascript:closure-compiler:v20211201
│ ├─ org.scala-js:scalajs-ir_2.13:1.8.0
│ │ └─ org.scala-lang:scala-library:2.13.6 -> 2.13.7
│ ├─ org.scala-js:scalajs-linker-interface_2.13:1.8.0
│ │ ├─ org.scala-js:scalajs-ir_2.13:1.8.0
│ │ │ └─ org.scala-lang:scala-library:2.13.6 -> 2.13.7
│ │ ├─ org.scala-js:scalajs-logging_2.13:1.1.1
│ │ │ └─ org.scala-lang:scala-library:2.13.2 -> 2.13.7
│ │ └─ org.scala-lang:scala-library:2.13.6 -> 2.13.7
│ ├─ org.scala-lang:scala-library:2.13.6 -> 2.13.7
│ └─ org.scala-lang.modules:scala-parallel-collections_2.13:0.2.0
│ └─ org.scala-lang:scala-library:2.13.0 -> 2.13.7
├─ org.scala-lang:scala3-library_3:3.1.0
│ └─ org.scala-lang:scala-library:2.13.6 -> 2.13.7
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.
@sjrd what would cause it to always work after you upgrade version such as https://github.com/lampepfl/dotty/pull/13734/files ?
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.
IIUC (which I very well may not) the Scala 3 compiler uses the .class
files of dependencies for compiling. Linking is what uses the .sjsir
files and depends on the IR version (hence it is the linker throwing this error), but there is no Scala 3 linker—as described in this blog post:
The .sjsir format and specification is independent of Scala, its compiler or its standard library. In fact, there is nothing Scala-specific in the entire linker, other than a few optimizations targeted at Scala-like code. This is important because it means that the linker is independent of the version of Scala: we use the same linker irrespective of the version of Scala that was used to create the .sjsir files.
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.
Classpath for the compiler seems to be:
/home/tgodzik/Documents/mdoc/tests/jsdocs/target/scala-3.1.0/classes:/home/tgodzik/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_sjs1_3/3.1.0/scala3-library_sjs1_3-3.1.0.jar:/home/tgodzik/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-library_2.13/1.8.0/scalajs-library_2.13-1.8.0.jar:/home/tgodzik/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-dom_sjs1_3/2.0.0/scalajs-dom_sjs1_3-2.0.0.jar:/home/tgodzik/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.6/scala-library-2.13.6.jar
And the compiler isn't able to read? Should the classpath contain the linker?
That shouldn't be a problem. Users even outside of mdoc can use Scala 3 with Scala.js 1.8.0, and they would get version 1.8.0. |
So @tgodzik raised a good question in #597 (comment) about why it would work after the corresponding SJS changes in the Scala 3 compiler. What's interesting is that the update to SJS 1.7 went exactly the same way in #540. Things were mostly working, except Scala 3 was having |
I went down the rabbit hole with this again in http4s-dom. By explicitly adding a dependency to the SJS 1.8 linker to my docs project, like so: lazy val docs =
project
.in(file("mdocs"))
.enablePlugins(MdocPlugin)
.settings(
mdocJS := Some(jsdocs),
libraryDependencies += "org.scala-js" %% "scalajs-linker" % "1.8.0" cross CrossVersion.for3Use2_13,
... I was able to get this error:
|
Wait, does that mean you somehow have the linker and its dependencies on the classpath of the compiler? (The one used to run the compiler) That could cause weird issues. The compiler plugin contains a copy of the |
@sjrd you mean like this? Lines 394 to 411 in 979b8f4
|
Hum yes, exactly. 😕 |
And the Lines 217 to 219 in 979b8f4
|
@sjrd does this mean that, for the purposes of mdoc.js, the Scala 3 version and Scala.js version will be tied to each other? Or is there some workaround for this by using multiple classloaders or similar techniques. |
Using class loaders would solve the issue. If you load the compiler in one class loader, and the linker in another one, they won't conflict. |
Superseded (:crossed_fingers: ) by #629 |
Towards #590.