container icon indicating copy to clipboard operation
container copied to clipboard

Native-Image cross-compilation from amd64 to arm64 fails on `gcc -v` check

Open agudian opened this issue 4 years ago • 2 comments

I want to create native images for both amd64 and arm64, and when I attempt that on my x86 machine (Mac), I start the image ghcr.io/graalvm/native-image:21.3 with --platform=linux/arm64.

Out of the box, this fails during the toolchain-check, as running gcc -v from within the Java process fails.

Adding this resolved the issue for me:

ENV JAVA_TOOL_OPTIONS="-Djdk.lang.Process.launchMechanism=vfork"

Should that be added to the graalvm-ce / native-image Docker images?

Btw, adding gcc variants with different target architectures and the related libs to the Docker image would be awesome - then I could run native-image in my home-architecture while creating native images in the target architecture without having to run the whole thing through qemu (which increases the build time by a factor of 20 for me).

agudian avatar Nov 26 '21 15:11 agudian

what do you mean by resolved the issue? did it really run flawlessly with just changing that? what about jni, reflection, etc... using qemu with kvm could make it much faster. but still, the best and cheap option for me was using a T2A instance in gcloud for the arm compilation.

benayat avatar Apr 21 '23 17:04 benayat

ENV JAVA_TOOL_OPTIONS="-Djdk.lang.Process.launchMechanism=vfork"

This doesn't solve the issue. I am creating a native image on my Mac M2 with the flag --platform=linux/amd64 and I get

[1/7] Initializing... (0.0s @ 0.31GB) Error: Collecting native-compiler info with '/usr/local/musl/bin/x86_64-linux-musl-gcc -v' failed Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain com.oracle.svm.core.util.UserError$UserException: Collecting native-compiler info with '/usr/local/musl/bin/x86_64-linux-musl-gcc -v' failed To prevent native-toolchain checking provide command-line option -H:-CheckToolchain

I am running the command inside a container from of image ghcr.io/graalvm/native-image:muslib-ol9-java17-22.3.2

justpolidor avatar May 01 '23 09:05 justpolidor