RFR: 8339480: Build static-jdk image with a statically linked launcher [v7]

Magnus Ihse Bursie ihse at openjdk.org
Mon Oct 21 13:20:21 UTC 2024


On Tue, 15 Oct 2024 20:22:52 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

>> As a prerequisite for Hermetic Java, we need a statically linked `java` launcher. It should behave like the normal, dynamically linked `java` launcher, except that all JDK native libraries should be statically, not dynamically, linked.
>> 
>> This patch is the first step towards this goal. It will generate a `static-jdk` image with a statically linked launcher. This launcher is missing several native libs, however, and does therefore not behave like a proper dynamic java. One of the reasons for this is that local symbol hiding in static libraries are not implemented yet, which causes symbol clashes when linking all static libraries together. This will be addressed in an upcoming patch. 
>> 
>> All changes in the `src` directory are copied from, or inspired by, changes made in [the hermetic-java-runtime branch in Project Leyden](https://github.com/openjdk/leyden/tree/hermetic-java-runtime).
>
> 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.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/20837#issuecomment-2426658524


More information about the build-dev mailing list