RFR: 8338768: Introduce runtime lookup to check for static builds [v2]

Magnus Ihse Bursie ihse at openjdk.org
Wed Aug 28 12:47:19 UTC 2024


On Tue, 27 Aug 2024 23:15:03 GMT, Jiangli Zhou <jiangli at openjdk.org> wrote:

>> And the discussion whether the checks are made "dynamically" or "statically" is too simplified to be really helpful.
>> 
>> Currently, we compile two sets of all object files, with slightly different compiler arguments, one for dynamic libraries and one for static libraries. Files that are doing things differently for these two modes have an #ifdef, so the alternative way of doing things are not included in the object file. 
>> 
>> In your branch, you still have a separate compilation of all files for static builds, but you also try to figure out through various means (which involves jumping through some hoops to get the bootstrapping right) if this is a static build or a dynamic build. In a way, one could argue that this is just worse than the current solution, since you are still recompiling all files separately for static libraries so you could "know" at build time if you are static or not.
>> 
>> What I am trying to do is to get to a point where we can compile almost all files just once, and then have two trivially small files that are compiled twice, with just a different value of a define that makes the difference. To propagate this information to all other object files, they need to call the function provided in this object file. So, is it then a "build time" lookup or a "runtime lookup", or a "static lookup" vs "dynamic lookup"? The semantics does not really matter. The whole point is that the difference in build is reduced to an absolute minimum. Sure, this single "lookup" function could be created more like the way you are doing in your branch to try to figure this out without the help of the build system, but there is really no point in that. This is a simple and elegant solution.
>
> @magicus please also specify contributor properly to so it's clear part of the change is based on/extracted from https://github.com/openjdk/leyden/tree/hermetic-java-runtime.

@jianglizhou Are there any other authors on the `hermetic-java-runtime` branch that should be credited?

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

PR Comment: https://git.openjdk.org/jdk/pull/20666#issuecomment-2315222006


More information about the core-libs-dev mailing list