Finish GraalVM native-image support#617
Open
ZacSweers wants to merge 31 commits into
Open
Conversation
Contributor
Author
|
Sorry for the churn, doing a bit of leg work to make the repo build able in windows for this. |
Introduces a `ktfmt` binary, built using GraalVM's `native-image` tool. The binary behaves the same way as `ktfmt`'s existing JVM-based CLI, but is compiled ahead-of-time into a native executable. Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
hick209
reviewed
May 28, 2026
hick209
reviewed
May 28, 2026
| @@ -1,50 +0,0 @@ | |||
| #!/bin/sh | |||
Contributor
There was a problem hiding this comment.
We still need this file as it's used by our internal BUCK build.
I guess I could move it around so it's publicly hidden though...
Contributor
Author
There was a problem hiding this comment.
Gotcha, yeah feel free to add back whatever you all need internally!
|
@hick209 has imported this pull request. If you are a Meta employee, you can view this in D106660271. |
ZacSweers
commented
May 28, 2026
sgammon
added a commit
to sgammon/ktfmt
that referenced
this pull request
Jun 4, 2026
Port the substantive native-image fixes from facebook#617 onto this branch so the GraalVM binary builds and actually runs: - Default `-march` to `compatibility` (the old `armv8.4-a+crypto+sve` is not a valid native-image AArch64 target and failed the build outright; `x86-64-v4` could also crash on older CPUs). - Default `--gc` to `serial` and actually thread the `nativeGc` property through (was hardcoded to `--gc=G1`, which is unsupported by native-image on macOS and in GraalVM Community Edition). Opt into G1 via `-Pktfmt.native.gc=G1`. - Align image flags with the tested set: add `--no-fallback` and `-H:-UseContainerSupport`; drop `--emit=build-report`, `--enable-sbom`, `-H:+UseCompressedReferences`, and `-H:+ReportDynamicAccess` (Oracle-EE-only or unnecessary), keeping the build portable to Community Edition. - Regenerate `reachability-metadata.json` for the current Kotlin compiler and fold the proxy config into it, removing the now-redundant `proxy-config.json` (and its deprecation warning). - Refresh `initialize-at-build-time.txt` / `initialize-at-run-time.txt` with the build-vs-runtime class-init fixes, and skip `#` comments when reading them. - Add `native_smoke_test.sh` to verify the binary formats Kotlin (catches stale reachability metadata that a bare `--version` check would miss). Verified: `:ktfmt:nativeCompile` + smoke test pass, and `:ktfmt:check`, `:ktfmt:build`, `:lambda:build` are green.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This finishes up #584. The original commits are preserved. Closes #441.
Changes since #584
mainnative-imageon macOS and is Oracle GraalVM only; Serial fits ktfmt's short-lived runs. Opt into G1 with-Pktfmt.native.gc=G1-marchdefaults (x86-64-v3,armv8-a). The old arm64 value was not a validnative-imagetarget, andx86-64-v4would crash on older/CI CPUs. Matches what GJF does.build-logicconvention pluginapplicationpluginnative_smoke_test.shandregenerate_native_metadata.shhelper scripts and a.gitattributesthat marks the generated metadata so reviews collapse it