Gentoo Archives: gentoo-dev

From: David Seifert <soap@g.o>
To: gentoo-dev@l.g.o
Cc: kde@g.o, Mike Gilbert <floppym@g.o>
Subject: Re: [gentoo-dev] [PATCH] cmake.eclass: do not append -DNDEBUG to CPPFLAGS
Date: Mon, 30 Mar 2020 08:36:52
Message-Id: c84f8871bcfcaced2088a7583e831ff95a15cadb.camel@gentoo.org
In Reply to: [gentoo-dev] [PATCH] cmake.eclass: do not append -DNDEBUG to CPPFLAGS by Mike Gilbert
1 On Sun, 2020-03-29 at 21:03 -0400, Mike Gilbert wrote:
2 > The NDEBUG macro turns the assert() function into a noop. This gives a
3 > small performance boost, but may allow subtle programming errors to go
4 > unnoticed.
5 >
6 > This code was added back in 2008, when we started passing
7 > -DCMAKE_BUILD_TYPE=None instead of Release or Debug. It probably tries
8 > to mimic a default behavior of Release type builds.
9 >
10 > Other common build systems do not do this by default. For example,
11 > autoconf's AC_HEADER_ASSERT macro only sets NDEBUG if --disable-assert
12 > is passed to configure (it defaults to enabled).
13 >
14 > It is better to let users add this to CPPFLAGS themselves if they really
15 > want to save those few CPU cycles.
16 >
17 > Signed-off-by: Mike Gilbert <floppym@g.o>
18 > ---
19 > eclass/cmake.eclass | 9 ---------
20 > 1 file changed, 9 deletions(-)
21 >
22 > diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
23 > index 160f40b1cf8e..3da3b9aeb555 100644
24 > --- a/eclass/cmake.eclass
25 > +++ b/eclass/cmake.eclass
26 > @@ -371,15 +371,6 @@ cmake_src_configure() {
27 > # Fix xdg collision with sandbox
28 > xdg_environment_reset
29 >
30 > - # @SEE CMAKE_BUILD_TYPE
31 > - if [[ ${CMAKE_BUILD_TYPE} = Gentoo ]]; then
32 > - # Handle release builds
33 > - if ! in_iuse debug || ! use debug; then
34 > - local CPPFLAGS=${CPPFLAGS}
35 > - append-cppflags -DNDEBUG
36 > - fi
37 > - fi
38 > -
39 > # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS
40 > etc.)
41 > local build_rules=${BUILD_DIR}/gentoo_rules.cmake
42 >
43
44 Double ACK. Injecting this flag is imo doing too much and more feature creep
45 than anything else. This is why we should try and find ways of checking that
46 CPPFLAGS is respected as a user flag.