Skip to content

Commit

Permalink
Only single native image is built at a time (#11497)
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
Akirathan authored Nov 5, 2024
1 parent 73abe90 commit 3df5755
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions project/NativeImage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3df5755

Please sign in to comment.