Re: RFR: 8333268: Fixes for static build [v2]

2024-06-20 Thread Jiangli Zhou
On Tue, 18 Jun 2024 17:57:29 GMT, Magnus Ihse Bursie  wrote:

>> Magnus Ihse Bursie has updated the pull request with a new target base due 
>> to a merge or a rebase. The incremental webrev excludes the unrelated 
>> changes brought in by the merge/rebase. The pull request contains seven 
>> additional commits since the last revision:
>> 
>>  - Merge branch 'master' into static-linking-progress
>>  - Merge branch 'master' into static-linking-progress
>>  - Move the exported JVM_IsStaticallyLinked to a better location
>>  - Use runtime lookup of static vs dynamic instead of #ifdef STATIC_BUILD
>>  - Copy fix for init_system_properties_values on linux
>>  - Make sure we do not try to build static libraries on Windows
>>  - 8333268: Fixes for static build
>
> src/hotspot/os/linux/os_linux.cpp line 605:
> 
>> 603: 
>> 604:   // Get rid of /{client|server|hotspot}, if binary is libjvm.so.
>> 605:   // Or, cut off /.
> 
> @jianglizhou This code is based on changes in the Hermetic Java repo, but I 
> do not fully understand neither the comment nor what the purpose is. If you 
> could explain this a bit I'd be grateful.

The specific related commit in the hermetic Java branch is 
https://github.com/openjdk/leyden/commit/53aa8f0cf418ab5f435a4b9996c7754fb8505d4b.
 

The change in os_linux.cpp here is to make sure  that the libjvm.so related 
path manipulation is conditionally done only. The check at line 599 looks for 
"/libjvm.so" substring, so we only chop off (`*pslash = `\0` at line 601) that 
part when necessary. In the static JDK case, there is no `libjvm.so` and the 
path string is `/bin/javastatic`, which should not be affected. 
Otherwise, it could fail.

I found the code was not very easy to follow when running into problems and 
fixing for static support. So I added a bit more comments in the code here. The 
comment above about `/{client|server|hotspot}` was there originally. I think we 
no longer have those directories. We can cleanup that later, since it needs 
some more testing.

@magicus, thanks a lot for extracting/reworking/cleaning-up the static Java 
changes from the hermetic Java branch. That's a substantial amount of work!

I have one quick comment about the removal of `STATIC_LIB_EXCLUDE_OBJS` 
changes. Will post it as separate comment for the related code. 

I'll also look closely of the vm & jdk changes and compare those with the 
changes in the hermetic Java branch this week.

-

PR Review Comment: https://git.openjdk.org/jdk/pull/19478#discussion_r1648283151


Re: RFR: 8333268: Fixes for static build [v2]

2024-06-18 Thread Magnus Ihse Bursie
On Tue, 18 Jun 2024 16:19:39 GMT, Magnus Ihse Bursie  wrote:

>> This patch contains a set of changes to improve static builds. They will 
>> pave the way for implementing a full static-only java launcher. The changes 
>> here will:
>> 
>> 1) Make sure non-exported symbols are made local in the static libraries. 
>> This means that the risk of symbol conflict is the same for static libraries 
>> as for dynamic libraries (i.e. in practice zero, as long as a consistent 
>> naming scheme is used for exported functions).
>> 
>> 2) Remove the work-arounds to exclude duplicated symbols.
>> 
>> 3) Fix some code in hotspot and the JDK libraries that did not work properly 
>> with a static java launcher.
>> 
>> The latter fixes are copied from or inspired by the work done by 
>> @jianglizhou and her team as part of the Project Leyden [Hermetic 
>> Java](https://github.com/openjdk/leyden/tree/hermetic-java-runtime).
>
> Magnus Ihse Bursie has updated the pull request with a new target base due to 
> a merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains seven additional 
> commits since the last revision:
> 
>  - Merge branch 'master' into static-linking-progress
>  - Merge branch 'master' into static-linking-progress
>  - Move the exported JVM_IsStaticallyLinked to a better location
>  - Use runtime lookup of static vs dynamic instead of #ifdef STATIC_BUILD
>  - Copy fix for init_system_properties_values on linux
>  - Make sure we do not try to build static libraries on Windows
>  - 8333268: Fixes for static build

src/hotspot/os/linux/os_linux.cpp line 605:

> 603: 
> 604:   // Get rid of /{client|server|hotspot}, if binary is libjvm.so.
> 605:   // Or, cut off /.

@jianglizhou This code is based on changes in the Hermetic Java repo, but I do 
not fully understand neither the comment nor what the purpose is. If you could 
explain this a bit I'd be grateful.

-

PR Review Comment: https://git.openjdk.org/jdk/pull/19478#discussion_r1644855137


Re: RFR: 8333268: Fixes for static build [v2]

2024-06-18 Thread Magnus Ihse Bursie
> This patch contains a set of changes to improve static builds. They will pave 
> the way for implementing a full static-only java launcher. The changes here 
> will:
> 
> 1) Make sure non-exported symbols are made local in the static libraries. 
> This means that the risk of symbol conflict is the same for static libraries 
> as for dynamic libraries (i.e. in practice zero, as long as a consistent 
> naming scheme is used for exported functions).
> 
> 2) Remove the work-arounds to exclude duplicated symbols.
> 
> 3) Fix some code in hotspot and the JDK libraries that did not work properly 
> with a static java launcher.
> 
> The latter fixes are copied from or inspired by the work done by @jianglizhou 
> and her team as part of the Project Leyden [Hermetic 
> Java](https://github.com/openjdk/leyden/tree/hermetic-java-runtime).

Magnus Ihse Bursie has updated the pull request with a new target base due to a 
merge or a rebase. The incremental webrev excludes the unrelated changes 
brought in by the merge/rebase. The pull request contains seven additional 
commits since the last revision:

 - Merge branch 'master' into static-linking-progress
 - Merge branch 'master' into static-linking-progress
 - Move the exported JVM_IsStaticallyLinked to a better location
 - Use runtime lookup of static vs dynamic instead of #ifdef STATIC_BUILD
 - Copy fix for init_system_properties_values on linux
 - Make sure we do not try to build static libraries on Windows
 - 8333268: Fixes for static build

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/19478/files
  - new: https://git.openjdk.org/jdk/pull/19478/files/6b24a789..e1c46562

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=19478&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=19478&range=00-01

  Stats: 2608 lines in 114 files changed: 1321 ins; 955 del; 332 mod
  Patch: https://git.openjdk.org/jdk/pull/19478.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19478/head:pull/19478

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