Skip to content
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: update native build to recent JDK #4561

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,25 @@ jobs:
- os: macOS-latest
artifact: scalafmt-macos
env:
NATIVE_IMAGE_STATIC: false
NATIVE_IMAGE_STATIC: none
- os: ubuntu-latest
libc: default
artifact: scalafmt-linux-glibc
env:
NATIVE_IMAGE_STATIC: true
NATIVE_IMAGE_STATIC: nolibc
- os: ubuntu-latest
libc: musl
artifact: scalafmt-linux-musl
env:
NATIVE_IMAGE_STATIC: true
NATIVE_IMAGE_MUSL: true
NATIVE_IMAGE_STATIC: musl
env: ${{ matrix.env }}
steps:
- uses: actions/checkout@v4
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.0'
java-version: '11'
components: 'native-image'
java-version: '21'
distribution: 'graalvm-community'
native-image-musl: ${{ matrix.libc == 'musl' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: sbt/setup-sbt@v1
Expand Down
18 changes: 11 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,19 @@ lazy val cli = crossProject(JVMPlatform, NativePlatform)
),
scalacOptions ++= scalacJvmOptions.value,
Compile / mainClass := Some("org.scalafmt.cli.Cli"),
nativeImageVersion := "22.3.0",
nativeImageInstalled := isCI,
nativeImageOptions ++= {
val isMusl = sys.env.get("NATIVE_IMAGE_MUSL").exists(_.toBoolean)
if (isMusl) Seq("--libc=musl") else Nil
},
nativeImageOptions ++= {
val isStatic = sys.env.get("NATIVE_IMAGE_STATIC").exists(_.toBoolean)
if (isStatic) Seq("--static") else Nil
// https://www.graalvm.org/22.3/reference-manual/native-image/guides/build-static-executables/
// https://www.graalvm.org/latest/reference-manual/native-image/guides/build-static-executables/
sys.env.get("NATIVE_IMAGE_STATIC") match {
case Some("nolibc") => Seq(
"-H:+UnlockExperimentalVMOptions",
"-H:+StaticExecutableWithDynamicLibC",
"-H:-UnlockExperimentalVMOptions",
)
case Some("musl") => Seq("--static", "--libc=musl")
case _ => Nil
}
},
).nativeSettings(scalaNativeConfig).dependsOn(core, dynamic)
.enablePlugins(NativeImagePlugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ Args=--no-server \
--enable-http \
--enable-https \
--install-exit-handlers \
--initialize-at-build-time \
--initialize-at-run-time=org.scalafmt.util.AbsoluteFile \
--strict-image-heap \
-march=native \
--initialize-at-build-time="org.scalafmt" \
--initialize-at-build-time="org.scalameta" \
--initialize-at-build-time="scala.meta" \
--report-unsupported-elements-at-runtime \
-H:EnableURLProtocols=http,https \
-H:+UnlockExperimentalVMOptions \
-H:+RemoveSaturatedTypeFlows \
-H:+ReportExceptionStackTraces
-H:+ReportExceptionStackTraces \
-H:-UnlockExperimentalVMOptions