Is there a way to minimise size of Kotlin/Native p...
# kotlin-native
d
Is there a way to minimise size of Kotlin/Native program binaries?
E.g. on osx hello world is ~700kb. With
konanc -opt
flag it’s even bigger.
It’s also interesting that
strings program.kexe
shows paths to teamcity agent
/opt/teamcity-agent/work/...
t
^that's jetbrains teamcity and I guess it's by design
d
What about
strip program.kexe
? That would cut 100~300kb a from hello world release/debug builds. Also you usually distribute things compressed. After a release build for macos + strip, a 7z file with the binary is ~142kb. You can also use UPX to get similar results (189kb) in the final exe:
upx program.kexe
d
Hm, why hello world needs to know about teamcity? 🤔
Yes, strip will minimize program size to about 400kb. I was wondering why the file is still quite big (I guess it's kotlin stdlib) and if there is some other optimisation.
d
Well, probably it uses the
__FILE__
macro for debugging purposes somehow and includes those strings since the stdlib was built using teamcity. You can compile your own kotlin-native in a shorter path and use it 🙂 But yeah, think that it is not even 1.0, so no much attention on that kind of optimizations has been done yet. Before 1.0 usually the idea is to get it right. My bet is that the size is related to some runtime stuff still not being optimized/stripped because a lack of other optimizations.
🙏 1
👍 2