Question about LDC and --gc-sections
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Oct 26 16:58:23 UTC 2018
On Friday, 26 October 2018 at 13:03:58 UTC, kinke wrote:
[...]
> What you could try is using an ld version script to override
> symbol visibility - create a little text file like this:
>
> ---
> CODEABI_1.0 {
> global: *entry_point*;
> local: *;
> };
> ---
>
> and then pass it to ld via `ldc2 ...
> -L--version-script=<path>`. It got the size down to ~900 KB for
> my dummy .so. Found here:
> http://anadoxin.org/blog/control-over-symbol-exports-in-gcc.html
Whoa. That did the trick!
Before: 6.1MB
After: 1.1MB
Not quite the 600KB of the executable, but good enough, in the
same ballpark. Now my APK is back down to a sane size (relative
to its contents)!
Thanks for the tip!!!
P.S. For anyone else interested in this: since I'm mainly calling
my D code from Java via JNI, I set up the version script to have
symbols of the form `Java_*` be marked global, and everything
else local. Then throw in --gc-sections, and voila, most of the
redundant symbols are gone. There are still a few that aren't,
I'm trying to track down where exactly they're referenced, but
most of the work has already been done.
More information about the Digitalmars-d
mailing list