cmake: switch from MinSizeRel to Release #1549
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is a choice of optimisation levels to apply at build time of C/C++
code. There are choices spanning from -00 to -03 and -0s. Most
distributions build with debug symbols which are then stripped, but
otherwise apply release optimisations at -O2 or -O3 level.
This is evident from dpkg-buildflags & debhelper pipelines in
Debian-like systems, as well as rpm macros on Fedora-like systems.
In C/C++ there are code optimisations at -O2 and higher levels that
increate binary size. And compiler has an option, do not optimise
things that would increase binary size -Os (Optimize for size. -Os
enables all -O2 optimizations except those that often increase code
size).
In wolfi by default we choose to build with -O2 via build-env files,
and openssf-compiler-options. However our CMAKE pipeline switches to
MinSizeRel build type that instead compiles things to -Os level.
On performant server hardware, it means that whilst the binaries are
at most 1-3% smaller, they potentially have worse performance. A very
recent analysis done by Fedora concluded that performance gain
outweighs the binary size to even go higher to O3. See
https://fedoraproject.org/wiki/Changes/Python_built_with_gcc_O3
The level of optimisation applied to the C/C++, doesn't impact our
primary goal of delivering zero CVEs, but it can hinder our secondary
goal of being at-parity compatible with other distributions.
Switch cmake pipeline to Release build type by default.
References: