scala / toolkit

The batteries-included Scala

Home Page:https://docs.scala-lang.org/toolkit/introduction.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Toolkit is broken on Native

armanbilge opened this issue · comments

This is due to VirtusLab/scala-cli#2426.

//> using toolkit latest
//> using platform native

@main def main = println("hello world")
$ scala-cli foo.scala 
Compiling project (Scala 3.3.0, Scala Native)
Compiled project (Scala 3.3.0, Scala Native)
[info] Linking (8078 ms)
[info] Checking intermediate code (quick) (409 ms)
[info] Discovered 700 classes and 3840 methods
[info] Optimizing (debug mode) (3422 ms)
[info] Generating intermediate code (2682 ms)
[info] Produced 16 files
[info] Compiling to native code (4908 ms)
[error] /usr/bin/ld: /workspace/sandbox/.scala-build/sandbox_e43dd4e865_19e4a0aaeb-b0bbeb3ef8/native/native-code-nativelib_native0.4_3-0.4.15-1/scala-native/gc/immix/Marker.c.o: in function `Object_IsWeakReference':
[error] Marker.c:(.text+0x88): undefined reference to `__weak_ref_ids_min'
[error] /usr/bin/ld: Marker.c:(.text+0xa2): undefined reference to `__weak_ref_ids_max'
[error] clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Exception in thread "main" scala.scalanative.build.BuildException: Failed to link /workspace/sandbox/.scala-build/sandbox_e43dd4e865_19e4a0aaeb-b0bbeb3ef8/native/main
        at scala.scalanative.build.LLVM$.link(LLVM.scala:131)
        at scala.scalanative.build.Build$.$anonfun$build$1(Build.scala:106)
        at scala.scalanative.build.Logger.time(Logger.scala:35)
        at scala.scalanative.build.Logger.time$(Logger.scala:32)
        at scala.scalanative.cli.utils.FilteredLogger.time(FilteredLogger.scala:7)
        at scala.scalanative.build.Build$.build(Build.scala:61)
        at scala.scalanative.cli.ScalaNativeLd$.$anonfun$runLd$3(ScalaNativeLd.scala:73)
        at scala.scalanative.util.Scope$.apply(Scope.scala:32)
        at scala.scalanative.cli.ScalaNativeLd$.runLd(ScalaNativeLd.scala:72)
        at scala.scalanative.cli.ScalaNativeLd$.main(ScalaNativeLd.scala:42)
        at scala.scalanative.cli.ScalaNativeLd.main(ScalaNativeLd.scala)
Error: scala.build.errors.ScalaNativeBuildError: Error compiling with Scala Native
For more details, please see '/workspace/sandbox/.scala-build/stacktraces/1697644322-15684455628134770469.log'

Thanks for the reporting, I think we could even include test for that in the CI

I'm not able to reproduce the problem on MacOS with Scala-CLI 1.1.2:

% scala-cli S.scala
[warn] ./S.scala:1:11
[warn] Using 'latest' for toolkit is deprecated, use 'default' to get more stable behaviour
[warn] //> using toolkit latest
[warn]           ^^^^^^^^^^^^^^
Compiling project (Scala 3.3.1, Scala Native 0.4.16)
Compiled project (Scala 3.3.1, Scala Native 0.4.16)
[info] Linking (677 ms)
[info] Checking intermediate code (quick) (77 ms)
[info] Discovered 701 classes and 3844 methods
[info] Optimizing (debug mode) (602 ms)
[info] Generating intermediate code (493 ms)
[info] Produced 12 files
[info] Compiling to native code (1536 ms)
[info] Total (3481 ms)
hello world

Yes, this will no longer be reproducible because scala-cli has released several new versions that upgrade the Scala Native toolchain and meanwhile toolkit has not released anything new. But it could happen again unless there is a plan so it won't happen again. In the Typelevel Toolkit we build a small app against the latest scala-cli just to verify everything still works before merging any PRs to update libraries.

Anyway, I will close as stale.

@armanbilge it's a good idea to add a small example toolkit app build to CI, I'll try to do this, meanwhile we're waiting for sttp to get on sn 0.5