RFR: 8307858: [REDO] JDK-8307194 Add make target for optionally building a complete set of all JDK and hotspot libjvm static libraries [v2]

Erik Joelsson erikj at openjdk.org
Mon May 22 19:57:59 UTC 2023


On Mon, 22 May 2023 19:40:00 GMT, Jiangli Zhou <jiangli at openjdk.org> wrote:

>> Original description for JDK-8307194 change:
>> -----
>> This PR is branched from the makefile changes for https://bugs.openjdk.org/browse/JDK-8303796 and contains the following for handling the JDK/hotspot static libraries:
>> 
>>  - Build hotspot libjvm.a and JDK static libraries for static-libs-image/static-libs-bundles targets; This change does not affect the graal-builder-image target
>> 
>>  - For libjvm.a specifically, exclude operator_new.o
>> 
>> - Filter out "external" .o files (those are the .o files included from a different JDK library and needed when creating the .so shared library only) from JDK .a libraries; That's to avoid linker failures caused by duplicate symbols
>>   - For libjli.a: Not include inflate.o inftrees.o inffast.o zadler32.o zcrc32.o zutil.o (compiled from zlib sources) if zlib is built as JDK bundled
>>   - For libawt_xawt.a and libawt_head.a: Not include systemScale.o, since it's provided in libawt.a
>> 
>> - Handle long arguments case for static build in make/common/NativeCompilation.gmk
>> 
>> - Address @erikj79's comment in https://github.com/openjdk/jdk/pull/13709#discussion_r1180750185 for LIBJLI_STATIC_EXCLUDE_OBJS
>> -----
>> 
>> Updates to address build failures reported on macosx-<cpu> platforms:
>> 
>> - For gcc/clang, when building a static library first partially link (using the `-r` linking option) all object files into one object. The output object file from the partial linking is then passed to `ar` to create the static library. 
>> 
>> The original change for JDK-8307194 used @argument_file for all platforms when dealing with long arguments to `ar`, which caused failures on macosx-<cpu> builds. On darwin (https://www.unix.com/man-page/osx/1/ar/), `ar` does not support @argument_file. The updated change avoids using @argument_file for `ar`.
>> 
>> The partial linking change is done in make/common/NativeCompilation.gmk. The flag related change is done in make/autoconf/flags-ldflags.m4 mainly.
>
> Jiangli Zhou has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 12 commits:
> 
>  - Merge branch 'master' into JDK-8307858
>  - Merge branch 'master' into JDK-8307858
>  - Clean up.
>  - In clude $MACHINE_FLAG in partial linking flag.
>  - Use '-m32' instead of '-m elf_i386'.
>  - Use '-m elf_i386' for partial linking with gcc for linux 32-bit platform.
>    
>    It's based on the post on https://www.linuxquestions.org/questions/linux-software-2/relocatable-linking-on-x86-64-for-i386-872812/.
>  - Only do partial linking step with gcc/clang on 64-bit platform.
>    
>    There is a linking failure with linux-x86 build:
>    
>    /usr/bin/ld: relocatable linking with relocations from format elf32-i386 (/home/runner/work/jdk/jdk/build/linux-x86/hotspot/variant-server/libjvm/libgtest/objs/gmock-all.o) to format elf64-x86-64 (/home/runner/work/jdk/jdk/build/linux-x86/hotspot/variant-server/libjvm/libgtest/objs/libgtest_relocatable.o) is not supported
>  - Need to set $1_AR_OBJ_ARG to $$($1_LD_OBJ_ARG) instead of $1_LD_OBJ_ARG.
>  - Merge branch 'master' into JDK-8307858
>  - Revert src/java.desktop/linux/native/libjsound/PLATFORM_API_LinuxOS_ALSA_CommonUtils.c change.
>  - ... and 2 more: https://git.openjdk.org/jdk/compare/8474e693...fb945210

make/common/NativeCompilation.gmk line 1175:

> 1173: 
> 1174:   ifeq ($$($1_TYPE), STATIC_LIBRARY)
> 1175:     $1_VARDEPS := $$($1_AR) $$(ARFLAGS) $$($1_ARFLAGS) $$($1_LIBS) \

We also need to add some things to VARDEPS. Looks like at least `$$($1_LD)` and `$$($1_SYSROOT_LDFLAGS)` are needed. Maybe conditionally.

make/common/NativeCompilation.gmk line 1208:

> 1206: 	  $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_partial_link, \
> 1207: 	     $$($1_LD) $(LDFLAGS_CXX_PARTIAL_LINKING) $(LD_OUT_OPTION)$$($1_TARGET_RELOCATABLE) \
> 1208:                  $$($1_LD_OBJ_ARG))

This makes my build pass.
Suggestion:

	     $$($1_LD) $(LDFLAGS_CXX_PARTIAL_LINKING) $$($1_SYSROOT_LDFLAGS) \
	         $(LD_OUT_OPTION)$$($1_TARGET_RELOCATABLE) \
                 $$($1_LD_OBJ_ARG))

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14064#discussion_r1200980626
PR Review Comment: https://git.openjdk.org/jdk/pull/14064#discussion_r1200982365


More information about the core-libs-dev mailing list