quarkusio / quarkus-images

Set of container images delivered for Quarkus
Apache License 2.0
110 stars 75 forks source link

Native build stuck when running quay.io/quarkus/ubi-quarkus-mandrel:22.2-java11 on an M1 chip #210

Closed danielcamargoeti closed 1 year ago

danielcamargoeti commented 1 year ago

I am trying to create a native executable but the process hangs indefinitely (see output bellow). I am running it on macOS using an M1 chip.

I've heard people using ghcr.io/graalvm/graalvm-ce:latest but the binary file does not run using AWS SAM CLI (that is using this image ublic.ecr.aws/sam/emulation-provided).

I am not sure where to go from here. Here is the sample project I am working with:

...
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on native-image 22.2.0.0-Final Mandrel Distribution (Java Version 11.0.16+8)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm -v /Users/daniel.camargo.eti/Projects/Pocs/google-auth/target/google-auth-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --name build-native-TFtet quay.io/quarkus/ubi-quarkus-mandrel:22.2-java11 -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Duser.language=en -J-Duser.country=US -J-Dfile.encoding=UTF-8 --features=io.quarkus.runner.Feature,io.quarkus.runtime.graal.ResourcesFeature,io.quarkus.runtime.graal.DisableLoggingFeature -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED -J--add-opens=java.base/java.io=ALL-UNNAMED -J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -H:ResourceConfigurationFiles=resources-config.json -H:ReflectionConfigurationFiles=reflection-config.json --trace-object-instantiation=java.security.SecureRandom -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+AllowFoldMethods -J-Djava.awt.headless=true -H:FallbackThreshold=0 --link-at-build-time -H:+ReportExceptionStackTraces -J-Xmx2g -H:-AddAllCharsets -H:EnableURLProtocols=http -H:-UseServiceLoaderFeature -H:+StackTrace -J--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.localization=ALL-UNNAMED -J--add-exports=org.graalvm.nativeimage.base/com.oracle.svm.util=ALL-UNNAMED google-auth-1.0.0-SNAPSHOT-runner -jar google-auth-1.0.0-SNAPSHOT-runner.jar
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
========================================================================================================================
GraalVM Native Image: Generating 'google-auth-1.0.0-SNAPSHOT-runner' (executable)...
========================================================================================================================
[1/7] Initializing...                                                                                   (61.5s @ 0.23GB)
 Version info: 'GraalVM 22.2.0.0-Final Java 11 Mandrel Distribution'
 Java version info: '11.0.16+8'
 C compiler: gcc (redhat, x86_64, 8.5.0)
 Garbage collector: Serial GC
 4 user-specific feature(s)
 - io.quarkus.runner.Feature: Auto-generated class by Quarkus from the existing extensions
 - io.quarkus.runtime.graal.DisableLoggingFeature: Disables INFO logging during the analysis phase for the [org.jboss.threads] categories
 - io.quarkus.runtime.graal.ResourcesFeature: Register each line in META-INF/quarkus-native-resources.txt as a resource on Substrate VM
 - org.graalvm.home.HomeFinderFeature: Finds GraalVM paths and its version number
cescoffier commented 1 year ago

This image does not work on M1, you need to use the https://quay.io/repository/quarkus/ubi-quarkus-mandrel-builder-image image.

danielcamargoeti commented 1 year ago

@cescoffier changing to quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.2.0.0-Final-java11 does create the native build, but it is now using a format that won't run when running:

sam local invoke --template sam/sam.native.yaml --event sam/event.json

Here is the output:

Invoking not.used (provided)
Decompressing .../target/function.zip
Skip pulling image and use local one: public.ecr.aws/sam/emulation-provided:rapid-1.56.1-x86_64.

Mounting /private/var/folders/zm/0m9j6d_514q7sjpkgg6_7lzr0000gq/T/tmpi0ogn2dk as /var/task:ro,delegated inside runtime container
START RequestId: 472a007d-d5b4-4574-b3cb-9b87dde9d09a Version: $LATEST
28 Sep 2022 16:28:18,072 [ERROR] (rapid) Init failed error=fork/exec /var/task/bootstrap: no such file or directory InvokeID=

The file is in the container but with a bad ELF interpreter:

sh-4.2# ls /var/task/bootstrap 
/var/task/bootstrap
sh-4.2# exec /var/task/bootstrap 
sh: /var/task/bootstrap: /lib/ld-linux-aarch64.so.1: bad ELF interpreter: No such file or directory
cescoffier commented 1 year ago

Yes, you got an ARM 64 container, not a Linux 64 container. Cross-compilation is not supported by graalvm.

I'm working on a way to enable it using qemu, but I'm only at the beginning of the journey.

Karm commented 1 year ago

Hello, we have a new suite of both arm64 and amd64 Linux containers for Mandrel:

quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17
quay.io/quarkus/ubi-quarkus-mandrel-builder-image:21.3-java17

I tested both amd64 (Xeons, Skylake and Ivy Bridge EP) and aarch64 (Ampere Altra) variants on CentOS 8 Stream.

I don't have access to :apple: Silicon, you are welcome to give it a shot.