Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce binary size #4

Closed
barsoosayque opened this issue Apr 2, 2020 · 1 comment
Closed

Reduce binary size #4

barsoosayque opened this issue Apr 2, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@barsoosayque
Copy link
Owner

barsoosayque commented Apr 2, 2020

As per the current version (0.2.2), the binary size (all ABIs combined) is about 12MB, which is huge. It is 100% possible to reduce that. Three things worth mentioning:

  • There is a binary size optimization flag in the configure script of FFmpeg. It disables performance optimizations, so it can be potentially harmful.
  • Build libgdx-oboe.so with LTO optimizations. I believe, this requires FFmpeg libs to be statically built, but that's not a problem.
  • Incorporate strip as a last built step; however, if I'm not mistaken, the NDK toolchain already does that.
@barsoosayque barsoosayque added the enhancement New feature or request label Apr 2, 2020
@barsoosayque barsoosayque self-assigned this Aug 4, 2020
@barsoosayque
Copy link
Owner Author

Here are some results:

  • I wasn't able to link static ffmpeg libraries, so LTO wasn't really an option here.
  • Binary size optimization flag didn't do much.
  • Using -O2 -flto=full -ffunction-sections -fdata-sections -fvisibility=hidden cxx/c flags along with --as-needed link flags were useful.
  • strip was super useful.

All in all, I got the library size cut down to 6.7 MB (-45%). I did everything I knew to reduce size, so if there any other method, reopen this issue / PR it !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant