RFR: 8339480: Build static-jdk image with a statically linked launcher [v7]
Magnus Ihse Bursie
ihse at openjdk.org
Tue Oct 29 20:43:18 UTC 2024
On Thu, 24 Oct 2024 23:36:19 GMT, Jiangli Zhou <jiangli at openjdk.org> wrote:
>> Magnus Ihse Bursie has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Don't hardcode server variant
>
>> > > When trying to sort out the LDFLAGS issues, it turned out that I could not run the linux launcher at all, not even when checking out older commits of this PR. I am almost at a loss here; I assume that this worked when I created this PR (even though I only did ad hoc testing at the time), and I'm not sure if my testing then was inadequate or if something else has changed during that time with my environment.
>> > > I'm trying to retrace my steps in how I got to this branch, but I have unfortunately deleted much of the intermediate steps.
>> > > @jianglizhou Can you check if you can build and run a simple HelloWorld.java with the static launcher in this PR on linux? `images/static-jdk/bin/java --version` works for me, but not `images/static-jdk/bin/java HelloWorld.java`, which fails with an error that indicates it cannot locate the jimage library.
>> >
>> >
>> > @magicus I just noticed your above notes now (I'm been chasing an unrelated long G1 Evacuation Pause issue). I'll test your changes tomorrow. Will update you in the thread.
>>
>> Sorry for the delay. I finally found some time to look into this today. Running the latest `static-jdk` `bin/java` built from your branch fails for me as well:
>>
>> ```
>> $ bin/java
>> Error: failed , because bin/java: undefined symbol: JNI_CreateJavaVM
>> ```
>>
>> I only took a quick look, but I think this looks like https://bugs.openjdk.org/browse/JDK-8339522 that I filed in September.
>>
>> ```
>> $ nm bin/java | grep JNI_CreateJavaVM
>> 000000000162733c t JNI_CreateJavaVM
>> 0000000001626e75 t _ZL22JNI_CreateJavaVM_innerPP7JavaVM_PPvS2_
>> jianglizhou at leia:~/github/jdk_pull_20837/build/linux-x86_64-server-slowdebug/images/static-jdk$ nm -D bin/java | grep JNI_CreateJavaVM
>> ```
>>
>> The VM dynamic symbols are not exported properly. This is related to the [#20837 (comment)](https://github.com/openjdk/jdk/pull/20837#discussion_r1744611776) discussion comment thread.
>
> Checking the `ld` command line, I think it is indeed https://bugs.openjdk.org/browse/JDK-8339522 issue. `-Wl,--exclude-libs,ALL` is included in the command:
>
> $ cat ./support/static-native/launcher/BUILD_LAUNCHER_java_run_ld.cmdline
> /usr/bin/gcc -Wl,-z,defs -Wl,-z,relro -Wl,-z,now -Wl,--no-as-needed -Wl,-z,noexecstack -m64 -pie -Wl,-z,defs -Wl,-z,relro -Wl,-z,now -Wl,--no-as-needed -Wl,--exclude-libs,ALL -Wl,-z,noexecstack -m64 -Wl,-rpath,$ORIGIN -Wl,--disable-new-dtags -Wl,-rpath,$ORIGIN/../lib -Wl,--disable-new-dtags -o /...jianglizhou/github/jdk_pull_20837/build/...
@jianglizhou I fixed the bug with `-Wl,--exclude-libs,ALL` not being properly filtered out.
However, I still get the jimage problem:
$ build/linux-x64/images/static-jdk/bin/java closed/make/scripts/GenerateSecureId.java
Error: Unable to load main class com.sun.tools.javac.launcher.SourceLauncher in module jdk.compiler
Caused by: java.lang.UnsatisfiedLinkError: no jimage in system library path: /localhome/git/jdk-ALT/build/linux-x64/images/static-jdk/bin
Runtime.exit(1) logging failed: Could not initialize class jdk.internal.module.SystemModuleFinders$SystemImage
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20837#issuecomment-2445284962
More information about the build-dev
mailing list