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.
[profile.release]
opt-level = "z"
codegen-units = 1
panic = 'abort'
strip = true
[profile.release-lto]
inherits = "release"
lto = true
Note that, to optimize for size, "s" (opt-level = "s") is a synonym to "z".
A quick test on my pies (all with LTO)
$ du *
5.5M cbindgen-pi4-default
1.7M cbindgen-pi4-adjusted-stripped
3.8M cbindgen-pi4-default-stripped
1.7M cbindgen-pi3-adjusted-stripped
The hack isn't RPI specific, we can introduce it into other arch.
What do you think ?