-
Notifications
You must be signed in to change notification settings - Fork 277
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
SBT: native-image settings/plugins for JVM only #4574
Conversation
@jchyb please let me know if this looks ok. |
bin/build-native-image.sh
Outdated
@@ -1,2 +1,2 @@ | |||
set -eux | |||
sbt "cli/nativeImageCopy scalafmt" | |||
sbt "cliNative/nativeImageCopy scalafmt" |
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.
I don't think Scala Native has much to do with NativeImage, that's a totally different thing if I am not mistaken totally? If we switch from native image to pure Scala native than we would need to just do nativeLinkReleaseFull
and then copy the generated binary from target/scala-2.13.15
Do you want to switch the binaries right now? O after the next release?
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.
goes to show that i am really up to speed here :) so what is native image, then?
let's fix the current state first, then do what you suggest with the switch.
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.
Native image is developed by Oracle, there is more info here and it's an alternative to Scala Native. From what I've seen native image is usually more complicated to set up and the binaries might be bigger, though not 100% sure about that.
The big plus is that we can always ask the developer(s) to help us with fixing some issue and it's focused on Scala.
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.
how interesting... then would it be correct to say that nativeImage should only be built from JVM (i.e., this change should accomplish the exact opposite), since there's no reason to build a native image from an already native result?
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.
Yes, native image is only for JVM.
Just checked and the scala native binary is almost 2x smaller than the native image one in case of scalafmt. And it works without adding any special options. We could probably also optimize it better, so that's also more efficient that native image, though I haven't yet compared the two.
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.
I should mention that the 2.13 scala native version might likely be slower then 2.13 native image for now, since parallel collections are not used there, as the scala-parallel-collections
library was not ported to scala native yet (they are built into scala stdlib in 2.12, so it's better there).
build.sbt
Outdated
).nativeSettings( | ||
nativeConfig ~= { _.withMode(Mode.releaseFull) }, | ||
nativeImageInstalled := isCI, | ||
nativeImageOptions ++= { |
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.
Similar issue as pointed out above, nativeImage
settings will be ignored here (basically Native Image still uses classfiles to make a binary file, so it has to use the JVM target, Scala Native compiler outputs something else with the .nir
extension, which then the linker uses that to make a binary file.
No description provided.