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

JDK 21 toolchain #876

Merged
merged 2 commits into from
Feb 3, 2025
Merged

JDK 21 toolchain #876

merged 2 commits into from
Feb 3, 2025

Conversation

sgammon
Copy link
Contributor

@sgammon sgammon commented Jan 6, 2025

Summary

This PR updates dependencies and build process for Pkl to bring GraalVM and Truffle support up to their latest versions. Today, Pkl builds against Java 17+, and requires Java 17+ to run.

After merging this PR, Pkl would build against Java 21, test against Java 21, and impose no change to lib consumers (i.e. still only requiring Java 17+ to run or transitively compile against Pkl).

Test downstream here (updated), via Github Actions. On that fork PR, the change set is expressed in full, with fixups.

PR Tree

Rationale

  • Gradle Toolchains: Uses Gradle's toolchains feature to provision and use different versions of the JDK.

  • JDK 21 Toolchain: Builds (and tests) occur under JDK 21, with bytecode targeting JVM 17. Build bytecode adopts JVM 21 to accelerate build tooling with no change to lib consumers.

  • Truffle SVM Dependency: Certain superclasses used by Pkl (notably, AbstractTruffleException and TruffleFeature) have moved to the new org.graalvm.nativeimage:truffle-runtime-svm coordinate.

  • Multi-JDK testing: Adds stronger guarantees for backward compatibility with regard to Pkl and JVM execution (i.e. java -jar ... with a fat JAR). Tests against versions 18-23 with test suites and java -jar ... executions.

Known Issues

  • Failing Tests (pkl-gradle)
  • Exports on JVM17: Running against newer Truffle on JVM17 may need --add-exports=...

Pre-merge Checklist

  • Refresh Gradle lockfiles and review

Changelog

  • feat: support for jvm21+ toolchain
  • feat: support for gradle toolchains
  • feat: pass -PnativeArch=native to build with -march=native
  • test: multi-jdk testing support
  • test: support for jvm-test-suite plugin
  • test: add tasks to run jpkl eval on multiple jdks
  • test: make jdk exec tests respect multi-jdk flags and ranges
  • fix: remove mrjar classes at >jvm17 from fatjars
  • fix: use jdk21 to run the tests (needed for Unsafe.ensureInitialized)
  • fix: truffle svm dependency is required after graalvm 24.0.0
  • fix: warnings for gvm flag usage, renamed truffle svm macro
  • fix: build with --add-modules=jdk.unsupported where needed
  • fix: don't use gu tool for modern graalvm versions
  • fix: catch Throwable instead of deprecated-for-removal ThreadDeath
  • chore: buildinfo changes for JVM targets, toolchains
  • chore: enforce testing at exactly jdk21
  • chore: enforce build tooling at jdk21+
  • chore: bump graalvm/truffle libs → 24.1.2
  • chore: toolchains for buildSrc

@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch from 8c2a05f to dc45756 Compare January 6, 2025 04:52
@sgammon sgammon changed the title feat: jvm 21+ support JVM 21+ support Jan 6, 2025
@sgammon sgammon mentioned this pull request Jan 6, 2025
buildSrc/src/main/kotlin/BuildInfo.kt Show resolved Hide resolved
buildSrc/src/main/kotlin/BuildInfo.kt Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/InstallGraalVm.kt Show resolved Hide resolved
gradlew Outdated Show resolved Hide resolved
pkl-cli/pkl-cli.gradle.kts Show resolved Hide resolved
pkl-cli/pkl-cli.gradle.kts Show resolved Hide resolved
pkl-cli/pkl-cli.gradle.kts Show resolved Hide resolved
pkl-cli/pkl-cli.gradle.kts Outdated Show resolved Hide resolved
pkl-executor/pkl-executor.gradle.kts Outdated Show resolved Hide resolved
@bioball bioball changed the title JVM 21+ support JVM 22+ support Jan 6, 2025
@bioball
Copy link
Contributor

bioball commented Jan 6, 2025

This is great, thanks, Sam!

I will do a review of this by next week.

FYI: Pkl today supports Java 21. The range enabled here is Java 22+ (updated your PR title).

settings.gradle.kts Outdated Show resolved Hide resolved
@sgammon

This comment was marked as outdated.

@StefMa
Copy link
Contributor

StefMa commented Jan 6, 2025

@sgammon feel free to extract the toolchain support into another PR. Indeed, my PR is quited dated. I will close it...

@sgammon
Copy link
Contributor Author

sgammon commented Jan 6, 2025

@StefMa roger, no worries :) I am a well known offender in that regard

@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch from dc45756 to 1982880 Compare January 6, 2025 22:00
@sgammon

This comment was marked as outdated.

@sgammon

This comment was marked as outdated.

Copy link
Contributor

@bioball bioball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

Also, general note: we'll need to set up our CI to use Java 21 to compile (for various compileJava tasks), and ideally to test with all of JDK 17/21/22+. I actually think toolchains probably makes sense for this, so, I'd be okay with the toolchain changes coming back into this PR.

With toolchains, maybe the version of Java used for tasks.test can come from a build flag.

gradlew Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/pklFatJar.gradle.kts Show resolved Hide resolved
gradle/libs.versions.toml Outdated Show resolved Hide resolved
pkl-cli/pkl-cli.gradle.kts Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/pklFatJar.gradle.kts Outdated Show resolved Hide resolved
@sgammon sgammon changed the title JVM 22+ support JDK 21+ toolchain Jan 22, 2025
@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch from 1982880 to a314e92 Compare January 22, 2025 06:12
pkl-cli/pkl-cli.gradle.kts Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/BuildInfo.kt Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/BuildInfo.kt Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts Outdated Show resolved Hide resolved
settings.gradle.kts Outdated Show resolved Hide resolved
@sgammon sgammon requested a review from bioball January 22, 2025 06:26
@sgammon

This comment was marked as outdated.

@sgammon sgammon changed the title JDK 21+ toolchain JDK 21 toolchain Jan 22, 2025
@sgammon

This comment was marked as outdated.

@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch from f9daed3 to 263588b Compare January 23, 2025 05:19
sgammon

This comment was marked as outdated.

settings.gradle.kts Outdated Show resolved Hide resolved
pkl-cli/pkl-cli.gradle.kts Outdated Show resolved Hide resolved
pkl-executor/pkl-executor.gradle.kts Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts Outdated Show resolved Hide resolved
@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch 3 times, most recently from 8ad9dd5 to 465337a Compare January 29, 2025 00:05
@sgammon

This comment was marked as outdated.

@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch from 465337a to 5f98585 Compare January 30, 2025 22:06
@sgammon

This comment was marked as outdated.

@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch 2 times, most recently from 69750d3 to d6a8801 Compare January 31, 2025 03:18
buildSrc/src/main/kotlin/BuildInfo.kt Outdated Show resolved Hide resolved
pkl-commons/gradle.lockfile Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/BuildInfo.kt Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/BuildInfo.kt Show resolved Hide resolved
buildSrc/build.gradle.kts Outdated Show resolved Hide resolved
buildSrc/build.gradle.kts Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/BuildInfo.kt Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/BuildInfo.kt Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/BuildInfo.kt Outdated Show resolved Hide resolved
@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch from d6a8801 to e85b259 Compare January 31, 2025 22:22
@sgammon

This comment was marked as resolved.

@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch from e85b259 to 8d9c22c Compare February 2, 2025 00:21
buildSrc/src/main/kotlin/BuildInfo.kt Show resolved Hide resolved
buildSrc/src/main/kotlin/BuildInfo.kt Show resolved Hide resolved
buildSrc/src/main/kotlin/BuildInfo.kt Show resolved Hide resolved
pkl-cli/gradle.lockfile Outdated Show resolved Hide resolved
pkl-cli/pkl-cli.gradle.kts Show resolved Hide resolved
pkl-cli/pkl-cli.gradle.kts Show resolved Hide resolved
@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch from 8d9c22c to a14ef41 Compare February 2, 2025 00:47
@sgammon sgammon requested a review from bioball February 2, 2025 00:48
@sgammon
Copy link
Contributor Author

sgammon commented Feb 2, 2025

@bioball This is ready for final review again :) I've left a self-review detailing the cleanups I've applied. Thank you for your patience while I figured out that GVM 17 bug.

@sgammon sgammon mentioned this pull request Feb 2, 2025
7 tasks
Copy link
Contributor

@bioball bioball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Sam! This looks really good. Thanks for your help here!

Can you also do the following:

  • Update the .java-version file to 21
  • Update DEVELOPMENT.adoc instructions (change mentions of Java 17 to 21)
  • Add -DpklMultiJdkTesting=true to our CircleCI definition. Should be okay to just add "-DpklMultiJdkTesting=true" to fixed gradleArgs in GradleJob.pkl.

buildSrc/src/main/kotlin/BuildInfo.kt Show resolved Hide resolved
@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch from a14ef41 to 596aa0a Compare February 3, 2025 21:51
@sgammon
Copy link
Contributor Author

sgammon commented Feb 3, 2025

@bioball No worries :) changes applied!

@sgammon sgammon requested a review from bioball February 3, 2025 21:51
- feat: support for jvm21+ toolchain
- feat: support for gradle toolchains
- feat: pass `-PnativeArch=native` to build with `-march=native`
- test: multi-jdk testing support
- test: support for `jvm-test-suite` plugin
- test: add tasks to run `jpkl eval` on multiple jdks
- test: make jdk exec tests respect multi-jdk flags and ranges
- fix: remove mrjar classes at >jvm17 from fatjars
- fix: use jdk21 to run the tests (needed for `Unsafe.ensureInitialized`)
- fix: truffle svm dependency is required after graalvm `24.0.0`
- fix: warnings for gvm flag usage, renamed truffle svm macro
- fix: build with `--add-modules=jdk.unsupported` where needed
- fix: don't use `gu` tool for modern graalvm versions
- fix: catch `Throwable` instead of deprecated-for-removal `ThreadDeath`
- chore: buildinfo changes for JVM targets, toolchains
- chore: enforce testing at exactly jdk21
- chore: enforce build tooling at jdk21+
- chore: bump graalvm/truffle libs → `24.1.2`
- chore: toolchains for `buildSrc`

Signed-off-by: Sam Gammon <[email protected]>
- chore: update to jdk21 in circle jobs
- chore: re-gen circle jobs

Signed-off-by: Sam Gammon <[email protected]>
@sgammon sgammon force-pushed the feat/jvm21plus-upstream branch from 596aa0a to 87a03af Compare February 3, 2025 21:53
Copy link
Contributor

@bioball bioball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, solid work, thank you!

@bioball bioball merged commit 408242a into apple:main Feb 3, 2025
3 checks passed
sgammon added a commit to elide-dev/pkl that referenced this pull request Feb 4, 2025
Checksums taken during apple#876 ended up out of date
due to the release of GraalVM `21.1.2` (the PR was
built against `21.1.1`).

These checksums are calculated from the GraalVM
download page directly:

https://www.graalvm.org/downloads/

On Linux:
```
sha256sum graalvm-...
```

Signed-off-by: Sam Gammon <[email protected]>
sgammon added a commit to elide-dev/pkl that referenced this pull request Feb 4, 2025
Checksums taken during apple#876 ended up out of date
due to the release of GraalVM `21.1.2` (the PR was
built against `21.1.1`).

These checksums are calculated from the GraalVM
download page directly:

https://www.graalvm.org/downloads/

On Linux:
```
sha256sum graalvm-...
```

Signed-off-by: Sam Gammon <[email protected]>
@sgammon sgammon mentioned this pull request Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants