Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripts to build native binary (using a container) #1045

Closed
wants to merge 2 commits into from

Conversation

vorburger
Copy link
Member

@vorburger vorburger commented Feb 9, 2024

Fixes #894 and fixes #868!

As is, this doesn't work yet, launching ./build-natives.sh fails with:

[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.13:build (build-native) on project google-java-format: 'gu' tool wasn't found. This probably means that JDK at isn't a GraalVM distribution. -> [Help 1]

What this gu tool which apparently comes with a GraalVM distribution, but isn't included in a Graal container base image?!

@fmeum @cushon perhaps you would know and like to chime in here?

PS: This includes #1044, so don't "squash merge" this PR, but merge that one (1044) first, then "rebase merge" this one, and only the 2nd commit would be merged, and 1st one dropped. (Or I could rebase this after that is merged, so this is cleaner, if requested.)

@vorburger vorburger marked this pull request as draft February 9, 2024 17:23
@vorburger
Copy link
Member Author

What this gu tool which apparently comes with a GraalVM distribution, but isn't included in a Graal container base image?!

According to oracle/graal#1868, gu is no longer available / needed?

Perhaps bumping the version of org.graalvm.buildtools:native-maven-plugin helps? I'll try...

@vorburger vorburger force-pushed the native branch 2 times, most recently from f4a79ea to 0373cd8 Compare February 9, 2024 18:14
@vorburger
Copy link
Member Author

Hah! It now "works" - kind of. How cool is this?

To make this fully ready for review as-is, from my side, I would need to do some more work to change the script to not use volumes in docker build, which works for locally, for me, on Fedora, with Podman; but with Docker, on Debian in a GitHub action, apparently docker build cannot use volumes?! How dumb is that... But it should be possible to rewrite it differently, probably in the end using both docker build and docker run. (Or with multi stage images, e.g. as explained here or here; although that wouldn't really work for the cache I'm using.)

Before spending a bit more time to do that ^^^ I would love a signal from reviewers / project committers if this would be merged, when green?

@cushon @cpovirk

@vorburger vorburger force-pushed the native branch 3 times, most recently from ad87d2b to b8908dc Compare February 9, 2024 19:12
@vorburger
Copy link
Member Author

https://docs.docker.com/build/guide/mounts/ for RUN --mount=type=cache,target=/root/.m2/ is cute, and is another better more "native Docker" way to solve ^^^ this which I previously didn't know about but learnt here. (Nice job of your old colleagues @teivah! 👋🏽)

With that, this is now fully ready for review as-is, from my side.

This uses a container to simplify GraalVM installation.
@vorburger vorburger marked this pull request as ready for review February 9, 2024 20:45
@cushon cushon mentioned this pull request Feb 9, 2024
@cushon
Copy link
Collaborator

cushon commented Feb 9, 2024

Thanks for investigating this!

Is https://github.com/graalvm/setup-graalvm a potential alternative to using docker to set up GraalVM?

@vorburger
Copy link
Member Author

Is https://github.com/graalvm/setup-graalvm a potential alternative to using docker to set up GraalVM?

It might - I hadn't seen (searched for) that approach.

Why I personally prefer this route over a GitHub Actions based approach is that this make it very easy to use locally:

Anyone who has Docker, even e.g. on a Mac or Windows, can launch ./build-natives.sh - and, voilà, natives magically come out! Without needing to worry about having anything else installed. (The Mac or Windows cross compilation is orthogonal, of course.)

With GitHub Actions, it's "only possible on (and "locked into") GitHub", which... I personally don't like much.

What do you think?

@cushon
Copy link
Collaborator

cushon commented Feb 9, 2024

Thanks for the background. I think my preference here as a maintainer is to try to use the dependencies and process we already have, vs. replacing it with a new one. GitHub Actions isn't perfect, but one concrete benefit here is that it would provide a way to support mac binaries.

@vorburger
Copy link
Member Author

OK, makes sense; then I'll try that approach! Some other day though, and I'll raise a separate new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't build native image with GraalVM 22.3.0 Java 17 CE Release native builds
2 participants