-
-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Build binaries for Mill Client using Graal VM native-image (#4044)
This PR builds binaries for Mill using [Graal VM native-image](https://www.graalvm.org/latest/reference-manual/native-image/overview/Options/) and adds Java/Scala/Kotlin examples for building native images. Execution time for `mill --version`, with server running, shows over 5x improvement. ```bash $ time ./mill --version Mill Build Tool version 0.12.3 Java version: 11.0.25, vendor: Eclipse Adoptium, runtime: ~/.sdkman/candidates/java/11.0.25-tem Default locale: en_US, platform encoding: UTF-8 OS name: "Linux", version: 6.8.0-49-generic, arch: amd64 real 0m0.113s user 0m0.171s sys 0m0.037s $ time ./out/dist/native.dest/mill --version Mill Build Tool version 0.12.3-14-b0feea Java version: 11.0.25, vendor: Eclipse Adoptium, runtime: ~/.sdkman/candidates/java/11.0.25-tem Default locale: en_US, platform encoding: UTF-8 OS name: "Linux", version: 6.8.0-49-generic, arch: amd64 real 0m0.021s user 0m0.005s sys 0m0.016s ``` Resolves #4007. --------- Co-authored-by: Li Haoyi <haoyi.sg@gmail.com>
- Loading branch information
1 parent
ccad335
commit 64b0856
Showing
27 changed files
with
375 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
dist/resources/META-INF/native-image/reachability-metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"reflection": [ | ||
{ | ||
"type": "mill.runner.MillMain" | ||
}, | ||
{ | ||
"type": "mill.runner.MillServerMain" | ||
} | ||
], | ||
"resources": [ | ||
{ | ||
"glob": "logback.xml" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//// SNIPPET:BUILD | ||
package build | ||
import mill._, javalib._ | ||
import mill.define.ModuleRef | ||
|
||
object foo extends JavaModule with NativeImageModule { | ||
|
||
def zincWorker = ModuleRef(ZincWorkerGraalvm) | ||
|
||
object ZincWorkerGraalvm extends ZincWorkerModule { | ||
def jvmId = "graalvm-community:17.0.7" | ||
} | ||
} | ||
|
||
//// SNIPPET:END |
8 changes: 8 additions & 0 deletions
8
example/javalib/publishing/7-native-image/foo/src/foo/App.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package foo; | ||
|
||
public class App { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Hello, World!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//// SNIPPET:BUILD | ||
package build | ||
import mill._, kotlinlib._ | ||
import mill.define.ModuleRef | ||
|
||
object foo extends KotlinModule with NativeImageModule { | ||
|
||
def zincWorker = ModuleRef(ZincWorkerGraalvm) | ||
|
||
object ZincWorkerGraalvm extends ZincWorkerModule { | ||
def jvmId = "graalvm-community:17.0.7" | ||
} | ||
|
||
def kotlinVersion = "1.9.24" | ||
} | ||
|
||
//// SNIPPET:END |
5 changes: 5 additions & 0 deletions
5
example/kotlinlib/publishing/7-native-image/foo/src/foo/App.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package foo | ||
|
||
fun main(args: Array<String>) { | ||
println("Hello, World!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//// SNIPPET:BUILD | ||
package build | ||
import mill._, scalalib._ | ||
import mill.define.ModuleRef | ||
|
||
object foo extends ScalaModule with NativeImageModule { | ||
|
||
def zincWorker = ModuleRef(ZincWorkerGraalvm) | ||
|
||
object ZincWorkerGraalvm extends ZincWorkerModule { | ||
def jvmId = "graalvm-community:17.0.7" | ||
} | ||
|
||
def scalaVersion = "2.13.11" | ||
} | ||
|
||
//// SNIPPET:END | ||
// | ||
// This example uses `NativeImageModule` to generate a native executable using https://www.graalvm.org/[Graal VM]. | ||
// NOTE: For build portability, it is recommended to use a custom JDK via a custom `ZincWorkerModule` overriding | ||
// `def jvmId`. | ||
|
||
/** Usage | ||
|
||
> ./mill show foo.ZincWorkerGraalvm.javaHome | ||
|
||
> ./mill foo.nativeImage | ||
GraalVM Native Image: Generating...native-image... | ||
Finished generating...native-image... | ||
|
||
> ./out/foo/nativeImage.dest/native-image | ||
Hello, World! | ||
*/ |
7 changes: 7 additions & 0 deletions
7
example/scalalib/publishing/7-native-image/foo/src/foo/App.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package foo | ||
|
||
object App { | ||
|
||
def main(args: Array[String]): Unit = | ||
println("Hello, World!") | ||
} |
Oops, something went wrong.