Skip to content
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

Support scala-natve 0.5.0 #2318

Closed
wants to merge 5 commits into from
Closed

Conversation

catap
Copy link
Contributor

@catap catap commented Mar 13, 2024

It has a few changes in build plugin, which requires to cleanup a bit build script.

And one deprectated class was removed.

Tested as:

export SCALANATIVE_VERSION=0.5.0-RC2

sbt clean

sbt ++2.12.17 "project scalacticNative" clean publishLocal
sbt ++2.13.10 "project scalacticNative" clean publishLocal
sbt "project scalacticDottyNative" clean publishLocal

sbt ++2.12.17 "project scalatestNative" clean publishLocal
sbt ++2.13.10 "project scalatestNative" clean publishLocal
sbt "project scalatestDottyNative" clean publishLocal

sbt ++2.12.17 "project scalatestAppNative" clean publishLocal
sbt ++2.13.10 "project scalatestAppNative" clean publishLocal
sbt "project scalatestAppDottyNative" clean publishLocal

@cla-bot cla-bot bot added the cla-signed label Mar 13, 2024
@catap catap marked this pull request as draft March 13, 2024 16:16
@catap catap marked this pull request as ready for review March 13, 2024 17:47
@catap
Copy link
Contributor Author

catap commented Mar 13, 2024

BTW to build it you must to publish localy scala-xml for the same version of Scala-Native.

@catap catap force-pushed the scala-native-0.5.0 branch 2 times, most recently from 1c69be4 to 9cdd90d Compare March 13, 2024 22:09
@catap catap marked this pull request as draft March 13, 2024 23:54
@cheeseng
Copy link
Contributor

@catap I am trying this, seems like when building with Scala 3 it will fail with:

[error] sbt.librarymanagement.ResolveException: Error downloading org.scala-lang.modules:scala-xml_native0.5.0-RC2_3:2.1.0
[error]   Not found
[error]   Not found
[error]   not found: /home/cheeseng/.ivy2/local/org.scala-lang.modules/scala-xml_native0.5.0-RC2_3/2.1.0/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_native0.5.0-RC2_3/2.1.0/scala-xml_native0.5.0-RC2_3-2.1.0.pom
[error]   not found: https://jcenter.bintray.com/org/scala-lang/modules/scala-xml_native0.5.0-RC2_3/2.1.0/scala-xml_native0.5.0-RC2_3-2.1.0.pom
[error]   not found: https://oss.sonatype.org/content/groups/public/org/scala-lang/modules/scala-xml_native0.5.0-RC2_3/2.1.0/scala-xml_native0.5.0-RC2_3-2.1.0.pom
[error]   not found: /home/cheeseng/.m2/repository/org/scala-lang/modules/scala-xml_native0.5.0-RC2_3/2.1.0/scala-xml_native0.5.0-RC2_3-2.1.0.pom
[error]   not found: https://oss.sonatype.org/content/repositories/orgscalactic-1461/org/scala-lang/modules/scala-xml_native0.5.0-RC2_3/2.1.0/scala-xml_native0.5.0-RC2_3-2.1.0.pom
[error]   not found: https://oss.sonatype.org/content/repositories/orgscalatest-1754/org/scala-lang/modules/scala-xml_native0.5.0-RC2_3/2.1.0/scala-xml_native0.5.0-RC2_3-2.1.0.pom
[error] Error downloading org.scala-native:test-interface_native0.4_3:0.5.0-RC2
[error]   Not found
[error]   Not found
[error]   not found: /home/cheeseng/.ivy2/local/org.scala-native/test-interface_native0.4_3/0.5.0-RC2/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/scala-native/test-interface_native0.4_3/0.5.0-RC2/test-interface_native0.4_3-0.5.0-RC2.pom
[error]   not found: https://jcenter.bintray.com/org/scala-native/test-interface_native0.4_3/0.5.0-RC2/test-interface_native0.4_3-0.5.0-RC2.pom
[error]   not found: https://oss.sonatype.org/content/groups/public/org/scala-native/test-interface_native0.4_3/0.5.0-RC2/test-interface_native0.4_3-0.5.0-RC2.pom
[error]   not found: /home/cheeseng/.m2/repository/org/scala-native/test-interface_native0.4_3/0.5.0-RC2/test-interface_native0.4_3-0.5.0-RC2.pom
[error]   not found: https://oss.sonatype.org/content/repositories/orgscalactic-1461/org/scala-native/test-interface_native0.4_3/0.5.0-RC2/test-interface_native0.4_3-0.5.0-RC2.pom
[error]   not found: https://oss.sonatype.org/content/repositories/orgscalatest-1754/org/scala-native/test-interface_native0.4_3/0.5.0-RC2/test-interface_native0.4_3-0.5.0-RC2.pom

