RFR: 8311661: Resolve duplicate symbol of StringTable::StringTable with JDK static linking [v2]
Jiangli Zhou
jiangli at openjdk.org
Wed Jan 24 22:35:43 UTC 2024
On Wed, 24 Jan 2024 09:27:54 GMT, Andrew Haley <aph at openjdk.org> wrote:
> > I found a way to hide the unwanted symbols in libjvm.a. This requires `ld --relocatable` and `objcopy --keep-global-symbols=...`. See the prototype here:
> >
> > * https://github.com/iklam/tools/tree/main/misc/staticlib
> >
> > So potentially we can do this completely in the makefiles, without adding namespaces to HotSpot.
>
> Yeah, `objcopy` can be used to localize symbols. One of my colleague @cjmoon1 implemented symbol localizing for `libfreetype.a` and `libharfbuzz.a` for static linking issue. In some cases, user might want to link with a different version of the harfbuzz library than the version linked with the JDK code. Then multiple versions of the libraries could be linked together into the executable. That was a solution suggested by C++ experts and it worked. Doing partial linking that produces a single `.o` file simplifies the work of `objcopy`. This is not a very portable solution though.
Additional discussions in https://github.com/openjdk/jdk/pull/17456#issuecomment-1909019550 thread
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14808#issuecomment-1909021515
More information about the hotspot-dev
mailing list