On Fri, 28 Apr 2023 01:03:28 GMT, Jiangli Zhou <jian...@openjdk.org> wrote:

> Initial implementation for supporting building a fully statically linked 
> (with a desired set of JDK native libraries and libjvm) Java launcher 
> executable, which is named as 'javastatic'.
> 
> In this PR, the support is only added for the linux platform. Both gcc and 
> clang can be supported. For current demo/testing purpose, the bin/javastatic 
> is statically linked with awt headless and other common JDK native libraries. 
> The current PR doesn't fully handle creating the bundle for a static JDK 
> image, which can be supported later.
> 
> To build the statically linked executable:
> 
> 1. Configure the JDK build with --with-static-java=yes
> 2. Build static-java-image, e.g. 'make jdk-image static-java-image'
> 
>  The 'javastatic' binary created by the static-java-image target is not 
> runnable. The runtime issues will be handled separately.
> 
> Following is a summary of the changes in this PR:
> 
> - Add make/autoconf/static-java.m4 for defining STATIC_JAVA_SETUP. Add 
> STATIC_JAVA_SETUP to make/autoconf/configure.ac.
> 
> - Changes in make/Main.gmk
>   - Add HOTSPOT_VARIANT_STATIC_LIBS_TARGETS and 
> DeclareHotspotStaticLibsRecipe for building libjvm static library.
>   - Add static-java-image for creating the fully statically linked standard 
> Java launcher binary, bin/javastatic. The build process also places libjvm.a 
> into the 'static-libs' image lib/ directory.
> 
> - Add make/StaticLink.gmk, which contains the main support for creating the 
> fully statically linked Java launcher binary.
> 
> - Setup LDFLAGS_CXX_STATIC_JDK based on $TOOLCHAIN_TYPE in 
> make/autoconf/flags-ldflags.m4.
> 
> - Always use bundled libraries for zlib, freetype, etc for static build 
> support. The related changes are in make/autoconf/lib-bundled.m4 and 
> make/autoconf/lib-freetype.m4. Building the bundled zlib, freetype and etc 
> libraries ensures those libraries are included in the JDK binary bundle. It 
> decouples the assumptions/requirements of the static Java image build process 
> from the assumptions/requirements of the JDK build process. A post process 
> that builds the static Java image can use those bundled libraries provided by 
> JDK binary if needed.
> 
> - When building a fully statically linked java launcher executable, the 
> --whole-archive linker option is used for the JDK/VM static libraries to make 
> sure it links every object (.o) file provided by those static libraries. As a 
> result, we need to remove any duplicate object files from the different 
> JDK/VM static libraries. To do that, STATIC_LIB_EXCLUDE_OBJS is added and 
> used in make/common/Nativ...

This pull request has been closed without being integrated.

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

PR: https://git.openjdk.org/jdk/pull/13709

Reply via email to