Perhaps the related scala-xml is not published yet?

@catap
Copy link
Contributor Author

catap commented Mar 14, 2024

@cheeseng ineed, I've locally updated to scala-xml-2.2.0, and publish it for Scala-Native-0.5.0-RC2 to unblock it.

Unfortently my yesterday test wasn't full, and required changed leads to update of scala3 version as well (otherwise it will be missmatch of ABI verison), and the last leads to a wired error:

[error] -- Error: /home/catap/src/scalatest/dotty/core.native/target/scala-3/src_managed/main/org/scalatest/Doc.scala:112:86 
[error] 112 |  final override lazy val nestedSuites: collection.immutable.IndexedSeq[Suite] = for (IncludedSuite(suite) <- snippets) yield suite
[error]     |                                                                                      ^^^^^^^^^^^^^^^^^^^^
[error]     |pattern's type Doc.this.IncludedSuite is more specialized than the right hand side expression's type Doc.this.Snippet
[error]     |
[error]     |If the narrowing is intentional, this can be communicated by adding the `case` keyword before the full pattern,
[error]     |which will result in a filtering for expression (using `withFilter`).
[error]     |This patch can be rewritten automatically under -rewrite -source 3.2-migration.

So, if you have any advice how to fix it, I'd like any help. Or, feel free to push into my branch.

My goal is prepare scalatest for the future release of scala-native, at least locally, to run heavy unit test on my code base, which usually allows to catch wired bugs :)

@catap
Copy link
Contributor Author

catap commented Mar 14, 2024

Well, seems that downgrade to scala-3.3.3 avoid to compile everything without this wired issue.

I continue to test it, and as soon as it's fully tested will convert this draft back to PR.

@catap
Copy link
Contributor Author

catap commented Mar 14, 2024

BTW opened a question in scala-xml: scala/scala-xml#713

@cheeseng
Copy link
Contributor

@catap Fyi to build with Scala 3.4 you'll need:

main...cheeseng:scalatest:feature-scala-3.4

But I think Scala 3.3 should be the better target since it is LTS.

@catap catap marked this pull request as ready for review March 14, 2024 09:29
@catap
Copy link
Contributor Author

catap commented Mar 14, 2024

@cheeseng everything had passed with scala-3.3.3

@catap
Copy link
Contributor Author

catap commented Mar 15, 2024

@cheeseng you seems the right person to ask. During my test migration a few tests are failed with reason:

java.lang.IllegalStateException: Queue is empty while future is not completed, this means you're probably using a wrong ExecutionContext for your task, please double check your Future

can you suggest any easy way to unblock it?

@catap
Copy link
Contributor Author

catap commented Mar 15, 2024

And...

  implicit override def executionContext: ExecutionContext =
    ExecutionContext.global

seems to fix this test

@catap
Copy link
Contributor Author

catap commented Mar 16, 2024

After future digging, just thoughts.

Probably #1858 need to be "adjusted". It doesn't requires for Scala-Native-0.5.0 anymore when Multithreading is enabled.

It can be checked via scala.scalanative.meta.LinktimeInfo.isMultithreadingEnabled which is linking-time condition and allows to have different code when multithreading is enabled and disabled.

But it exists on 0.5.0 only, so everything before will be literally broken.

I have no idea how to support old scala native and new one on the same code base.

@cheeseng
Copy link
Contributor

I have no idea how to support old scala native and new one on the same code base.

@catap Hmm, I wonder if we still want to support scala-native 0.4 going forward? If need to we probably can do so with a generator in sbt build I think.

@catap
Copy link
Contributor Author

catap commented Mar 17, 2024 via email

@catap
Copy link
Contributor Author

catap commented Mar 20, 2024

@cheeseng I just added one more commit which rework #1858 and brokes compatibillity with Scala-Native before 0.5.0

Trivial test case work on both enabled and disabled multithreading builds.

The whole test case almost work, but it may stuck on some random test. Probably related to issues inside SN itself, see for example: scala-native/scala-native#3846

Comment on lines 47 to 50
//SCALATESTNATIVE-ONLY implicit override def executionContext =
//SCALATESTNATIVE-ONLY if (scala.scalanative.meta.LinktimeInfo.isMultithreadingEnabled)
//SCALATESTNATIVE-ONLY scala.concurrent.ExecutionContext.Implicits.global
//SCALATESTNATIVE-ONLY else super.executionContext

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed? Scala Native does already use real, ForkJoinPool based ExecutionContext when multithreading is enabled or QueueExecutionContext in singlet-hreaded mode. Although I don't know what lives under super.executionContext
https://github.com/scala-native/scala-native/blob/8ac5d27670389495ca3493213a61105df9a6f95b/scalalib/overrides-2.13/scala/concurrent/ExecutionContext.scala.patch#L16

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long story short: with this version it work with and without multithreading out the box.

