Lib size almost does not change when doing custom build on iOS compared to Android

Hi Folks,

On master branch when doing custom build for Android I have got 40% decrease in Lib size (for libpytorch_jni.so). However when doing custom build for iOS with the same .yaml file I have got about 2.7% decrease (for libtorch_cpu.a).
I did custom builds as described here: https://pytorch.org/mobile/home/

I have also created following GitHub issue:
https://github.com/pytorch/pytorch/issues/35306

Regards,
Hovhannes

@hhov The size reduction happens when you link your static libraries to output the final binary, as linker can strip most of the unused code ( -dead_strip ). Unlike dynamic libraries(.so in Android), linker can’t strip code when compiling static libraries.

@xta0 Thanks for info. Besides comparing .a file sizes I also checked size as described here:https://stackoverflow.com/questions/32003262/find-size-contributed-by-each-external-library-on-ios/39593377
Both ways gave insignificant difference. I tried also with -dead_strip but seams XCode is already doing it.
After that I tried simply comparing final .ipa files and result was as expected, about 40% decrease in size.

1 Like