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.21k stars 1.62k forks source link

native-image failing on aarch64 with: Cannot run program ... PosixDirectives ... error=13, Permission Denied #2727

Closed petergeneric closed 5 months ago

petergeneric commented 4 years ago

Describe the issue

native-image is failing to process a simple program with no external dependencies that uses ProcessBuilder/Files.lines on aarch64 with 20.1.0. Builds fine on AMD64.

Error I get from native-image is:

Fatal error:com.oracle.svm.core.util.VMError$HostedError: java.io.IOException: Cannot run program "/tmp/SVM-2805127498358634798/PosixDirectives" (in directory "/tmp/SVM-2805127498358634798"): error=13, Permission denied

Steps to reproduce the issue

  1. git clone https://github.com/petergeneric/unifi-protect-remux
  2. make native-image

Describe GraalVM and your environment: OS: Ubuntu Linux 18.04.4 LTS Architecture: ARM64 openjdk version "11.0.7" 2020-04-14 OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02) OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode)

More details

$ native-image --no-fallback --native-image-info --verbose -cp target/*.jar Remux
Build on Server(pid: 18256, port: 41877)
SendBuildRequest [
-task=com.oracle.svm.hosted.NativeImageGeneratorRunner
-imagecp
/opt/graal/graalvm-ce-java11-20.1.0/lib/svm/builder/llvm-platform-specific-shadowed.jar:/opt/graal/graalvm-ce-java11-20.1.0/lib/svm/builder/javacpp-shadowed.jar:/opt/graal/graalvm-ce-java11-20.1.0/lib/svm/builder/svm-llvm.jar:/opt/graal/graalvm-ce-java11-20.1.0/lib/svm/builder/objectfile.jar:/opt/graal/graalvm-ce-java11-20.1.0/lib/svm/builder/svm.jar:/opt/graal/graalvm-ce-java11-20.1.0/lib/svm/builder/llvm-wrapper-shadowed.jar:/opt/graal/graalvm-ce-java11-20.1.0/lib/svm/builder/pointsto.jar:/opt/graal/graalvm-ce-java11-20.1.0/lib/svm/library-support.jar:/home/user/unifi-protect-remux/target/remux-1.0-SNAPSHOT.jar
-H:Path=/home/user/unifi-protect-remux
-H:FallbackThreshold=0
-H:+DumpTargetInfo
-H:CLibraryPath=/opt/graal/graalvm-ce-java11-20.1.0/lib/svm/clibraries/linux-aarch64
-H:Class=Remux
-H:Name=remux
]
[remux:18256]    classlist:     232.44 ms,  0.96 GB
[remux:18256]        (cap):     478.32 ms,  0.96 GB
[remux:18256]        setup:     629.71 ms,  0.96 GB
Fatal error:com.oracle.svm.core.util.VMError$HostedError: java.io.IOException: Cannot run program "/tmp/SVM-2805127498358634798/PosixDirectives" (in directory "/tmp/SVM-2805127498358634798"): error=13, Permission denied
    at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:72)
    at com.oracle.svm.hosted.c.CAnnotationProcessor.makeQuery(CAnnotationProcessor.java:125)
    at com.oracle.svm.hosted.c.CAnnotationProcessor.process(CAnnotationProcessor.java:101)
    at com.oracle.svm.hosted.c.NativeLibraries.finish(NativeLibraries.java:503)
    at com.oracle.svm.hosted.NativeImageGenerator.processNativeLibraryImports(NativeImageGenerator.java:1527)
    at com.oracle.svm.hosted.NativeImageGenerator.setupNativeLibraries(NativeImageGenerator.java:1027)
    at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:856)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:536)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:451)
    at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: java.io.IOException: Cannot run program "/tmp/SVM-2805127498358634798/PosixDirectives" (in directory "/tmp/SVM-2805127498358634798"): error=13, Permission denied
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
    at com.oracle.svm.hosted.c.CAnnotationProcessor.makeQuery(CAnnotationProcessor.java:116)
    ... 13 more
Caused by: java.io.IOException: error=13, Permission denied
    at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
    at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
    at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
    ... 15 more
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
    at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1541)
    at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1299)
    at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1260)
    at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1219)
    at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1722)
SergejIsbrecht commented 4 years ago

@petergeneric , what happens, when you run the native-image with sudo? To me it looks like, it is an permission issue on you linux system.

petergeneric commented 4 years ago

Running this today with/without sudo gives me different results than yesterday - the same permission denied error, but it's a different file being listed. Example:

With sudo:

[remux:2338]    classlist:   4,079.85 ms,  0.96 GB
[remux:2338]        (cap):     663.84 ms,  0.96 GB
[remux:2338]        setup:   1,842.65 ms,  0.96 GB
Fatal error:com.oracle.svm.core.util.VMError$HostedError: java.io.IOException: Cannot run program "/tmp/SVM-9651287018676379936/LibFFIHeaderDirectives" (in directory "/tmp/SVM-9651287018676379936"): error=13, Permission denied

Without sudo:

[remux:3692]    classlist:   4,097.16 ms,  0.96 GB
[remux:3692]        (cap):     613.58 ms,  0.96 GB
[remux:3692]        setup:   1,791.24 ms,  0.96 GB
Fatal error:com.oracle.svm.core.util.VMError$HostedError: java.io.IOException: Cannot run program "/tmp/SVM-5312035683829760953/AArch64LibCHelperDirectives" (in directory "/tmp/SVM-5312035683829760953"): error=13, Permission denied

Is there any way to get native-image to leave behind all these files in /tmp for inspection to see what's going on?

SergejIsbrecht commented 4 years ago

Interesting, it does not link on Ubuntu X86 either:

[remux:159752]    classlist:   1,315.60 ms,  0.96 GB
[remux:159752]        (cap):     584.16 ms,  0.96 GB
[remux:159752]        setup:   1,683.05 ms,  0.96 GB
# Building image for target platform: org.graalvm.nativeimage.Platform$LINUX_AMD64
# Using native toolchain:
#   Name: GNU project C and C++ compiler (gcc)
#   Vendor: linux
#   Version: 9.3.0
#   Target architecture: x86_64
#   Path: /usr/bin/gcc
# Using CLibrary: com.oracle.svm.core.c.libc.GLibc
[remux:159752]     (clinit):     246.66 ms,  1.70 GB
# Static libraries:
#   ../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/liblibchelper.a
#   ../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/libnet.a
#   ../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libstrictmath.a
#   ../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libffi.a
#   ../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/libnio.a
#   ../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/libjava.a
#   ../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libjvm.a
#   ../../../../.sdkman/candidates/java/20.1.0.r11-grl/lib/libzip.a
# Other libraries: pthread,dl,z,rt
[remux:159752]   (typeflow):   7,526.78 ms,  1.70 GB
[remux:159752]    (objects):   7,523.07 ms,  1.70 GB
[remux:159752]   (features):     289.09 ms,  1.70 GB
[remux:159752]     analysis:  16,012.26 ms,  1.70 GB
[remux:159752]     universe:     404.65 ms,  1.70 GB
[remux:159752]      (parse):   1,133.65 ms,  1.71 GB
[remux:159752]     (inline):   1,727.42 ms,  2.27 GB
[remux:159752]    (compile):   8,232.03 ms,  2.50 GB
[remux:159752]      compile:  11,713.65 ms,  2.50 GB
[remux:159752]        image:   1,325.93 ms,  2.51 GB
[remux:159752]        write:     115.43 ms,  2.51 GB
Fatal error:java.lang.RuntimeException: java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1

Based on the linker command output, possible reasons for this include:
1. It appears as though libz.a is missing. Please install it.

Linker command executed:
/usr/bin/gcc -z noexecstack -Wl,--gc-sections -Wl,--dynamic-list -Wl,/tmp/SVM-2282483482469791503/exported_symbols.list -Wl,--exclude-libs,ALL -Wl,-x -o /home/sergej/Development/GitHub/unifi-protect-remux/remux /tmp/SVM-2282483482469791503/remux.o /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/liblibchelper.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libnet.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libstrictmath.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libffi.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libnio.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libjava.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libjvm.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libzip.a -v -L/tmp/SVM-2282483482469791503 -L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib -L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64 -lpthread -ldl -lz -lrt 

Linker command ouput:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2) 
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-z' 'noexecstack' '-o' '/home/sergej/Development/GitHub/unifi-protect-remux/remux' '-v' '-L/tmp/SVM-2282483482469791503' '-L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib' '-L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccImBKcz.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 --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o /home/sergej/Development/GitHub/unifi-protect-remux/remux -z noexecstack /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/tmp/SVM-2282483482469791503 -L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib -L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64 -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. --gc-sections --dynamic-list /tmp/SVM-2282483482469791503/exported_symbols.list --exclude-libs ALL -x /tmp/SVM-2282483482469791503/remux.o /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/liblibchelper.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libnet.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libstrictmath.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libffi.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libnio.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libjava.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libjvm.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libzip.a -lpthread -ldl -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-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status

    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:600)
    at java.base/java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1006)
    at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:463)
    at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:359)
    at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:518)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.executeCompilation(NativeImageBuildServer.java:406)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.lambda$processCommand$8(NativeImageBuildServer.java:343)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.withJVMContext(NativeImageBuildServer.java:424)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.processCommand(NativeImageBuildServer.java:340)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.processRequest(NativeImageBuildServer.java:284)
    at com.oracle.svm.hosted.server.NativeImageBuildServer.lambda$serve$7(NativeImageBuildServer.java:244)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.RuntimeException: There was an error linking the native image: Linker command exited with 1

Based on the linker command output, possible reasons for this include:
1. It appears as though libz.a is missing. Please install it.

Linker command executed:
/usr/bin/gcc -z noexecstack -Wl,--gc-sections -Wl,--dynamic-list -Wl,/tmp/SVM-2282483482469791503/exported_symbols.list -Wl,--exclude-libs,ALL -Wl,-x -o /home/sergej/Development/GitHub/unifi-protect-remux/remux /tmp/SVM-2282483482469791503/remux.o /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/liblibchelper.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libnet.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libstrictmath.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libffi.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libnio.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libjava.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libjvm.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libzip.a -v -L/tmp/SVM-2282483482469791503 -L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib -L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64 -lpthread -ldl -lz -lrt 

Linker command ouput:
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.3.0-10ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2) 
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/9/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-z' 'noexecstack' '-o' '/home/sergej/Development/GitHub/unifi-protect-remux/remux' '-v' '-L/tmp/SVM-2282483482469791503' '-L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib' '-L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/9/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/9/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper -plugin-opt=-fresolution=/tmp/ccImBKcz.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 --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o /home/sergej/Development/GitHub/unifi-protect-remux/remux -z noexecstack /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/tmp/SVM-2282483482469791503 -L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib -L/home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64 -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/9/../../.. --gc-sections --dynamic-list /tmp/SVM-2282483482469791503/exported_symbols.list --exclude-libs ALL -x /tmp/SVM-2282483482469791503/remux.o /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/liblibchelper.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libnet.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libstrictmath.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libffi.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libnio.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libjava.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/svm/clibraries/linux-amd64/libjvm.a /home/sergej/.sdkman/candidates/java/20.1.0.r11-grl/lib/libzip.a -lpthread -ldl -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-linux-gnu/9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status

    at com.oracle.svm.hosted.image.NativeBootImageViaCC.handleLinkerFailure(NativeBootImageViaCC.java:423)
    at com.oracle.svm.hosted.image.NativeBootImageViaCC.write(NativeBootImageViaCC.java:398)
    at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:663)
    at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:451)
    at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
    at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1541)
    at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1299)
    at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1260)
    at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1219)
    at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1722)
petergeneric commented 4 years ago

Aha, this issue must be something to do with how my original ARM system is configured - it's an nVidia Jetson Xavier (ARMv8 Tegra) running a mostly stock install of Ubuntu from nVidia's installer. However, if I run this build on a Raspberry Pi 4 then I encounter the "cannot find -lz" error just like you do, and once I run "apt install zlib1g-dev" it builds fine on the Raspberry Pi... which is a lot slower but good enough for all I need to build, so this issue can probably be closed on the assumption that the original issue on the nVidia ARM chip is actually user error - although it would be nice if the error message that had been spit out from native-image was better!

realJayNay commented 2 years ago

-H:CLibraryPath=* Search path for C libraries passed to the linker (list of comma-separated directories).

Ortega-Dan commented 2 years ago

HI I just want to add that based on the output you had showing: 1. It appears as though libz.a is missing. Please install it. It was not linking successfully because it was missing libz, in Ubuntu I got it installed with: sudo apt install zlib1g-dev and after that it worked perfectly for me.

mo-rjr commented 2 years ago

I was getting the same missing libz.a error on Amazon Linux (which is based on Red Hat) although I already had glibc-devel.x86_64 installed. It started working after I tried installing zib-static and glic-static as suggested in one of the comments on this page https://serverfault.com/questions/481859/usr-bin-ld-cannot-find-lz-but-libz-exists

andreaippo commented 6 months ago

Hello, just chiming in to give back to the community as well :)

On opensuse-tumbleweed, the missing package was zlib-devel.

Build was successful after a sudo zypper install zlib-devel

sivanagireddyb commented 5 months ago

@petergeneric Did you find sollution ?

petergeneric commented 5 months ago

@petergeneric Did you find sollution ?

No, I gave up on graal and switched to Go. Given this, my original steps to reproduce will no longer be valid - and since I am no longer interested in graal I'm going to close this ticket so that current graal users can create their own issue.