RFR: 8311661: Resolve duplicate symbol of StringTable::StringTable with JDK static linking [v2]

Jiangli Zhou jiangli at openjdk.org
Tue Jul 11 23:00:14 UTC 2023

On Tue, 11 Jul 2023 22:38:10 GMT, Ioi Lam <iklam 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 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.


PR Comment: https://git.openjdk.org/jdk/pull/14808#issuecomment-1631611220

More information about the graal-dev mailing list