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

Runtime size increase caused by NDK update #936

Closed
mhsmith opened this issue Aug 18, 2023 · 2 comments
Closed

Runtime size increase caused by NDK update #936

mhsmith opened this issue Aug 18, 2023 · 2 comments
Labels
Milestone

Comments

@mhsmith
Copy link
Member

mhsmith commented Aug 18, 2023

The runtime build recently changed from NDK version 22.1.7171670 to 23.2.8568313, to avoid having to install it on the GitHub Actions runner. However, this has caused a significant increase in the size of all .so files in a release build.

See if this can be improved by moving to an even newer version.

Related:

@mhsmith mhsmith added this to the 15.0 milestone Aug 18, 2023
@mhsmith mhsmith added the bug label Aug 18, 2023
@mhsmith
Copy link
Member Author

mhsmith commented Oct 10, 2023

We'll have to move to a newer version anyway now, because NDK version 23 will be removed from the GitHub runners on October 9 (actions/runner-images#8383).

@mhsmith
Copy link
Member Author

mhsmith commented Nov 17, 2023

Af first I thought it was these changes in NDK r23b:

To reduce per-arch differences and behavior differences compared to CMake's defaults, -Oz use was removed. You may see code size increases for armeabi-v7a due to this, but also increased optimization.

if using CMAKE_BUILD_TYPE=Release, your optimization type will likely be -O3 instead of -O2 or -Oz. See Issue 1536 for more information.

For which the suggested workaround is "being explicit and telling CMake that you want MinSizeRel and not Release".

But then in r23c, when they switched back to the "legacy toolchain file" (which despite its name, will be the only recommended option for the foreseeable future), they accidentally disabled optimization completely in Release mode (android/ndk#1740). They didn't notice this at first, because AGP uses RelWithDebInfo mode by default. But we don't use AGP to do these builds.

Sizes from du -Ak:

NDK 22.1.7171670, CMAKE_BUILD_TYPE=Release:

778     chaquopy-15.0.1-3.8-arm64-v8a.so
417     chaquopy-15.0.1-3.8-armeabi-v7a.so
745     chaquopy-15.0.1-3.8-x86.so
798     chaquopy-15.0.1-3.8-x86_64.so

NDK 23.2.8568313, CMAKE_BUILD_TYPE=Release:

960     chaquopy-15.0.1-3.8-arm64-v8a.so
661     chaquopy-15.0.1-3.8-armeabi-v7a.so
1252    chaquopy-15.0.1-3.8-x86.so
1135    chaquopy-15.0.1-3.8-x86_64.so

NDK 26.1.10909125, CMAKE_BUILD_TYPE=Release:

802     chaquopy-15.0.1-3.8-arm64-v8a.so
552     chaquopy-15.0.1-3.8-armeabi-v7a.so
745     chaquopy-15.0.1-3.8-x86.so
794     chaquopy-15.0.1-3.8-x86_64.so

mhsmith added a commit that referenced this issue Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant