From a68d1182017a0a08ea761333347b001733189d4e Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Sat, 10 Dec 2022 10:48:20 -0800 Subject: [PATCH] Native: use 22.3.0, switch to setup-graalvm The older version no longer handles the regular glibc case correctly, resulting in linker errors, hence the need for an upgrade. The newer version doesn't support the `-H:UseMuslC` option, hence the need to upgrade to setup-graalvm action which supports musl toolchain directly, requiring simply a flag. --- .github/workflows/ci.yml | 16 ++++++++-------- build.sbt | 19 ++++++++----------- .../scalafmt-cli/native-image.properties | 2 -- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c8f8d64d1..3ede6fadcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,18 +72,18 @@ jobs: artifact: scalafmt-linux-musl env: NATIVE_IMAGE_STATIC: true - NATIVE_IMAGE_MUSL: /home/runner/work/scalafmt/scalafmt/bundle + NATIVE_IMAGE_MUSL: true env: ${{ matrix.env }} steps: - uses: actions/checkout@v3 - - uses: olafurpg/setup-scala@v13 + - name: Set up GraalVM + uses: graalvm/setup-graalvm@v1 with: - java-version: graalvm-ce-java11@20.1.0 - - if: matrix.libc == 'musl' - name: Install musl bundle - run: | - wget https://github.com/gradinac/musl-bundle-example/releases/download/v1.0/musl.tar.gz - tar xvf musl.tar.gz + version: '22.3.0' + java-version: '11' + components: 'native-image' + native-image-musl: ${{ matrix.libc == 'musl' }} + github-token: ${{ secrets.GITHUB_TOKEN }} - run: bin/build-native-image.sh env: CI: true diff --git a/build.sbt b/build.sbt index 9140ee3c4d..4410d26309 100644 --- a/build.sbt +++ b/build.sbt @@ -232,18 +232,15 @@ lazy val cli = project ), scalacOptions ++= scalacJvmOptions.value, Compile / mainClass := Some("org.scalafmt.cli.Cli"), - nativeImageVersion := "20.1.0", + nativeImageVersion := "22.3.0", + nativeImageInstalled := isCI, nativeImageOptions ++= { - sys.env - .get("NATIVE_IMAGE_MUSL") - .map(path => s"-H:UseMuslC=$path") - .toSeq ++ - sys.env - .get("NATIVE_IMAGE_STATIC") - .map(_.toBoolean) - .filter(identity) - .map(_ => "--static") - .toSeq + 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 } ) .dependsOn(coreJVM, dynamic) diff --git a/scalafmt-cli/src/main/resources/META-INF/native-image/org.scalafmt/scalafmt-cli/native-image.properties b/scalafmt-cli/src/main/resources/META-INF/native-image/org.scalafmt/scalafmt-cli/native-image.properties index 979f87a554..8404075ea7 100644 --- a/scalafmt-cli/src/main/resources/META-INF/native-image/org.scalafmt/scalafmt-cli/native-image.properties +++ b/scalafmt-cli/src/main/resources/META-INF/native-image/org.scalafmt/scalafmt-cli/native-image.properties @@ -3,12 +3,10 @@ Args=--no-server \ --no-fallback \ --enable-http \ --enable-https \ - --enable-all-security-services \ --install-exit-handlers \ --initialize-at-build-time \ --initialize-at-run-time=org.scalafmt.util.AbsoluteFile \ --report-unsupported-elements-at-runtime \ - --verbose \ -H:EnableURLProtocols=http,https \ -H:+RemoveSaturatedTypeFlows \ -H:+ReportExceptionStackTraces