I had encountered two issues scala-native/scala-native#3846 and scala-native/scala-native#3848 with enabled multithreading, but it seems to be Scala-Native related or/and my code (libuv integration) which I still "clean" for multithreading.

@WojciechMazur
Copy link

WojciechMazur commented Mar 24, 2024

I think this PR still is not ready and needs adaption to added multithreading support in Scala Native.
Theres a plenty of tests that fail especially the async one that were referenced in reported SN issue.

Test command: scalatestFeatureSpecTestDottyNative/test
Output:

[error] Failed tests:
[error]         org.scalatest.featurespec.DeprecatedAsyncFeatureSpecSpec
[error]         org.scalatest.featurespec.AsyncFeatureSpecLikeSpec
[error]         org.scalatest.featurespec.FixtureAsyncFeatureSpecLikeSpec
[error]         org.scalatest.featurespec.DeprecatedAsyncFeatureSpecLikeSpec
[error]         org.scalatest.featurespec.AsyncFeatureSpecSpec
[error]         org.scalatest.featurespec.FixtureAsyncFeatureSpecSpec

It might be related to using single threaded stubs for java.util.concurrent types

@catap
Copy link
Contributor Author

catap commented Mar 25, 2024 via email

@lbialy
Copy link

lbialy commented Apr 12, 2024

@catap can we somehow help with this?

@catap
Copy link
Contributor Author

catap commented Apr 12, 2024 via email

@cheeseng
Copy link
Contributor

@catap I just tried with the released 0.5.0, seems working fine for Scala 2.12 and 2.13 (Scala 2.11 seems not supported), but for the scala-xml 2.2.0 the build for Scala 3 seems like not available yet:

[error] sbt.librarymanagement.ResolveException: Error downloading org.scala-lang.modules:scala-xml_native0.5_3:2.2.0
[error]   Not found
[error]   Not found
[error]   not found: /home/cheeseng/.ivy2/local/org.scala-lang.modules/scala-xml_native0.5_3/2.2.0/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error]   not found: https://jcenter.bintray.com/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error]   not found: https://oss.sonatype.org/content/groups/public/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error]   not found: /home/cheeseng/.m2/repository/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error]   not found: https://oss.sonatype.org/content/repositories/orgscalactic-1461/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error]   not found: https://oss.sonatype.org/content/repositories/orgscalatest-1754/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error] 	at lmcoursier.CoursierDependencyResolution.unresolvedWarningOrThrow(CoursierDependencyResolution.scala:258)
[error] 	at lmcoursier.CoursierDependencyResolution.$anonfun$update$38(CoursierDependencyResolution.scala:227)
[error] 	at scala.util.Either$LeftProjection.map(Either.scala:573)
[error] 	at lmcoursier.CoursierDependencyResolution.update(CoursierDependencyResolution.scala:227)
[error] 	at sbt.librarymanagement.DependencyResolution.update(DependencyResolution.scala:60)
[error] 	at sbt.internal.LibraryManagement$.resolve$1(LibraryManagement.scala:53)
[error] 	at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$12(LibraryManagement.scala:103)
[error] 	at sbt.util.Tracked$.$anonfun$lastOutput$1(Tracked.scala:73)
[error] 	at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$20(LibraryManagement.scala:116)
[error] 	at scala.util.control.Exception$Catch.apply(Exception.scala:228)
[error] 	at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11(LibraryManagement.scala:116)
[error] 	at sbt.internal.LibraryManagement$.$anonfun$cachedUpdate$11$adapted(LibraryManagement.scala:97)
[error] 	at sbt.util.Tracked$.$anonfun$inputChangedW$1(Tracked.scala:219)
[error] 	at sbt.internal.LibraryManagement$.cachedUpdate(LibraryManagement.scala:130)
[error] 	at sbt.Classpaths$.$anonfun$updateTask0$5(Defaults.scala:3525)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.Execute.work(Execute.scala:291)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] 	at java.lang.Thread.run(Thread.java:750)
[error] (scalatestCoreDottyNative / update) sbt.librarymanagement.ResolveException: Error downloading org.scala-lang.modules:scala-xml_native0.5_3:2.2.0
[error]   Not found
[error]   Not found
[error]   not found: /home/cheeseng/.ivy2/local/org.scala-lang.modules/scala-xml_native0.5_3/2.2.0/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error]   not found: https://jcenter.bintray.com/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error]   not found: https://oss.sonatype.org/content/groups/public/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error]   not found: /home/cheeseng/.m2/repository/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error]   not found: https://oss.sonatype.org/content/repositories/orgscalactic-1461/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error]   not found: https://oss.sonatype.org/content/repositories/orgscalatest-1754/org/scala-lang/modules/scala-xml_native0.5_3/2.2.0/scala-xml_native0.5_3-2.2.0.pom
[error] Total time: 13 s, completed Apr 15, 2024 9:42:02 AM

