Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing static JDK libraries compiled against musl #4645

Closed
spockz opened this issue Jun 14, 2022 · 8 comments
Closed

Missing static JDK libraries compiled against musl #4645

spockz opened this issue Jun 14, 2022 · 8 comments
Assignees

Comments

@spockz
Copy link

spockz commented Jun 14, 2022

Describe the issue
I am trying to make a static image which, as per instructions, needs musl as the libc implementation. When doing this native-image fails, unable to find the static jdk libraries it needs in $JAVA_HOME/lib/static/linux-aarch64/musl. This directory is missing, only a glibc directory exists.

Steps to reproduce the issue
Please include both build steps as well as run steps

  1. **native-image -cp --verbose -H:+PrintClassInitialization --trace-class-initialization=io.netty.buffer,io.netty.handler.ssl --trace-class-initialization=io.netty.buffer.ByteBufUtil --trace-class-initialization=io.netty.handler.ssl.ReferenceCountedOpenSslContext --trace-object-instantiation=io.netty.handler.ssl.ReferenceCountedOpenSslContext -H:Optimize=3 --initialize-at-build-time=org.slf4j --initialize-at-build-time=ch.qos.logback --enable-https --enable-http --static --libc=musl --target=linux-aarch64 --native-compiler-path=/home/alessandro/Downloads/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc -H:Name=sidecar

Describe GraalVM and your environment:

  • GraalVM version: 22.1.0
  • JDK major version: 11,17
  • OS: Fedora 35
  • Architecture: AMD64 (cross-compiling for aarch64)
  • musl : 8695ff86979cdf30fbbcd33061711f5b1ebc3c48a87822b9ca56cde6d3a22abd4dab30fdcd1789ac27c6febbaeb9e5bde59d79d66552fae53d54cc1377a19272 aarch64-linux-musl-cross.tgz
  • zlib: 1.2.12
[1/7] Initializing...                                                                                    (0.0s @ 0.70GB)
Error: Building images for org.graalvm.nativeimage.Platform$LINUX_AARCH64 (target libc: musl) requires static JDK libraries.
Use most recent JDK from https://github.com/graalvm/labs-openjdk-*/releases
Missing libraries: java, nio, net, zip
(search path: /home/alessandro/.sdkman/candidates/java/22.1.0.r11-grl/lib/static/linux-aarch64/musl)
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception

@spockz
Copy link
Author

spockz commented Jun 14, 2022

It appears the files are taken from the JVMCI builds, https://github.com/graalvm/labs-openjdk-11/. Should this issue be moved there?

@oubidar-Abderrahim
Copy link
Member

I believe if you're cross-compiling, you'll need to install musl toolchain for aarch64 in your $TOOLCHAIN_DIR (as explained in https://www.graalvm.org/22.1/reference-manual/native-image/StaticImages/)

@oubidar-Abderrahim oubidar-Abderrahim self-assigned this Jun 21, 2022
@spockz
Copy link
Author

spockz commented Jun 24, 2022

@oubidar-Abderrahim yes, I did. However, that toolchain itself is generic. It doesn't contain the JDK-static libraries compiled against musl, those are only available for linux-amd64 in that download.

@cforce
Copy link

cforce commented Jan 3, 2023

I have the same issue for 22.3.r17

native-image --static --libc=musl -H:-CheckToolchain -H:+ReportExceptionStackTraces EnvMap
========================================================================================================================
GraalVM Native Image: Generating 'envmap' (static executable)...
========================================================================================================================
[1/7] Initializing...
                                                                                    (0.0s @ 0.16GB)
Error: Building images for org.graalvm.nativeimage.Platform$LINUX_AMD64 (target libc: musl) requires static JDK libraries.
Use most recent JDK from https://github.com/graalvm/labs-openjdk-*/releases
Missing libraries: java, nio, net, zip
(search path: /root/.sdkman/candidates/java/22.3.r17-nik/lib/static/linux-amd64/musl)
com.oracle.svm.core.util.UserError$UserException: Building images for org.graalvm.nativeimage.Platform$LINUX_AMD64 (target libc: musl) requires static JDK libraries.
Use most recent JDK from https://github.com/graalvm/labs-openjdk-*/releases
Missing libraries: java, nio, net, zip
(search path: /root/.sdkman/candidates/java/22.3.r17-nik/lib/static/linux-amd64/musl)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:73)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.guarantee(UserError.java:97)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.NativeLibraries.initCLibraryPath(NativeLibraries.java:350)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.NativeLibraries.<init>(NativeLibraries.java:264)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeLibraries(NativeImageGenerator.java:1119)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:915)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:575)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:535)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:403)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:580)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
------------------------------------------------------------------------------------------------------------------------
                         0.3s (5.9% of total time) in 6 GCs | Peak RSS: 0.47GB | CPU load: 1.87
========================================================================================================================
Failed generating 'envmap' after 3.7s.
Error: Image build request failed with exit status 1

We shall have a buildpack for this which can be used together with spring-boot-maven-plugin

The issue is with nik
sdk use java 22.3.r17-nik ->does NOT work
sdk use java 22.3.r17-grl ->woks

@cforce
Copy link

cforce commented Mar 13, 2023

Any news here .. when this will be fixed

@petermz
Copy link
Contributor

petermz commented Mar 13, 2023

The NIK issue has been fixed in 22.3.1. The original issue, I'm not sure. The instructions mentioned there imply that static linking against musl is not supported on ARM.

@cforce
Copy link

cforce commented Mar 13, 2023

Any builder image used in packets buildpack https://github.com/paketo-buildpacks/native-image is to recent in context of libc Version requirement that it simply can not be successful executed on aws lambda due to bindings to libc version not matched on lambda base images(to old) aws/aws-lambda-base-images#59 (comment)

How shall build and deploy to lambda using bionic /glibc 2.7

@oubidar-Abderrahim
Copy link
Member

If this issue is still relevant in the latest GraalVM versions, please create a new issue for it and follow the template provided. Thank you

@oubidar-Abderrahim oubidar-Abderrahim closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants