graalvm / mandrel-packaging

6 stars 8 forks source link

Add support for libsvm_container.a in Mandrel #430

Closed jerboaa closed 4 months ago

jerboaa commented 4 months ago

Closes: https://github.com/graalvm/mandrel/issues/765

Depends on this upstream PR to be merged: https://github.com/oracle/graal/pull/8989

jerboaa commented 4 months ago

Depends on this upstream PR to be merged: oracle/graal#8989

I'll move the PR out of draft once that's merged.

jerboaa commented 4 months ago

Hello World from https://github.com/graalvm/mandrel/issues/765 works fine with this (libsvm_container.a part of the native link):

$ ./mandrel-build/bin/native-image -H:+TraceNativeToolUsage -cp mandrel-build HelloWorld
Warning: The option '-H:+TraceNativeToolUsage' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
Warning: Please re-evaluate whether any experimental option is required, and either remove or unlock it. The build output lists all active experimental options, including where they come from and possible alternatives. If you think an experimental option should be considered as stable, please file an issue.
========================================================================================================================
GraalVM Native Image: Generating 'helloworld' (executable)...
========================================================================================================================
>> /usr/bin/gcc -v    
># Using built-in specs.
># COLLECT_GCC=/usr/bin/gcc
># COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper
># OFFLOAD_TARGET_NAMES=nvptx-none
># OFFLOAD_TARGET_DEFAULT=1
># Target: x86_64-redhat-linux
># Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.3.1-20240522/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
># Thread model: posix
># Supported LTO compression algorithms: zlib zstd
># gcc version 13.3.1 20240522 (Red Hat 13.3.1-1) (GCC) 
>> /usr/bin/gcc -Wall -Werror -o /tmp/SVM-3945473757933258103/RISCV64LibCHelperDirectives /tmp/SVM-3945473757933258103/RISCV64LibCHelperDirectives.c
>> /usr/bin/gcc -Wall -Werror -I/disk/graal/upstream-sources/graal/mandrel-build/include/linux -o /tmp/SVM-3945473757933258103/JNIHeaderDirectivesJDKLatest /tmp/SVM-3945473757933258103/JNIHeaderDirectivesJDKLatest.c
>> /usr/bin/gcc -Wall -Werror -o /tmp/SVM-3945473757933258103/AArch64LibCHelperDirectives /tmp/SVM-3945473757933258103/AArch64LibCHelperDirectives.c
>> /usr/bin/gcc -Wall -Werror -o /tmp/SVM-3945473757933258103/PosixDirectives /tmp/SVM-3945473757933258103/PosixDirectives.c
>> /usr/bin/gcc -Wall -Werror -I/disk/graal/upstream-sources/graal/mandrel-build/include/linux -o /tmp/SVM-3945473757933258103/JNIHeaderDirectives /tmp/SVM-3945473757933258103/JNIHeaderDirectives.c
>> /usr/bin/gcc -Wall -Werror -o /tmp/SVM-3945473757933258103/BuiltinDirectives /tmp/SVM-3945473757933258103/BuiltinDirectives.c
>> /usr/bin/gcc -Wall -Werror -o /tmp/SVM-3945473757933258103/AMD64LibCHelperDirectives /tmp/SVM-3945473757933258103/AMD64LibCHelperDirectives.c
>> /usr/bin/gcc -Wall -Werror -o /tmp/SVM-3945473757933258103/ContainerLibraryDirectives /tmp/SVM-3945473757933258103/ContainerLibraryDirectives.c
[1/8] Initializing...                                                                                    (2.9s @ 0.22GB)
 Java version: 24-beta+3-ea, vendor version: Mandrel-24.2.0-dev1bea0be4cc32
 Graal compiler: optimization level: 2, target machine: x86-64-v3
 C compiler: gcc (redhat, x86_64, 13.3.1)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 1 user-specific feature(s):
 - com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
 1 experimental option(s) unlocked:
 - '-H:+TraceNativeToolUsage' (origin(s): command line)
------------------------------------------------------------------------------------------------------------------------
Build resources:
 - 26.49GB of memory (42.4% of 62.55GB system memory, determined at start)
 - 12 thread(s) (100.0% of 12 available processor(s), determined at start)
[2/8] Performing analysis...  [*****]                                                                    (6.7s @ 0.31GB)
    3,275 reachable types   (70.0% of    4,678 total)
    3,819 reachable fields  (43.2% of    8,842 total)
   15,406 reachable methods (43.8% of   35,191 total)
    1,026 types,    58 fields, and   374 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.49GB)
