Closed tarkah closed 3 years ago
Probably inlined it by default with the function being small. https://stackoverflow.com/a/37639889/9806233
Messed around with some things, and was able to get the binary size to as low as 1856 kbytes (1.9M) first with opt_level='z'
(5.1M) on the release profile and then finally using upx to compress the binary with the lzma
format.
$ du -sh 0.13.1*
10252 11M 0.13.1
6224 6.1M 0.13.1_stripped
7892 7.8M 0.13.1_lto
5612 5.5M 0.13.1_lto_stripped
5124 5.1M 0.13.1_opt_level
2340 2.3M 0.13.1_opt_level_upx_1
2320 2.3M 0.13.1_opt_level_upx_9
2312 2.3M 0.13.1_opt_level_upx_best
1904 1.9M 0.13.1_opt_level_upx_brute
2076 2.1M 0.13.1_opt_level_upx_brute_1
1904 1.9M 0.13.1_opt_level_upx_brute_9
1856 1.9M 0.13.1_opt_level_upx_lzma
2028 2.0M 0.13.1_opt_level_upx_lzma_1
1856 1.9M 0.13.1_opt_level_upx_lzma_9
1896 1.9M 0.13.1_opt_level_upx_ultra_brute
I'm sure there's gonna be a cost somewhere that I can't investigate right now, but it's good to know it gets that low without doing much to tweak the actual code.
@miraclx LTO appears to reduce binary size from 11MB to 7.8MB on Linux. No noticeable difference on the inlined function, but maybe it was already getting inlined or is immaterial.