RFR: 8371893: [macOS aarch64] use dead_strip linker option to reduce binary size
Matthias Baesken
mbaesken at openjdk.org
Thu Nov 20 14:42:28 UTC 2025
On Wed, 19 Nov 2025 18:53:34 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
> This seems to work:
>
> ```
> extern void* _ZTV8Metadata[];
>
> __attribute__((used))
> void* foo() {
> return _ZTV8Metadata[0];
> }
> ```
>
> You can put this anywhere since it does not reference any hotspot types. It just needs to be linked in with libjvm. Note I tried putting the "used" attribute on _ZTV8Metadata and getting rid of the foo() part, but I got the following warning and the vtable was dead stripped:
>
> `warning: 'used' attribute ignored on a non-definition declaration [-Wignored-attributes]`
Thanks for the testing and providing the workaround. Too bad that the 'retain' and 'used' are only function attributes, this makes things a bit harder.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28319#issuecomment-3558408585
More information about the build-dev
mailing list