[4/8] Parsing methods...      [*]                                                                        (0.7s @ 0.49GB)
[5/8] Inlining methods...     [***]                                                                      (0.6s @ 0.51GB)
[6/8] Compiling methods...    [***]                                                                      (6.8s @ 0.49GB)
[7/8] Laying out methods...   [*]                                                                        (2.0s @ 0.38GB)
>> /usr/bin/gcc -z noexecstack -z text -Wl,--gc-sections -Wl,--version-script,/tmp/SVM-3945473757933258103/exported_symbols.list -Wl,-x -o /disk/graal/upstream-sources/graal/helloworld helloworld.o /disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64/glibc/liblibchelper.a /disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64/glibc/libsvm_container.a /disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc/libnet.a /disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc/libnio.a /disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc/libjava.a /disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc/libzip.a /disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64/glibc/libjvm.a -Wl,--export-dynamic -v -L/tmp/SVM-3945473757933258103 -L/disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc -L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64/glibc -L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64 -L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries -ldl -lpthread -lz -lrt
># Using built-in specs.
># COLLECT_GCC=/usr/bin/gcc
># COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper
># OFFLOAD_TARGET_NAMES=nvptx-none
># OFFLOAD_TARGET_DEFAULT=1
># Target: x86_64-redhat-linux
># Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.3.1-20240522/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
># Thread model: posix
># Supported LTO compression algorithms: zlib zstd
># gcc version 13.3.1 20240522 (Red Hat 13.3.1-1) (GCC) 
># COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/13/:/usr/libexec/gcc/x86_64-redhat-linux/13/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/13/:/usr/lib/gcc/x86_64-redhat-linux/
># LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/13/:/usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/13/../../../:/lib/:/usr/lib/
># COLLECT_GCC_OPTIONS='-z' 'noexecstack' '-z' 'text' '-o' '/disk/graal/upstream-sources/graal/helloworld' '-v' '-L/tmp/SVM-3945473757933258103' '-L/disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc' '-L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64/glibc' '-L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64' '-L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries' '-mtune=generic' '-march=x86-64' '-dumpdir' '/disk/graal/upstream-sources/graal/helloworld.'
>#  /usr/libexec/gcc/x86_64-redhat-linux/13/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/13/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper -plugin-opt=-fresolution=/tmp/ccCat3Vi.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /disk/graal/upstream-sources/graal/helloworld -z noexecstack -z text /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/13/crtbegin.o -L/tmp/SVM-3945473757933258103 -L/disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc -L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64/glibc -L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64 -L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries -L/usr/lib/gcc/x86_64-redhat-linux/13 -L/usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/13/../../.. --gc-sections --version-script /tmp/SVM-3945473757933258103/exported_symbols.list -x helloworld.o /disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64/glibc/liblibchelper.a /disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64/glibc/libsvm_container.a /disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc/libnet.a /disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc/libnio.a /disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc/libjava.a /disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc/libzip.a /disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64/glibc/libjvm.a --export-dynamic -ldl -lpthread -lz -lrt -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-redhat-linux/13/crtend.o /usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crtn.o
># COLLECT_GCC_OPTIONS='-z' 'noexecstack' '-z' 'text' '-o' '/disk/graal/upstream-sources/graal/helloworld' '-v' '-L/tmp/SVM-3945473757933258103' '-L/disk/graal/upstream-sources/graal/mandrel-build/lib/static/linux-amd64/glibc' '-L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64/glibc' '-L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries/linux-amd64' '-L/disk/graal/upstream-sources/graal/mandrel-build/lib/svm/clibraries' '-mtune=generic' '-march=x86-64' '-dumpdir' '/disk/graal/upstream-sources/graal/helloworld.'
>> objcopy --version
># GNU objcopy version 2.40-14.fc39
># Copyright (C) 2023 Free Software Foundation, Inc.
># This program is free software; you may redistribute it under the terms of
># the GNU General Public License version 3 or (at your option) any later version.
># This program has absolutely no warranty.
>> objcopy --strip-all --keep-symbols=/tmp/SVM-3945473757933258103/keep-symbols.list /disk/graal/upstream-sources/graal/helloworld
[8/8] Creating image...       [*]                                                                        (1.5s @ 0.42GB)
   5.25MB (40.15%) for code area:     8,796 compilation units
   7.22MB (55.22%) for image heap:   95,318 objects and 55 resources
 620.49kB ( 4.64%) for other data
  13.07MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area:                                Top 10 object types in image heap:
   3.93MB java.base                                            1.38MB byte[] for code metadata
 939.05kB svm.jar (Native Image)                               1.28MB byte[] for java.lang.String
 113.05kB java.logging                                       938.47kB java.lang.String
  69.38kB org.graalvm.nativeimage.base                       779.48kB java.lang.Class
  49.71kB jdk.proxy2                                         281.45kB com.oracle.svm.core.hub.DynamicHubCompanion
  39.69kB jdk.proxy1                                         280.02kB byte[] for general heap data
  26.87kB jdk.internal.vm.ci                                 255.89kB java.util.HashMap$Node
  20.35kB org.graalvm.collections                            222.39kB java.lang.Object[]
  12.17kB jdk.proxy3                                         183.13kB java.lang.String[]
   8.04kB jdk.graal.compiler                                 154.36kB byte[] for embedded resources
   1.92kB for 3 more packages                                  1.54MB for 932 more object types
------------------------------------------------------------------------------------------------------------------------
Recommendations:
 HEAP: Set max heap for improved and more predictable memory usage.
 CPU:  Enable more CPU features with '-march=native' for improved performance.
------------------------------------------------------------------------------------------------------------------------
                        0.8s (3.4% of total time) in 83 GCs | Peak RSS: 0.96GB | CPU load: 9.01
------------------------------------------------------------------------------------------------------------------------
Build artifacts:
 /disk/graal/upstream-sources/graal/helloworld (executable)
========================================================================================================================
Finished generating 'helloworld' in 23.3s.
jerboaa commented 4 months ago

https://github.com/oracle/graal/pull/8989 is merged now. Moving out of draft.