graalvm / mandrel

Mandrel is a downstream distribution of the GraalVM community edition. Mandrel's main goal is to provide a native-image release specifically to support Quarkus.
Other
396 stars 15 forks source link

[GraalVM for JDK 24] Add support for building based on a JDK that has JEP 493 enabled #808

Open jerboaa opened 1 day ago

jerboaa commented 1 day ago

Is your feature request related to a problem? Please describe. GraalVM currently doesn't build if the base JDK doesn't include jmods. For mandrel in particular, which does no jlinking, this must be optional. For GraalVM it should link from the run-time image instead (for JDK modules), but this needs to be investigated.

Describe the solution you'd like Allow mandrel builds to succeed with/without jmods being present in the base JDK.

Describe alternatives you've considered Require the jmods to be present. Yet, it would be nice to not need this. For example for Temurin 24, JEP 493 is enabled and jmods are not being provided (unless there is a strong reason to).

Additional context Example failing Windows build:

Compiling com.oracle.truffle.compiler with javac-daemon(JDK 24)... [D:\a\mandrel\mandrel\mandrel\truffle\mxbuild\jdk24\com.oracle.truffle.compiler\bin\com\oracle\truffle\compiler\ConstantFieldInfo.class does not exist]
Archiving WORD... [dependency org.graalvm.word updated]
Missing directory containing JMOD files: D:\a\mandrel\mandrel\openjdk\jmods
Building Java module org.graalvm.word (word.jar) from WORD

See: https://github.com/graalvm/mandrel/actions/runs/11944256969/job/33294889211#step:8:358

Enhancement on the Temurin side which enables JEP 493: https://github.com/adoptium/temurin-build/issues/4035

jerboaa commented 1 day ago

For the time being the steps to reproduce is to remove the jmods folder from a JDK 24 build and try to build mandrel from source. Since Mandrel doesn't perform any jlinking (uses upstream's --no-jlinking option to mx), this should succeed. No jlink involved whatsoever. Yet the build fails with:

[loading /modules/java.base/java/io/FilterOutputStream.class]
  File "/usr/lib64/python3.13/threading.py", line 1012, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib64/python3.13/threading.py", line 1041, in _bootstrap_inner
    self.run()
  File "/disk/graal/upstream-sources/mx/src/mx/_impl/mx.py", line 395, in run
    super(_DummyProcess, self).run()
  File "/usr/lib64/python3.13/threading.py", line 992, in run
    self._target(*self._args, **self._kwargs)
  File "/disk/graal/upstream-sources/mx/src/mx/_impl/mx.py", line 14694, in executeTask
    task.execute()
  File "/disk/graal/upstream-sources/mx/src/mx/_impl/build/tasks/build.py", line 165, in execute
    _built = self.build()
  File "/disk/graal/upstream-sources/mx/src/mx/_impl/mx.py", line 5090, in build
    self.subject.make_archive(getattr(self, 'javac_daemon', None))
  File "/disk/graal/upstream-sources/mx/src/mx/_impl/mx_jardistribution.py", line 339, in make_archive
    jmd = mx.make_java_module(self, jdk, stager.bin_archive, javac_daemon=javac_daemon)
  File "/disk/graal/upstream-sources/mx/src/mx/_impl/mx_javamodules.py", line 1093, in make_java_module
    mx.abort('Missing directory containing JMOD files: ' + jdk_jmods)
  File "/disk/graal/upstream-sources/mx/src/mx/_impl/support/logging.py", line 254, in abort
    traceback.print_stack()
Missing directory containing JMOD files: /disk/openjdk/builds/temurin-linkable-runtime/jdk-24+23/jmods
Archiving WORD: Failed due to error: 1
[loading /modules/java.base/java/io/Externalizable.class]
[loading /modules/java.base/java/util/Locale.class]
[2024-11-21T11:01:20.175727547Z:127.0.0.1] Shutting down
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Failed, exit code: 1
    at OperatingSystem.exec(build.java:1873)
    at SequentialBuild.lambda$build$0(build.java:650)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:186)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215)
    at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:722)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:153)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:176)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:636)
    at Mx.build(build.java:1075)
    at SequentialBuild.build(build.java:652)
    at build.main(build.java:88)
Caused by: java.lang.RuntimeException: Failed, exit code: 1
    at OperatingSystem.exec(build.java:1862)
    at SequentialBuild.lambda$build$0(build.java:650)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:186)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215)
    at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:722)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:153)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:176)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:636)
    at Mx.build(build.java:1075)
    at SequentialBuild.build(build.java:652)
    at build.main(build.java:88)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:565)
    at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.execute(SourceLauncher.java:269)
    at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.run(SourceLauncher.java:153)
    at jdk.compiler/com.sun.tools.javac.launcher.SourceLauncher.main(SourceLauncher.java:78)
jerboaa commented 1 day ago

This will require an upstream mx change to support it. Compilation of module-info.java files of GraalVM CE modules inherently assume jmods being present (for no good reason I argue).

jerboaa commented 1 day ago

Upstream MX issue: https://github.com/graalvm/mx/issues/286