mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
Improve default value of glib_debug option
glib_debug is an auto option. This is clever because it allows us to guess the best default based on the build type, while also allowing an easy way to override if the guess is not good. Sadly, the attempt to guess based on the build type does not work well. For example, it considers debugoptimized builds to be debug builds, but despite the name, it is definitely a release build type (except on Windows, which we'll ignore here). The minsize build type has the exact same problem. The debug option is true for both build types, but this only controls whether debuginfo is enabled, not whether debug extras are enabled. The plain build type has a different problem: debug is off, but the optimization option is off too, even though plain builds are distro builds are will almost always use optimization. I've outlined an argument for why we should make these changes here: https://blogs.gnome.org/mcatanzaro/2022/07/15/best-practices-for-build-options/ Specifically, Rule 4 shows all the build types and whether they correspond to release builds or debug builds. Rule 6 argues that we should provide good defaults for plain builds.
This commit is contained in:
parent
08715a4cd1
commit
61a843564d
@ -205,15 +205,10 @@
|
||||
<para>
|
||||
This is a standard <application>Meson</application> option which
|
||||
specifies how much debugging and optimization to enable. If the build
|
||||
type starts with <literal>debug</literal>,
|
||||
type is <literal>debug</literal>,
|
||||
<literal>G_ENABLE_DEBUG</literal> will be defined and GLib will be built
|
||||
with additional debug code enabled.
|
||||
</para>
|
||||
<para>
|
||||
If the build type is <literal>plain</literal>, GLib will not enable any
|
||||
optimization or debug options by default, and will leave it entirely to
|
||||
the user to choose their options. To build with the options recommended
|
||||
by GLib developers, choose <literal>release</literal>.
|
||||
with additional debug code enabled. You can override this behavior using
|
||||
<option>-Dglib_debug</option>.
|
||||
</para>
|
||||
</formalpara>
|
||||
|
||||
|
@ -294,13 +294,15 @@ elif vs_crt_opt == 'from_buildtype'
|
||||
endif
|
||||
|
||||
# Use debug/optimization flags to determine whether to enable debug or disable
|
||||
# cast checks
|
||||
# cast checks. We have a non-production (debug) build if debug is true and if
|
||||
# optimization is 0 or g; otherwise, we have a production build.
|
||||
glib_debug_cflags = []
|
||||
glib_debug = get_option('glib_debug')
|
||||
if glib_debug.enabled() or (glib_debug.auto() and get_option('debug'))
|
||||
optimized_build = get_option('optimization') not in [ '0', 'g' ]
|
||||
if glib_debug.enabled() or (glib_debug.auto() and get_option('debug') and not optimized_build)
|
||||
glib_debug_cflags += ['-DG_ENABLE_DEBUG']
|
||||
message('Enabling various debug infrastructure')
|
||||
elif get_option('optimization') in ['2', '3', 's']
|
||||
elif optimized_build
|
||||
glib_debug_cflags += ['-DG_DISABLE_CAST_CHECKS']
|
||||
message('Disabling cast checks')
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user