| Summary: | Android : size of the library could be reduced. | ||
|---|---|---|---|
| Product: | SDL_image | Reporter: | Sylvain <sylvain.becker> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | minor | ||
| Priority: | P2 | CC: | denis, gabomdq |
| Version: | unspecified | ||
| Hardware: | ARM | ||
| OS: | Android (All) | ||
| Attachments: | patch on Android.mk | ||
|
Description
Sylvain
2013-08-21 15:59:40 UTC
If you can contribute a patch I would gladly look at it. I looked at it, find no real difference. Replacing -O3 by -Os would make the library go from 460ko to 320ko. -fprefetch-loop-arrays could be removed as it produced a warning saying the option is ignored. BTW, there are three Android.mk SDL_image/Android.mk SDL_image/externals/libpng/Android.mk SDL_image/externals/jpeg/Android.mk But the SDL_image/Android.mk includes directly the png/jpg source, so, the presence of the other Android.mk is confusing. ... To be confirmed, but it seems that compiling separatly SDL_image (shared) / jpeg (static) and libpng (static) make an even smaller library 320 ko -> 250 ko. --- It is also possible to remove the WRITE support from PNG (pnglibconf.h & scripts) for 30 ko ... --- Then the libraries png/jpeg from Pelya are older and also smaller. Hello, Here's what I am doing to get the SDL_image compiled with libraries : externals libraries are built independently with : ndk-build APP_BUILD_SCRIPT=jni/SDL_image_hg/external/libpng-1.6.2/Android.mk ndk-build APP_BUILD_SCRIPT=jni/SDL_image_hg/external/jpeg-9/Android.mk For jpeg/Android.mk and libpng/Android.mk : add -Os flags For SDL_image/Android.mk: remove : LOCAL_SRC_FILES of png and jpeg LOCAL_LDLIBS := -Lobj/local/armeabi -ljpeg -lpng The correct way should be to use LOCAL_STATIC_LIBRARIES but it does not work ! Also, I would like to trigger the build of jpeg/png automatically from the SDL_image Android.mk. Any idea ? thanks So, the trick is to save the local path, then to call the .mk files. 1 my_LOCAL_PATH := $(call my-dir) 2 3 include $(my_LOCAL_PATH)/external/jpeg-9/Android.mk 4 include $(my_LOCAL_PATH)/external/libpng-1.6.2/Android.mk 5 6 LOCAL_PATH := $(my_LOCAL_PATH) 7 include $(CLEAR_VARS) 8 ... Created attachment 1915 [details]
patch on Android.mk
Here's a patch to build the png/jpeg/webp lib independently with their own Android.mk file.
In addition to the previous patch, if you add -Os: +++ external/jpeg-9/Android.mk -LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays +LOCAL_CFLAGS += -Os -fstrict-aliasing -fprefetch-loop-arrays +++ external/libpng-1.6.2/Android.mk -common_CFLAGS := ## -fomit-frame-pointer +common_CFLAGS := -Os ## -fomit-frame-pointer You will get a libSDL2_image of 275 ko instead of 460 ko. Curiously, you wouldn't get this by only adding -Os to the old Android.mk! I admit this is not so much important now that android libs are heavy, but the Android.mk file is now smaller, and it's not required anymore to make symlink of png/jpeg/webp to the jni directory. can be close with https://hg.libsdl.org/SDL_image/rev/0c24466d7d81 |