intel / dps-for-iot

Other
61 stars 23 forks source link

Add a minimal size release variant #98

Closed AAlon closed 5 years ago

AAlon commented 5 years ago

Currently, the build variants supported are debug and release, the latter implies -O3.

It would be useful to add a min-size-release option (analogue to CMake's MinSizeRel) to better fit resource-constrained environments.

At the very least it should specify -Os. Additional relevant options might be -s, -fdata-sections -ffunction-sections, -flto, -Wl,--gc-sections, -Wl,--strip-all.

AAlon commented 5 years ago

For reference, the stock build of libdps_shared.so.0.9.0 on my EC2 instance weighs 3.0MB. With all the flags above it comes down to 599K.

malsbat commented 5 years ago

https://github.com/intel/dps-for-iot/pull/102 has the following impact for me:

release:

$ ls -lh build/dist/lib/libdps_shared.so.0.9.0 
-rwxr-xr-x. 1 tmalsbar lock 3.2M May 23 11:46 build/dist/lib/libdps_shared.so.0.9.0
$ size build/dist/lib/libdps_shared.so.0.9.0 
   text    data     bss     dec     hex filename
 589324    9632   11121  610077   94f1d build/dist/lib/libdps_shared.so.0.9.0

min-size-release:

$ ls -lh build/dist/lib/libdps_shared.so.0.9.0 
-rwxr-xr-x. 1 tmalsbar lock 255K May 23 11:47 build/dist/lib/libdps_shared.so.0.9.0
$ size build/dist/lib/libdps_shared.so.0.9.0 
   text    data     bss     dec     hex filename
 252609    5440    9729  267778   41602 build/dist/lib/libdps_shared.so.0.9.0
AAlon commented 5 years ago

Nice!

malsbat commented 5 years ago

102 has been merged