rust-browser-game icon indicating copy to clipboard operation
rust-browser-game copied to clipboard

Enabling LTO (Link time optimizations) reduces binary size when using core abstractions

Open cdecompilador opened this issue 4 years ago • 2 comments
trafficstars

Adding to rustc options -C lto reduces the size from for example:

Using core clamp function: 559K The same but with lto enabled: 5.8K

Also note that the actual size of the binary is: 3.8K

Maybe enabling lto allows you to use some core abstractions without bloating the binary. Hope it helps.

cdecompilador avatar May 06 '21 16:05 cdecompilador

@cdecompilador I like how you purposefully not mention that the size increase from 3.8k to 3.9k without any code modifications just by enabling LTO Kappa

rexim avatar May 06 '21 18:05 rexim

Sorry it wasn't on purpose, that happens because lto does some inlinings than even telling the compiler not to inline it does. I hope still the information is useful, for example you can use math functions without implement them by yourself and also tell the compiler to disable checkings on casting to reduce the code size even more.

cdecompilador avatar May 06 '21 21:05 cdecompilador