Subject: Using buildtypes that respect our C{,PP,XX}FLAGS in CMake and Meson

From: Rasmus Thomsen <[email-masked]>
Date: Thu, 20 Feb 2020 17:20:45 +0000

Hello list,

due to we've noticed that most aports use the RelWithDebInfo or Release
buildtype for CMake or the meson equivalents debugoptimized or release,
which overwrite the C{,PP,XX}FLAGS set by abuild. E.g. meson can add
-O2 or even -O3 to release builds and many upstreams add additional
flags to their release builds they deem increase performance. As such
we should switch to the None buildtype for CMake and for Meson to the
plain buildtype, so that no additional flags are added to our aports.

To make the impact of this clear, here's a comparison between
CMAKE_BUILD_TYPE=RelWithDebInfo and CMAKE_BUILD_TYPE=None for attica:

attica-5.67.0-r0 installed size:
823296

attica-5.67.0-r1 installed size:
823296

attica-5.67.0-r2 installed size:
589824

-r0 is compiled with RelWithDebInfo and the flags the builders use, -r1
is compiled with None and CFLAGS set to -O2 in abuild.conf and -r2 is
compile with None and the default flags of abuild (-Os -fomit-frame-
pointer).

Similiar (although not as drastic, but maybe that's just on libtracker
vs attica) differences can be seen with meson (using the same flags as
above):

libtracker-2.3.2-r0 installed size:
5718016

libtracker-2.3.2-r1 installed size:
5713920

libtracker-2.3.2-r2 installed size:
4911104

As such I'd suggest multiple steps to be taken:

1) Change existing aports over to the None/plain buildtype to make sure
this doesn't break anything (we'll probably use some performance but
get smaller packages due to our CFLAGS, but that's the goal here, I
suppose)

2) Change Alpine policy to only use the None/plain buildtype.
Additionally, the buildtype _must be_ mentioned, since at least Meson
defaults to 'debug' if no buildtype is specified.

3) Change newapkbuild so that new aports use the correct buildtype (
https://gitlab.alpinelinux.org/alpine/abuild/merge_requests/29)

Thanks,

Rasmus Thomsen

---

From: Sören Tempel <[email-masked]>
Date: Fri, 21 Feb 2020 18:30:28 +0100

> Hello list,

Hello,

This has just been merged. This makes CMake / meson builds consistent
with the configuration in /etc/abuild.conf. If anyone encounters issues
with any of the rebuild packages let us know.

Cheers,
Sören

---

From: Rasmus Thomsen <[email-masked]>
Date: Thu, 20 Feb 2020 17:40:10 +0000

Hello,

the MR to switch all packages over is located here: 
https://gitlab.alpinelinux.org/alpine/aports/merge_requests/4317

Thanks,

Rasmus Thomsen

---

From: Kevin Daudt <[email-masked]>
Date: Thu, 20 Feb 2020 18:44:26 +0100

On Thu, Feb 20, 2020 at 05:20:45PM +0000, Rasmus Thomsen wrote:
> [..]

If feasible, we could add a linting check to verify that the proper
buildtype is used as well.

---

From: Rasmus Thomsen <[email-masked]>
Date: Fri, 21 Feb 2020 16:48:27 +0000

> buildtype is used as well.

That sounds like a good idea, I guess we could check if cmake is
mentioned in an APKBUILD and if so, if the right CMAKE_BUILD_TYPE is
used (and the same for meson with buildtype).