From 3df57557ca8c901cec469134a1386e8fc9c729a4 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Tue, 5 Nov 2024 19:33:58 +0100 Subject: [PATCH] Only single native image is built at a time (#11497) #10783 introduced another definition of a buildnativeimage task. Since that time, our CI is transiently failing on out of memory error. This PR ensures that there can be just a single `buildNativeImage` task running at a time. # Important Notes Manually tested by running ``` sbt:enso> all engine-runner/buildNativeImage project-manager/buildNativeImage ``` And looking at spawn subprocesses. On develop, I have two `native-image` processes, on this PR, there is just a single one. --- build.sbt | 5 +++++ project/NativeImage.scala | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/build.sbt b/build.sbt index ad31a6a91884..2a7909868b8b 100644 --- a/build.sbt +++ b/build.sbt @@ -106,6 +106,11 @@ ThisBuild / publish / skip := true val simpleLibraryServerTag = Tags.Tag("simple-library-server") Global / concurrentRestrictions += Tags.limit(simpleLibraryServerTag, 1) +/** Tag limiting the concurrent spawning of `native-image` subprocess. + */ +val nativeImageBuildTag = NativeImage.nativeImageBuildTag +Global / concurrentRestrictions += Tags.limit(nativeImageBuildTag, 1) + lazy val gatherLicenses = taskKey[Unit]( "Gathers licensing information for relevant dependencies of all distributions" diff --git a/project/NativeImage.scala b/project/NativeImage.scala index f8cad68c3310..dbd911508cb5 100644 --- a/project/NativeImage.scala +++ b/project/NativeImage.scala @@ -49,6 +49,12 @@ object NativeImage { val NATIVE_IMAGE_ARG_FILE = "native-image-args.txt" + /** Tag limiting the concurrent access to `native-image` subprocess spawning, i.e., + * there should be just a single such subprocess. This should ensure that we do + * not run out of memory. + */ + val nativeImageBuildTag = Tags.Tag("native-image-build") + /** Creates a task that builds a native image for the current project. * * This task must be setup in such a way that the assembly JAR is built @@ -262,6 +268,7 @@ object NativeImage { } log.info(s"$targetLoc native image build successful.") } + .tag(nativeImageBuildTag) .dependsOn(Compile / compile) /** Creates a task which watches for changes of any compiled files or