oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.3k stars 1.63k forks source link

Fully static native images on linux/arm64 support #5872

Open axelfontaine opened 1 year ago

axelfontaine commented 1 year ago

As described in https://github.com/graalvm/container/issues/70 the blocker for being able to create fully static native images on linux/arm64 is GraalVM only supporting muslib on AMD64.

oubidar-Abderrahim commented 1 year ago

Hi, Thank you for your suggestion, we'll take a look at it shortly.

oubidar-Abderrahim commented 1 year ago

Tracked internally at GR 44077

tisonkun commented 10 months ago

@oubidar-Abderrahim do you have some ideas what concrete technical blockers are here?

That is, we are blocked because "GraalVM only supporting muslib on AMD64", so the next question is why GraalVM cannot support muslib on ARM64?

sdavids commented 3 weeks ago

This blocks development on current Apple hardware.

sdavids commented 3 weeks ago
$ sw_vers                                                                                           
ProductName:            macOS
ProductVersion:         14.7
BuildVersion:           23H124
$ uname -a                                                                                          
Darwin redacted 23.6.0 Darwin Kernel Version 23.6.0: Wed Jul 31 20:49:46 PDT 2024; root:xnu-10063.141.1.700.5~1/RELEASE_ARM64_T8103 arm64
$ java --version
openjdk 21.0.2 2024-01-16
OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30)
OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing)

$ echo 'public class Test{public static void main(String[] a){System.out.println(".");}}' >Test.java
$ javac Test.java

$ docker run --rm -v $PWD:/app ghcr.io/graalvm/native-image-community:21.0.2-muslib -march=native Test 
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 'test' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------

[1/8] Initializing...                                                                                    (0.0s @ 0.06GB)
Error: Missing CAP cache value for: NativeCodeInfo:JNIHeaderDirectivesJDK21OrLater:ConstantInfo:JNI_VERSION_21
------------------------------------------------------------------------------------------------------------------------
                        0.2s (2.8% of total time) in 13 GCs | Peak RSS: 0.47GB | CPU load: 2.18
========================================================================================================================
Finished generating 'test' in 4.3s.

$ docker run --rm --platform=linux/amd64 -v $PWD:/app ghcr.io/graalvm/native-image-community:21.0.2-muslib -march=native Test
========================================================================================================================
GraalVM Native Image: Generating 'test' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------

[1/8] Initializing...                                                                                    (0.0s @ 0.06GB)
Error: Missing CAP cache value for: NativeCodeInfo:AArch64LibCHelperDirectives:StructInfo:CPUFeatures
------------------------------------------------------------------------------------------------------------------------
                        0.2s (2.6% of total time) in 13 GCs | Peak RSS: 0.47GB | CPU load: 2.12
========================================================================================================================
Finished generating 'test' in 4.7s.

$ docker run --rm -v $PWD:/app ghcr.io/graalvm/native-image-community:21.0.2 -march=native Test
========================================================================================================================
GraalVM Native Image: Generating 'test' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------
[1/8] Initializing...                                                                                    (4.5s @ 0.06GB)
 Java version: 21.0.2+13, vendor version: GraalVM CE 21.0.2+13.1
 Graal compiler: optimization level: 2, target machine: native
 C compiler: gcc (redhat, aarch64, 11.4.1)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 1 user-specific feature(s):
 - com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
Build resources:
 - <redacted>
 - <redacted>
[2/8] Performing analysis...  [*****]                                                                   (16.8s @ 0.26GB)
    3,253 reachable types   (72.7% of    4,472 total)
    3,840 reachable fields  (50.1% of    7,660 total)
   15,754 reachable methods (45.5% of   34,593 total)
    1,030 types,    90 fields, and   676 methods registered for reflection
       57 types,    57 fields, and    52 methods registered for JNI access
        4 native libraries: dl, pthread, rt, z
[3/8] Building universe...                                                                               (1.3s @ 0.35GB)
[4/8] Parsing methods...      [*]                                                                        (1.0s @ 0.36GB)
[5/8] Inlining methods...     [***]                                                                      (0.9s @ 0.27GB)
[6/8] Compiling methods...    [***]                                                                      (7.8s @ 0.28GB)
[7/8] Layouting methods...    [*]                                                                        (0.8s @ 0.44GB)
[8/8] Creating image...       [*]                                                                        (1.1s @ 0.37GB)
   5.11MB (39.81%) for code area:     8,940 compilation units
   7.48MB (58.35%) for image heap:   97,372 objects and 48 resources
 242.52kB ( 1.85%) for other data
  12.83MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area:                                Top 10 object types in image heap:
   3.83MB java.base                                            1.59MB byte[] for code metadata
 941.92kB svm.jar (Native Image)                               1.29MB byte[] for java.lang.String
 108.34kB java.logging                                       978.09kB java.lang.String
  56.84kB org.graalvm.nativeimage.base                       755.32kB java.lang.Class
  43.64kB jdk.proxy1                                         279.55kB com.oracle.svm.core.hub.DynamicHubCompanion
  42.03kB jdk.proxy3                                         278.63kB byte[] for general heap data
  21.98kB org.graalvm.collections                            242.20kB java.util.HashMap$Node
  19.52kB jdk.internal.vm.ci                                 217.99kB java.lang.Object[]
  10.46kB jdk.proxy2                                         186.00kB java.lang.String[]
   8.03kB jdk.internal.vm.compiler                           156.38kB byte[] for reflection metadata
   2.95kB for 2 more packages                                  1.57MB for 908 more object types
------------------------------------------------------------------------------------------------------------------------
Recommendations:
 INIT: Adopt '--strict-image-heap' to prepare for the next GraalVM release.
 HEAP: Set max heap for improved and more predictable memory usage.
------------------------------------------------------------------------------------------------------------------------
                       4.0s (11.3% of total time) in 147 GCs | Peak RSS: 0.96GB | CPU load: 4.51
------------------------------------------------------------------------------------------------------------------------
Produced artifacts:
 /app/test (executable)
========================================================================================================================
Finished generating 'test' in 34.7s