Skip to content

abuild.conf: set release profile optimisations for cargo

Jakub Panek requested to merge (removed):cargo into master

This is a proposal to set default optimisations for cargo release profile for decreased binary size, similar to CFLAGS.
The main reason is that we already patch in those optimisations for (some) rust packages but as a patch file or within APKBUILD if viable,
it should as well provide sane defaults which maintainers should not think about (we currently have a mix of opt-level = 's'/opt-level = 'z' while for everything non-rust we have -Os as default)

Environmental variables for cargo take precendence over TOML config files (source) so those should be respected no matter what upstream defines in their Cargo.toml
In case of issues with those defaults, it will be possible to unset envvar inside APKBUILD, but I don't expect it to be a common case.

Similar to -Os, s optimises for size, z additionally turns off loop vectorization (


Abort instead of unwinding the stack, standard for decreasing binary size (


Decrease parallel compiling resulting in better optimised package (


I'm aware that we do not have LTO by default, but we usually patch it in for rust packages (


Relevant issues:
RFC: implement optimization profiles
RFC: Enable link time optimization
enable link time optimization

Signed-off-by: Jakub Panek

Edited by Jakub Panek

Merge request reports