@catap
Copy link
Contributor Author

catap commented Apr 15, 2024

@cheeseng PR to switch scala-xml to scala-native-0.5.0 is here: scala/scala-xml#716

I hope that it will be merged and released soon.

It has a few changes in build plugin, which requires to cleanup a bit
build script.

And one deprectated class was removed.

Tested as:
```
export SCALANATIVE_VERSION=0.5.0

sbt clean

sbt ++2.12.17 "project scalacticNative" clean publishLocal
sbt ++2.13.10 "project scalacticNative" clean publishLocal
sbt "project scalacticDottyNative" clean publishLocal

sbt ++2.12.17 "project scalatestNative" clean publishLocal
sbt ++2.13.10 "project scalatestNative" clean publishLocal
sbt "project scalatestDottyNative" clean publishLocal

sbt ++2.12.17 "project scalatestAppNative" clean publishLocal
sbt ++2.13.10 "project scalatestAppNative" clean publishLocal
sbt "project scalatestAppDottyNative" clean publishLocal
```
@catap
Copy link
Contributor Author

catap commented Apr 15, 2024

Now it's blocked by https://github.com/scala/scala-parser-combinators

@catap
Copy link
Contributor Author

catap commented Apr 15, 2024

Linked issue: scala/scala-parser-combinators#550

@catap
Copy link
Contributor Author

catap commented Apr 18, 2024

@cheeseng CI is failing on scala-js. Anyway, I assume that you have already figured it out because main branch has updated version as well.

So, feel free to harvest from this PR support of SN-0.5.0 and dependencies.

But all of them should be used with modern enoug Scala.js.

@cheeseng
Copy link
Contributor

@catap Fyi I am trying this now.

@cheeseng cheeseng mentioned this pull request Apr 18, 2024
@cheeseng
Copy link
Contributor

@catap I have staged 3.2.18 build for scala-native 0.5, and submitted the following PR based on this PR:

#2322

@bvenners shall have the pleasure to release it.

Cheers.

@catap
Copy link
Contributor Author

catap commented Apr 18, 2024

Closed in favour of #2322

@catap catap closed this Apr 18, 2024
@catap catap deleted the scala-native-0.5.0 branch April 18, 2024 15:03
guizmaii added a commit to guizmaii/zio that referenced this pull request Apr 19, 2024
guizmaii added a commit to guizmaii/zio that referenced this pull request Apr 20, 2024
jdegoes pushed a commit to zio/zio that referenced this pull request Apr 20, 2024
* Update Scala, dependencies and sbt plugins

* Remove warnings

* Rollback scala-native to v.0.4.x

Because of scalatest/scalatest#2318

* Fix compilation errors

* Fix compilation errors

* scalacheck 1.18.0 is only build for scala-native v.0.5.x

* Clean ci.yml

* Improve `testJvms` CI step to test on 11, 17 and 21

* Remove compilation errors

* Remove compilation errors

* Simplify scala versions declarations

* Unify CI declarations

* Fix import

* Remove compilation errors

* Remove custom sbt script

* Update actions/setup-java

* Update actions/checkout

* Fix CI

* Remove compilation errors

* Try fix CI error:

```
[warn] In the last 10 seconds, 5.18 (52.6%) were spent in GC. [Heap: 0.00GB free of 1.00GB, max 1.00GB] Consider increasing the JVM heap using `-Xmx` or try a different collector, e.g. `-XX:+UseG1GC`, for better performance.
[warn] In the last 10 seconds, 6.369 (67.4%) were spent in GC. [Heap: 0.00GB free of 1.00GB, max 1.00GB] Consider increasing the JVM heap using `-Xmx` or try a different collector, e.g. `-XX:+UseG1GC`, for better performance.

              total        used        free      shared     buffers       cache   available
Mem:          16768        2589       11296          35         230        2652       13780
Swap:          7516           0        7516
Total:        24284        2589       18812
[error] ## Exception when compiling 16 sources to /home/runner/work/zio/zio/scalafix/input/target/scala-2.13/classes
```

* scalafmt

* Fix CI

* Fix CI

* `Compile / fork := false` is declared twice in the `doc` module

* Debug sbt command

* Put back `JVM_OPTS` envvar

* Rollback `Compile / fork` change

* debug

* debug

* debug

* debug

* debug

* debug

* debug

* Use .jvmopts-ci

* Prefer `SBT_OPTS`

* Debug $SBT_OPTS

* Rollback: Debug $SBT_OPTS

* clean

* Add more debug for future maintainers

* clean

* Remove Java 17 from `testJvms` CI step. It's already tested in other jobs

* Fix compilation

* Fix `build-website` CI step
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants