Skip to content

Instantly share code, notes, and snippets.

@kmizu
Last active August 21, 2018 16:01
Show Gist options
  • Save kmizu/de477c28371479b4d05572093ac052db to your computer and use it in GitHub Desktop.
Save kmizu/de477c28371479b4d05572093ac052db to your computer and use it in GitHub Desktop.
Graal VMのnative-imageでscalac-nativeをビルドする ref: https://qiita.com/kmizu/items/89253e29a2f13db84802
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
$ export GRAALVM_HOME=$HOME/graalvm-ce-1.0.0-rc5/Contents/Home
$ git clone https://github.com/graalvm/graalvm-demos
$ cd graalvm-demos/scala-days-2018/scalac-native/scala-substitutions
$ sbt package
$ cd ../
$ export SCALA_HOME=/usr/local/Cellar/scala/2.12.6/libexec
$ ./scalac-image.sh
Shutdown Server(pid: 48659, port: 61012)
Build on Server(pid: 51113, port: 62944)*
classlist: 7,329.88 ms
(cap): 1,539.01 ms
setup: 2,721.47 ms
(typeflow): 44,765.91 ms
(objects): 14,196.04 ms
(features): 268.88 ms
analysis: 61,275.37 ms
universe: 2,039.23 ms
(parse): 11,110.12 ms
(inline): 6,877.22 ms
(compile): 32,331.02 ms
compile: 52,528.67 ms
image: 3,955.90 ms
write: 20,390.24 ms
[total]: 150,422.60 ms
$ cat HelloWorld.scala
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}
$ time ./scalac-native HelloWorld.scala
./scalac-native HelloWorld.scala 0.14s user 0.07s system 90% cpu 0.227 total
$ ls *.class
HelloWorld$.class HelloWorld.class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment