Skip to content

Commit

Permalink
Upgrade GraalVM and Truffle, set up multi-JDK testing, bump developme…
Browse files Browse the repository at this point in the history
…nt Java to 21 (#876)

This updates the GraalVM and Truffle libraries to 2024.1.2.

This also updates the build logic to compile Java sources using Java 21, due to some compile-only dependencies within GraalVM/Truffle using class file version 65. However, the produced artifact is still compatible with Java 17.

This also changes the Gradle build logic to use toolchains, and to test the Java libraries with JDK 17 and 21.

One consequence of this change is that Truffle is no longer shaded within the fat jars.

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]>
  • Loading branch information
sgammon authored Feb 3, 2025
1 parent 8cfd235 commit 408242a
Show file tree
Hide file tree
Showing 37 changed files with 747 additions and 181 deletions.
11 changes: 3 additions & 8 deletions .circleci/config.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,13 @@ local buildNativeJobs: Mapping<String, BuildNativeJob> = new {
}

local gradleCheckJobs: Mapping<String, GradleCheckJob> = new {
["gradle-check-jdk17"] {
javaVersion = "17.0"
isRelease = false
os = "linux"
}
["gradle-check-jdk21"] {
["gradle-check"] {
javaVersion = "21.0"
isRelease = false
os = "linux"
}
["gradle-check-jdk17-windows"] {
javaVersion = "17.0"
["gradle-check-windows"] {
javaVersion = "21.0"
isRelease = false
os = "windows"
}
Expand Down
91 changes: 33 additions & 58 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:macExecutableAmd64 pkl-core:testMacExecutableAmd64 pkl-server:testMacExecutableAmd64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:macExecutableAmd64 pkl-core:testMacExecutableAmd64 pkl-server:testMacExecutableAmd64
name: gradle buildNative
- persist_to_workspace:
root: '.'
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:linuxExecutableAmd64 pkl-core:testLinuxExecutableAmd64 pkl-server:testLinuxExecutableAmd64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:linuxExecutableAmd64 pkl-core:testLinuxExecutableAmd64 pkl-server:testLinuxExecutableAmd64
name: gradle buildNative
- persist_to_workspace:
root: '.'
Expand All @@ -108,7 +108,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:macExecutableAarch64 pkl-core:testMacExecutableAarch64 pkl-server:testMacExecutableAarch64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:macExecutableAarch64 pkl-core:testMacExecutableAarch64 pkl-server:testMacExecutableAarch64
name: gradle buildNative
- persist_to_workspace:
root: '.'
Expand Down Expand Up @@ -168,7 +168,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:linuxExecutableAarch64 pkl-core:testLinuxExecutableAarch64 pkl-server:testLinuxExecutableAarch64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:linuxExecutableAarch64 pkl-core:testLinuxExecutableAarch64 pkl-server:testLinuxExecutableAarch64
name: gradle buildNative
- persist_to_workspace:
root: '.'
Expand Down Expand Up @@ -245,7 +245,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:alpineExecutableAmd64 pkl-core:testAlpineExecutableAmd64 pkl-server:testAlpineExecutableAmd64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:alpineExecutableAmd64 pkl-core:testAlpineExecutableAmd64 pkl-server:testAlpineExecutableAmd64
name: gradle buildNative
- persist_to_workspace:
root: '.'
Expand Down Expand Up @@ -277,7 +277,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true pkl-cli:windowsExecutableAmd64 pkl-core:testWindowsExecutableAmd64 pkl-server:testWindowsExecutableAmd64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true pkl-cli:windowsExecutableAmd64 pkl-core:testWindowsExecutableAmd64 pkl-server:testWindowsExecutableAmd64
name: gradle buildNative
shell: bash.exe
- persist_to_workspace:
Expand All @@ -301,7 +301,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:macExecutableAmd64 pkl-core:testMacExecutableAmd64 pkl-server:testMacExecutableAmd64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:macExecutableAmd64 pkl-core:testMacExecutableAmd64 pkl-server:testMacExecutableAmd64
name: gradle buildNative
- persist_to_workspace:
root: '.'
Expand Down Expand Up @@ -377,7 +377,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:linuxExecutableAmd64 pkl-core:testLinuxExecutableAmd64 pkl-server:testLinuxExecutableAmd64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:linuxExecutableAmd64 pkl-core:testLinuxExecutableAmd64 pkl-server:testLinuxExecutableAmd64
name: gradle buildNative
- persist_to_workspace:
root: '.'
Expand All @@ -397,7 +397,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:macExecutableAarch64 pkl-core:testMacExecutableAarch64 pkl-server:testMacExecutableAarch64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:macExecutableAarch64 pkl-core:testMacExecutableAarch64 pkl-server:testMacExecutableAarch64
name: gradle buildNative
- persist_to_workspace:
root: '.'
Expand Down Expand Up @@ -457,7 +457,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:linuxExecutableAarch64 pkl-core:testLinuxExecutableAarch64 pkl-server:testLinuxExecutableAarch64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:linuxExecutableAarch64 pkl-core:testLinuxExecutableAarch64 pkl-server:testLinuxExecutableAarch64
name: gradle buildNative
- persist_to_workspace:
root: '.'
Expand Down Expand Up @@ -534,7 +534,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:alpineExecutableAmd64 pkl-core:testAlpineExecutableAmd64 pkl-server:testAlpineExecutableAmd64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:alpineExecutableAmd64 pkl-core:testAlpineExecutableAmd64 pkl-server:testAlpineExecutableAmd64
name: gradle buildNative
- persist_to_workspace:
root: '.'
Expand Down Expand Up @@ -566,7 +566,7 @@ jobs:
- run:
command: |-
export PATH=~/staticdeps/bin:$PATH
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results pkl-cli:windowsExecutableAmd64 pkl-core:testWindowsExecutableAmd64 pkl-server:testWindowsExecutableAmd64
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true pkl-cli:windowsExecutableAmd64 pkl-core:testWindowsExecutableAmd64 pkl-server:testWindowsExecutableAmd64
name: gradle buildNative
shell: bash.exe
- persist_to_workspace:
Expand All @@ -581,38 +581,26 @@ jobs:
resource_class: windows.large
machine:
image: windows-server-2022-gui:current
gradle-check-jdk17:
gradle-check:
steps:
- checkout
- run:
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results check
name: gradle check
- store_test_results:
path: ~/test-results
environment:
LANG: en_US.UTF-8
docker:
- image: cimg/openjdk:17.0
gradle-check-jdk21:
steps:
- checkout
- run:
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results check
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true check
name: gradle check
- store_test_results:
path: ~/test-results
environment:
LANG: en_US.UTF-8
docker:
- image: cimg/openjdk:21.0
gradle-check-jdk17-windows:
gradle-check-windows:
steps:
- checkout
- run:
command: |-
# install jdk
curl -Lf \
https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9.1/OpenJDK17U-jdk_x64_windows_hotspot_17.0.9_9.zip -o /tmp/jdk.zip
https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jdk_x64_windows_hotspot_21.0.5_11.zip -o /tmp/jdk.zip
unzip /tmp/jdk.zip -d /tmp/jdk \
&& cd /tmp/jdk/jdk-* \
Expand All @@ -621,7 +609,7 @@ jobs:
name: Set up environment
shell: bash.exe
- run:
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results check
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true check
name: gradle check
- store_test_results:
path: ~/test-results
Expand All @@ -635,7 +623,7 @@ jobs:
steps:
- checkout
- run:
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results bench:jmh
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true bench:jmh
name: bench:jmh
- store_test_results:
path: ~/test-results
Expand All @@ -648,7 +636,7 @@ jobs:
- checkout
- run:
command: |-
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results :pkl-gradle:build \
./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true :pkl-gradle:build \
:pkl-gradle:compatibilityTestReleases
name: gradle compatibility
- store_test_results:
Expand All @@ -663,7 +651,7 @@ jobs:
- attach_workspace:
at: '.'
- run:
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results publishToSonatype
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true publishToSonatype
- persist_to_workspace:
root: '.'
paths:
Expand All @@ -680,7 +668,7 @@ jobs:
- attach_workspace:
at: '.'
- run:
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DreleaseBuild=true publishToSonatype closeAndReleaseSonatypeStagingRepository
command: ./gradlew --info --stacktrace -DtestReportsDir=${HOME}/test-results -DpklMultiJdkTesting=true -DreleaseBuild=true publishToSonatype closeAndReleaseSonatypeStagingRepository
- persist_to_workspace:
root: '.'
paths:
Expand Down Expand Up @@ -742,13 +730,10 @@ workflows:
type: approval
- pr-approval/authenticate:
context: pkl-pr-approval
- gradle-check-jdk17:
- gradle-check:
requires:
- hold
- gradle-check-jdk21:
requires:
- hold
- gradle-check-jdk17-windows:
- gradle-check-windows:
requires:
- hold
when:
Expand All @@ -757,9 +742,8 @@ workflows:
pattern: ^pull/\d+(/head)?$
main:
jobs:
- gradle-check-jdk17
- gradle-check-jdk21
- gradle-check-jdk17-windows
- gradle-check
- gradle-check-windows
- bench
- gradle-compatibility
- pkl-cli-macOS-amd64-snapshot
Expand All @@ -770,9 +754,8 @@ workflows:
- pkl-cli-windows-amd64-snapshot
- deploy-snapshot:
requires:
- gradle-check-jdk17
- gradle-check-jdk21
- gradle-check-jdk17-windows
- gradle-check
- gradle-check-windows
- bench
- gradle-compatibility
- pkl-cli-macOS-amd64-snapshot
Expand All @@ -793,19 +776,13 @@ workflows:
- << pipeline.git.branch >>
release:
jobs:
- gradle-check-jdk17:
filters:
branches:
ignore: /.*/
tags:
only: /^v?\d+\.\d+\.\d+$/
- gradle-check-jdk21:
- gradle-check:
filters:
branches:
ignore: /.*/
tags:
only: /^v?\d+\.\d+\.\d+$/
- gradle-check-jdk17-windows:
- gradle-check-windows:
filters:
branches:
ignore: /.*/
Expand Down Expand Up @@ -861,9 +838,8 @@ workflows:
only: /^v?\d+\.\d+\.\d+$/
- github-release:
requires:
- gradle-check-jdk17
- gradle-check-jdk21
- gradle-check-jdk17-windows
- gradle-check
- gradle-check-windows
- bench
- gradle-compatibility
- pkl-cli-macOS-amd64-release
Expand Down Expand Up @@ -899,9 +875,8 @@ workflows:
only: /^v?\d+\.\d+\.\d+$/
release-branch:
jobs:
- gradle-check-jdk17
- gradle-check-jdk21
- gradle-check-jdk17-windows
- gradle-check
- gradle-check-windows
- bench
- gradle-compatibility
- pkl-cli-macOS-amd64-release
Expand Down
1 change: 1 addition & 0 deletions .circleci/jobs/GradleJob.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ fixed gradleArgs = new Listing {
"--info"
"--stacktrace"
"-DtestReportsDir=${HOME}/test-results"
"-DpklMultiJdkTesting=true"
when (isRelease) {
"-DreleaseBuild=true"
}
Expand Down
2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.0
21
4 changes: 2 additions & 2 deletions DEVELOPMENT.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

== Setup

. (mandatory) Install a JDK (any version between 17 - 21).
. (mandatory) Install a JDK (JDK 21+ required).
. (recommended) Install {uri-intellij}[IntelliJ IDEA] +
To import the project into IntelliJ, go to File->Open and select the project's root directory.
If the project is opened but not imported, look for a popup in the lower right corner
Expand All @@ -17,7 +17,7 @@ _gng_ enables to run Gradle commands with `gw` (instead of `./gradlew`) from any
. (recommended) Set up Git ignore-revs +
`git config blame.ignoreRevsFile .git-blame-ignore-revs`
. (recommended) Install {uri-jenv}[jenv] and plugins +
_jenv_ use specific JDK versions in certain subdirectories. _Pkl_ comes with a `.java-version` file specifying JDK 17. +
_jenv_ use specific JDK versions in certain subdirectories. _Pkl_ comes with a `.java-version` file specifying JDK 21. +
Enable _jenv_ plugins for better handling by `gradle`:
+
[source,shell]
Expand Down
11 changes: 8 additions & 3 deletions bench/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ net.sf.jopt-simple:jopt-simple:5.0.4=jmh,jmhCompileClasspath,jmhImplementationDe
org.apache.commons:commons-math3:3.6.1=jmh,jmhCompileClasspath,jmhImplementationDependenciesMetadata,jmhRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeOnlyDependenciesMetadata
org.assertj:assertj-core:3.27.2=testCompileClasspath,testImplementationDependenciesMetadata,testRuntimeClasspath
org.graalvm.compiler:compiler:23.0.6=graal
org.graalvm.sdk:graal-sdk:23.0.6=graal,jmh,jmhRuntimeClasspath,truffle
org.graalvm.truffle:truffle-api:23.0.6=graal,jmh,jmhRuntimeClasspath,truffle
org.graalvm.compiler:compiler:24.1.2=graal
org.graalvm.polyglot:polyglot:24.1.2=jmh,jmhRuntimeClasspath,truffle
org.graalvm.sdk:collections:24.1.2=graal,jmh,jmhRuntimeClasspath,truffle
org.graalvm.sdk:graal-sdk:24.1.2=jmh,jmhRuntimeClasspath
org.graalvm.sdk:nativeimage:24.1.2=jmh,jmhRuntimeClasspath,truffle
org.graalvm.sdk:word:24.1.2=graal,jmh,jmhRuntimeClasspath,truffle
org.graalvm.truffle:truffle-api:24.1.2=jmh,jmhRuntimeClasspath,truffle
org.graalvm.truffle:truffle-compiler:24.1.2=graal
org.jetbrains.intellij.deps:trove4j:1.0.20200330=kotlinBuildToolsApiClasspath,kotlinCompilerClasspath,kotlinKlibCommonizerClasspath
org.jetbrains.kotlin:kotlin-build-common:2.0.21=kotlinBuildToolsApiClasspath
org.jetbrains.kotlin:kotlin-build-tools-api:2.0.21=kotlinBuildToolsApiClasspath
Expand Down
22 changes: 18 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
*/
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins { `kotlin-dsl` }
plugins {
`kotlin-dsl`
`jvm-toolchains`
}

// Keep this in sync with the constants in `BuildInfo.kt` (those are not addressable here).
val toolchainVersion = 21

dependencies {
implementation(libs.downloadTaskPlugin)
Expand All @@ -29,8 +35,16 @@ dependencies {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.toVersion(toolchainVersion)
targetCompatibility = JavaVersion.toVersion(toolchainVersion)

toolchain {
languageVersion = JavaLanguageVersion.of(toolchainVersion)
vendor = JvmVendorSpec.ADOPTIUM
}
}

kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_17 } }
kotlin {
jvmToolchain(toolchainVersion)
compilerOptions { jvmTarget = JvmTarget.fromTarget(toolchainVersion.toString()) }
}
Loading

0 comments on commit 408242a

Please sign in to comment.