On Thu, 13 Apr 2023 06:56:46 GMT, David Holmes <dhol...@openjdk.org> wrote:

> Is there not a way to stop these from being exported from the library, as I 
> assume they are not actually intended for external use. ??

Good question.

We could make those as weak symbols as long as there is no concern about 
portability. In our current prototype on JDK 11, we use weak symbol to help 
detect if we are dealing with a statically linked binary at runtime then handle 
some of the cases conditionally (dynamic vs. static). Around the end of last 
year, I became aware that there could be issues in some cases on macos with 
weak symbols (e.g. without '-undefined dynamic_lookup'). I'm planning to look 
into alternatives (besides using weak symbol) when porting the support to the 
latest OpenJDK code base.

Another approach is using 'objcopy' 
(https://web.mit.edu/gnu/doc/html/binutils_4.html) to localize the problematic 
symbols in the object file. It was suggested by our C++ colleague. We used that 
to hide symbols in libfreetype and libharfbuzz (there were problems when user 
code requires its own specific statically linked libfreetype and libharfbuzz 
due to versioning difference). So we first partially link all .o for the 
particular native library (in JDK) to form one .o file, then run 'objcopy' to 
localize the symbols. That hides the affected symbols during final link time. 
We had to do that since we don't control libfreetype and libharfbuzz. It worked 
for our specific case (for linux). It's probably not a general solution.

The direct renaming in this case seems to be more strait forward. Any thoughts?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13451#discussion_r1165975548

Reply via email to