Adjusting to GraalVM for JDK21+ (#7855)

Changes required to build on GraalVM for JDK21+ while keeping the support for building on GraalVM for JDK17.
This commit is contained in:
Jaroslav Tulach 2023-09-22 13:38:53 +02:00 committed by GitHub
parent 12c4f2981d
commit 15b1989418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 55 deletions

View File

@ -894,7 +894,6 @@ lazy val `project-manager` = (project in file("lib/scala/project-manager"))
)
)
.dependsOn(VerifyReflectionSetup.run)
.dependsOn(installNativeImage)
.dependsOn(assembly)
.value,
buildNativeImage := NativeImage
@ -1293,55 +1292,6 @@ def runGu(logger: ManagedLogger, args: Seq[String]): String = {
)
}
def installedGuComponents(logger: ManagedLogger): Seq[String] = {
val componentList = runGu(
logger,
Seq("list")
)
val components = componentList.linesIterator
.drop(2)
.map { line =>
line
.split(" ")
.head
}
.toList
logger.debug(s"Installed GU components = $components")
if (!components.contains("graalvm")) {
throw new RuntimeException(s"graalvm components is not in $components")
}
components
}
lazy val installGraalJs = taskKey[Unit]("Install graaljs GraalVM component")
ThisBuild / installGraalJs := {
val logger = streams.value.log
if (!installedGuComponents(logger).contains("js")) {
logger.info("Installing js GraalVM component")
runGu(
logger,
Seq("install", "js")
)
}
}
lazy val installNativeImage =
taskKey[Unit]("Install native-image GraalVM component")
ThisBuild / installNativeImage := {
val logger = streams.value.log
if (!installedGuComponents(logger).contains("native-image")) {
logger.info("Installing native-image GraalVM component")
runGu(
logger,
Seq("install", "native-image")
)
}
}
ThisBuild / installNativeImage := {
(ThisBuild / installNativeImage).result.value
}
lazy val runtime = (project in file("engine/runtime"))
.configs(Benchmark)
.settings(
@ -1413,7 +1363,6 @@ lazy val runtime = (project in file("engine/runtime"))
.settings(
(Compile / compile) := (Compile / compile)
.dependsOn(Def.task { (Compile / sourceManaged).value.mkdirs })
.dependsOn(installGraalJs)
.value
)
.settings(
@ -1734,7 +1683,6 @@ lazy val `engine-runner` = project
"akka.http"
)
)
.dependsOn(installNativeImage)
.dependsOn(assembly)
.value,
buildNativeImage := NativeImage
@ -1778,7 +1726,6 @@ lazy val launcher = project
"-H:IncludeResources=.*Main.enso$"
)
)
.dependsOn(installNativeImage)
.dependsOn(assembly)
.dependsOn(VerifyReflectionSetup.run)
.value,

View File

@ -198,7 +198,7 @@ impl RunContext {
graalvm.install_if_missing(&self.cache).await?;
graal::Gu.require_present().await?;
let required_components = [graal::ComponentId::NativeImage];
let required_components = [graal::ComponentId::NativeImage, graal::ComponentId::JS];
// Some GraalVM components depend on Sulong and are not available on all platforms (like
// Windows or M1 macOS). Thus, we treat them as optional. See e.g.
// https://github.com/oracle/graalpython/issues/156

View File

@ -83,6 +83,11 @@ object CopyTruffleJAR {
libraryUpdates: UpdateReport,
log: ManagedLogger
): Boolean = {
val version = System.getProperty("java.version").split("\\.");
if (Integer.parseInt(version(0)) >= 21) {
// skip all checks on GraalVM for JDK21 and newer
return false;
}
var truffleInstancesFound = 0
var restartRequired = false
libraryUpdates.allFiles.foreach { f =>

View File

@ -73,7 +73,6 @@ object GraalVersionCheck {
val logger = newState.log
if (!graalVersionOk(graalVersion, logger)) {
logger.error("GraalVM version check failed.")
System.exit(1)
}
newState
}