Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8
Date: Fri, 20 Aug 2021 08:10:59
Message-Id: da7dce479cc68afa254ed16ef3e3f89a5c11f15d.camel@gentoo.org
In Reply to: Re: [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8 by Guilherme Amadio
1 On Fri, 2021-08-20 at 09:46 +0200, Guilherme Amadio wrote:
2 > Hi,
3 >
4 > On Thu, Aug 19, 2021 at 07:45:16PM +0200, Andreas Sturmlechner wrote:
5 > > Signed-off-by: Michał Górny <mgorny@g.o>
6 > > Signed-off-by: Andreas Sturmlechner <asturm@g.o>
7 > > ---
8 > > eclass/cmake.eclass | 11 ++++++++---
9 > > 1 file changed, 8 insertions(+), 3 deletions(-)
10 > >
11 > > diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
12 > > index 8befd9e5a9f..3021a3a2b1e 100644
13 > > --- a/eclass/cmake.eclass
14 > > +++ b/eclass/cmake.eclass
15 > > @@ -42,14 +42,19 @@ _CMAKE_ECLASS=1
16 > > # Eclass can use different cmake binary than the one provided in by system.
17 > > : ${CMAKE_BINARY:=cmake}
18 > >
19 > > +[[ ${EAPI} == 7 ]] && : ${CMAKE_BUILD_TYPE:=Gentoo}
20 > > # @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
21 > > # @DESCRIPTION:
22 > > # Set to override default CMAKE_BUILD_TYPE. Only useful for packages
23 > > # known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)".
24 > > # If about to be set - needs to be set before invoking cmake_src_configure.
25 > > -# You usually do *NOT* want nor need to set it as it pulls CMake default
26 > > -# build-type specific compiler flags overriding make.conf.
27 > > -: ${CMAKE_BUILD_TYPE:=Gentoo}
28 > > +#
29 > > +# The default is RelWithDebInfo as that is least likely to append undesirable
30 > > +# flags. However, you may still need to sed CMake files or choose a different
31 > > +# build type to achieve desirable results.
32 > > +#
33 > > +# In EAPI 7, the default was non-standard build type of Gentoo.
34 > > +: ${CMAKE_BUILD_TYPE:=RelWithDebInfo}
35 >
36 > Although I think this is better than the "Gentoo" build type we had, I
37 > think that even better is to just leave this blank and set a default on
38 > a per-ebuild basis, as I commented on bug 802786[1]. Repeating my
39 > comment from there, build type flags always come after CMAKE_<LANG>_FLAGS,
40 > which then override make.conf settings. Moreover, setting a build type
41 > can also have funny behavior with multi-config generators (possible with
42 > ninja on Linux too now) because it has no meaning in that context. For
43 > instance, this may override make.conf flags with "-O2 -g" in most cases,
44 > preventing people from changing the optimization level of any CMake-based
45 > package, or disabling compilation of debug info (which is then stripped
46 > anyway). This is probably why we had the "Gentoo" build in the first place.
47 >
48 > For ebuilds that must have a CMAKE_BUILD_TYPE set, we should probably
49 > use Release and override CMAKE_<LANG>_FLAGS_RELEASE with settings from
50 > make.conf, or make CMAKE_<LANG>_FLAGS contain settings from make.conf
51 > and enforce CMAKE_<LANG>_FLAGS_<BUILD_TYPE> is empty for all build types.
52 >
53
54 No, we shouldn't. Release often has unexpected side effects.
55 RelWithDebInfo is the moderate type that is least likely to have side
56 effects.
57
58 The eclasses are stripping default build type flags since 2016. Please
59 do some research and/or testing before posting.
60
61 --
62 Best regards,
63 Michał Górny