From 15b198941815f4cd2014093b47f14eef8163cf81 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Fri, 22 Sep 2023 13:38:53 +0200 Subject: [PATCH] Adjusting to GraalVM for JDK21+ (#7855) Changes required to build on GraalVM for JDK21+ while keeping the support for building on GraalVM for JDK17. --- build.sbt | 53 ------------------------------- build/build/src/engine/context.rs | 2 +- project/CopyTruffleJAR.scala | 5 +++ project/GraalVersionCheck.scala | 1 - 4 files changed, 6 insertions(+), 55 deletions(-) diff --git a/build.sbt b/build.sbt index 9868000eaf0..228bebf9911 100644 --- a/build.sbt +++ b/build.sbt @@ -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, diff --git a/build/build/src/engine/context.rs b/build/build/src/engine/context.rs index 61b807a5389..64650199c4a 100644 --- a/build/build/src/engine/context.rs +++ b/build/build/src/engine/context.rs @@ -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 diff --git a/project/CopyTruffleJAR.scala b/project/CopyTruffleJAR.scala index 4ca0de75c9b..3f4622eb419 100644 --- a/project/CopyTruffleJAR.scala +++ b/project/CopyTruffleJAR.scala @@ -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 => diff --git a/project/GraalVersionCheck.scala b/project/GraalVersionCheck.scala index f8db9a51cde..d45a707d48f 100644 --- a/project/GraalVersionCheck.scala +++ b/project/GraalVersionCheck.scala @@ -73,7 +73,6 @@ object GraalVersionCheck { val logger = newState.log if (!graalVersionOk(graalVersion, logger)) { logger.error("GraalVM version check failed.") - System.exit(1) } newState }