Tiny Core Extensions > TCE Tips & Tricks

Shrink the size

(1/1)

polikuo:
I'm trying to build firefox which requires several other extensions.
One of them is cbindgen, which has its unique way for compilation.
If you check the notes, you'll see that none of them use any compile flags.

A bit of googling leads me to the stackoverflow.
In brief, he says by adding these lines into the .toml config, you get smaller binary and strip it in a go.

--- Code: ---[profile.release]
opt-level = "z"
codegen-units = 1
panic = 'abort'
strip = true

[profile.release-lto]
inherits = "release"
lto = true

--- End code ---
Note that, to optimize for size, "s" (opt-level = "s") is a synonym to "z".

A quick test on my pies (all with LTO)

--- Code: ---$ du *
5.5M    cbindgen-pi4-default
1.7M    cbindgen-pi4-adjusted-stripped
3.8M    cbindgen-pi4-default-stripped
1.7M    cbindgen-pi3-adjusted-stripped

--- End code ---

The hack isn't RPI specific, we can introduce it into other arch.
What do you think ?  :)

jazzbiker:
Hi polikuo!

-Oz was introduced in gcc12.

from https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Optimize-Options.html:

-Oz

    Optimize aggressively for size rather than speed. This may increase the number of instructions executed if those instructions require fewer bytes to encode. -Oz behaves similarly to -Os including enabling most -O2 optimizations.

Looks like -Ofast antipode.

CardealRusso:
maybe tcc?

Navigation

[0] Message Index

Go to full version