Issue compiling quarkus native image on Apple Sillicon
Asked Answered
T

1

5

I tried running both Mandrel:

./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel:20.3.2.0-Final-java11

and GraalVM version:

./mvnw package -Pnative -Dquarkus.native.container-build=true  

but they just get stuck at building, I have the latest Docker for M1, this is a sample from mandrel on which it just stays there using 300% cpu:

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep]  docker run -v lambda-0.0.1-SNAPSHOT-native-image-source-jar:/project:z --env LANG=C --rm quay.io/quarkus/ubi-quarkus-mandrel:20.3.2.0-Final-java11 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dcom.mysql.cj.disableAbandonedConnectionCleanup=true -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 -J-Duser.language=en -J-Dfile.encoding=UTF-8 --report-unsupported-elements-at-runtime --enable-all-security-services --allow-incomplete-classpath -H:DynamicProxyConfigurationFiles=dynamic-proxies.json -H:ResourceConfigurationFiles=resources-config.json -H:ReflectionConfigurationFiles=reflection-config.json --initialize-at-run-time=com.common.utils -H:+ReportExceptionStackTraces --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -jar lambda-0.0.1-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:+AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services -H:-UseServiceLoaderFeature -H:+StackTrace lambda-0.0.1-SNAPSHOT-runner
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
[ithaca-creditcards-service-lambda-0.0.1-SNAPSHOT-runner:71]    classlist:  75,914.69 ms,  1.06 GB
[ithaca-creditcards-service-lambda-0.0.1-SNAPSHOT-runner:71]        (cap):   5,804.38 ms,  1.06 GB
[ithaca-creditcards-service-lambda-0.0.1-SNAPSHOT-runner:71]        setup:  18,307.33 ms,  1.06 GB
02:57:58,598 INFO  [org.hib.val.int.uti.Version] HV000001: Hibernate Validator 6.1.6.Final
02:57:59,639 INFO  [org.hib.Version] HHH000412: Hibernate ORM core version 5.4.24.Final
02:57:59,679 INFO  [org.hib.ann.com.Version] HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
02:57:59,894 INFO  [org.hib.dia.Dialect] HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
02:58:02,539 INFO  [org.hib.orm.beans] HHH10005002: No explicit CDI BeanManager reference was passed to Hibernate, but CDI is available on the Hibernate ClassLoader.
Tabbatha answered 30/4, 2021 at 16:39 Comment(4)
I have the same issue on an M1 Mac currently. Did you resolve this?Encrata
I couldn't find a solution unfortunately, currently building quarkus native projects on amd64 machinesTabbatha
Thanks very much for letting me know, I'll do the same for now. I'll update here if I ever find a solution.Encrata
This should be the reason: github.com/oracle/graal/issues/2666Assemblyman
B
6

First create docker file for GraalVM image:

FROM ghcr.io/graalvm/graalvm-ce:22 as build
RUN gu install native-image
WORKDIR /project
VOLUME ["/project"]
ENTRYPOINT ["native-image"]

Save this file as Dockerfile.graalvm. Then build the GraalVM image using it

docker build -f src/main/docker/Dockerfile.graalvm -t graalvm .

Now you have GraalVM image and can build quarkus Linux image

./mvnw package -Pnative  -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=graalvm

The runner, that has been created is 64-bit ARM aarch64 executable and can be used to create a docker container

docker build -f src/main/docker/Dockerfile.native -t quarkus/your-app . 

And finally run it

docker run --rm -p 8080:8080 quarkus/your-app
Barge answered 6/3, 2022 at 8:2 Comment(1)
I use gradle and for gradle instead of mvn it is gradle build -Dquarkus.package.type=native -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=graalvm:latestLafferty

© 2022 - 2024 — McMap. All rights reserved.