Strip examples of unused data and functions

Compile time:
$ time ./build-example.sh
Before: user 0m40.885s
After:  user 0m41.011s

Binary size (for example-toy-genlib):
$ ls -l gen/bin/example-toy-genlib) | awk '{print $5}'
Before: 830168
After:  809896
Note that the majority of this is a statically linked libc.

Binary size (excluding the statically linked example-toy-genlib):
$ ls -l gen/bin/example-* | awk '{print $5 " " $9}'

Before:
 85280 gen/bin/example-cbor-to-json
242216 gen/bin/example-convert-to-nia
 37112 gen/bin/example-crc32
 53328 gen/bin/example-gifplayer
282840 gen/bin/example-imageviewer
 95152 gen/bin/example-json-to-cbor
122720 gen/bin/example-jsonfindptrs
 60448 gen/bin/example-jsonptr
267672 gen/bin/example-sdl-imageviewer
 64792 gen/bin/example-zcat

After:
 73104 gen/bin/example-cbor-to-json
231560 gen/bin/example-convert-to-nia
 34640 gen/bin/example-crc32
 47632 gen/bin/example-gifplayer
269632 gen/bin/example-imageviewer
 83032 gen/bin/example-json-to-cbor
118664 gen/bin/example-jsonfindptrs
 58040 gen/bin/example-jsonptr
253424 gen/bin/example-sdl-imageviewer
 58200 gen/bin/example-zcat

Before total: 1311560
After  total: 1227928
This commit is contained in:
Nigel Tao committed 2021-10-04 13:28:42 +11:00
1 parent 9699c49f55
commit 41fce8a8de
1 file changed
+2 -2
+2 -2
View File
@@ -23,9 +23,9 @@ if [ ! -e release/c/wuffs-unsupported-snapshot.c ]; then
fi
CC=${CC:-gcc}
CFLAGS=${CFLAGS:--O3}
CFLAGS=${CFLAGS:--O3 -fdata-sections -ffunction-sections -Wl,--gc-sections}
CXX=${CXX:-g++}
CXXFLAGS=${CXXFLAGS:--O3}
CXXFLAGS=${CXXFLAGS:--O3 -fdata-sections -ffunction-sections -Wl,--gc-sections}
LDFLAGS=${LDFLAGS:-}
mkdir -p gen/bin