RFC: implement optimization profiles
Presently, abuild
only supports a unified set of CFLAGS
, et al. If you want to override the CFLAGS
used for a package, you must do it in the APKBUILD
for that package. However, there are many packages where the default -Os
optimization setting does not make any sense: for the amount of binary size savings, we lose significant performance -- an example of this being the OpenBLAS and LAPACK libraries.
Talking about this with @jirutka we thought about the concept of an optimization profile: a package maintainer would specify how the build should be optimized, and abuild
would choose the correct CFLAGS based on that profile. For example, an APKBUILD
could have optprofile=size
or optprofile=performance
, which would choose different CFLAGS based on the requested profile. It would be desirable for the end-user to be able to override the default profiles in abuild.conf
, as well.
Thinking out loud, there could be at least three profiles, but we may want additional profiles to trade hardening features for performance too:
-
size
: the current default CFLAGS:-Os -fomit-frame-pointer
-
balanced
: basically the same as the current default, but-O2
-
performance
:-O3 -ffast-math -funroll-all-loops ...
We probably want to tweak these profiles for specific microarchitectural optimizations, too, but that seems like something where @alxu probably knows a lot more than me.
The point of this being that we no longer are just overriding CFLAGS to get -O2
and so on, it keeps everything more consistent with the building.