graalvm / setup-graalvm

GitHub Action for setting up GraalVM distributions.
https://www.graalvm.org
Universal Permissive License v1.0
192 stars 27 forks source link

Support for Liberica Native Image #76

Closed SimonScholz closed 6 months ago

SimonScholz commented 9 months ago

As of now the following distributions are available.

Is there any chance that the Liberica Native Image Kit will be added as well? I do use it to create native images for my tiny Swing application, which works quite well with the Liberica Native Image Kit, but unfortunately not for the other distributions.

fniephaus commented 9 months ago

Hi @SimonScholz, there are currently no plans to add Liberica, but it could be done if someone is willing to do the work.

Maybe this is also a use case for #61, which we haven't finished yet.

Your "tiny Swing application" builds fine with Liberica because it provides AWT metadata that happens to work for your app out of the box? Have you considered generating metadata specifically for your application? It should then be possible to build it with any GraalVM distribution, and the binaries may be even smaller. If you select graalvm (Oracle GraalVM), you could even build your app with G1 GC if latency is an issue.

SimonScholz commented 8 months ago

Have you considered generating metadata specifically for your application? It should then be possible to build it with any GraalVM distribution, and the binaries may be even smaller. If you select graalvm (Oracle GraalVM), you could even build your app with G1 GC if latency is an issue.

Well I already tried really hard with Oracle GraalVM and then gave up until I found Liberica, because I had one issue after another. I even made the actual native build work with Oracle GraalVM, but then at runtime it always crashed due to missing Fonts, which were not available in the JDK, and problems with the FontManager. I even tried to set the java.home programmatically, which is for some reason hard coded in the JDK for awt here: https://github.com/SimonScholz/qr-code-with-logo/blob/5ebe2678bd020f20d5286b77a14936835d2f4c39/qr-code-app/src/main/kotlin/io/github/simonscholz/Main.kt#L27

@fniephaus Do you maybe have a working example for the usage of the regular Oracle GraalVM together with Swing/AWT? Then I'd be delighted to try it out and use Oracle GraalVM instead of Liberica.

fniephaus commented 8 months ago

Well I already tried really hard with Oracle GraalVM and then gave up until I found Liberica, because I had one issue after another. I even made the actual native build work with Oracle GraalVM, but then at runtime it always crashed due to missing Fonts, which were not available in the JDK, and problems with the FontManager. I even tried to set the java.home programmatically, which is for some reason hard coded in the JDK for awt here: https://github.com/SimonScholz/qr-code-with-logo/blob/5ebe2678bd020f20d5286b77a14936835d2f4c39/qr-code-app/src/main/kotlin/io/github/simonscholz/Main.kt#L27

I had a quick look at your example application and it seems you've already tried using the tracing agent. I tried running it on my own and immediately ran into something we still need to finish. I'm surprised to learn that Liberica has somehow solved all those issue for you, but they ship a substantial amount of metadata that is relatively hard to maintain.

Do you maybe have a working example for the usage of the regular Oracle GraalVM together with Swing/AWT?

We currently recommend using the tracing agent, which does not seem to be enough to get your application working. However, we do have plans to improve this in the future. So please stay tuned or get in touch on Slack if you'd like to help :)

petermz commented 8 months ago

I'm going to look into adding Liberica as a new distribution. I'll submit a PR when it is ready.

fniephaus commented 8 months ago

Maybe you can re-use some of the Mandrel support, for example #67?

petermz commented 7 months ago

I'll definitely need an example to learn from, thanks!

Sorry for a lame question, but I can't wrap my head around dist/main/index.js. Was it generated by some tool? E.g. in const mandrel_1 = __nccwpck_require__(8766);, where does 8766 come from?

fniephaus commented 7 months ago

You may want to look at the template. The dist/ files are generated from the sources in src/.

fniephaus commented 6 months ago

Liberica is now available via v1.2.0.