How can I get my build size smaller?
# kotlin-native
z
How can I get my build size smaller?
j
Along with the GC the stdlib and default platform libraries is probably what takes the most size. You can run without the default libs by adding the compiler flag: -no-default-libs, the effect of this however will be that you can not use a lot of the platform related code that you might want. And to remove the stdlib you can use the compiler flag: -nostdlib The effect of this however is that you will not get any standard methods available anymore which makes your coding very cumbersome.
👍 1
n
If you are using C libraries then you should go for ones that provide dynamic library files if possible. Preferably, go with C libraries that have a very small number of dependencies (the same advice also applies to Kotlin libraries). Note that static library files can significantly increase binary size.
With Kotlin programs minimise the use of inlined elements like functions and compile time constants (aka const val) for example. If there are some static text resources in a Kotlin program then extract them into separate configuration/text files if possible.
e
n
How effective is UPX on reducing the size of a Kotlin Native binary (using linuxArm32Hfp as the example target)?
j
upx is pretty clever. the relinking can find things missed by strip, somehow.
138 Views