scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Adding CLI option for cross-compiling on Scala Native

Open windymelt opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

Scala Native has its cross-compiling feature that is came from clang/LLVM.

https://scala-native.org/en/stable/user/sbt.html#cross-compilation

nativeConfig ~= { _.withTargetTriple("x86_64-apple-macosx10.14.0") }

Though Scala CLI has some CLI options that manipulates Scala Native, there is no option to handle with target triple.

(Scala CLI have --native-target, but it sets artifact type e.g. application / dynamic lib / static lib)

Describe the solution you'd like

Add --native-target-triple to provide target triple info for Scala Native (and clang/LLVM)

Describe alternatives you've considered

We can convert foobar.scala.sc into sbt project, and manually add Scala Native configurations.

Additional context

I tried building native binary via Docker Image (virtuslab/scala-cli), and that's quite easy (I wrote build stage, and copied binary to host or another thin stage). If we have cross-compiling feature, that's awesome build infrastructure for small tool (like Go, Rust).

windymelt avatar Mar 02 '24 11:03 windymelt