After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 794790 - Meson: Define G_ENABLE_DEBUG and friends
Meson: Define G_ENABLE_DEBUG and friends
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 790954
 
 
Reported: 2018-03-29 01:39 UTC by Xavier Claessens
Modified: 2018-04-19 14:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Meson: Define G_ENABLE_DEBUG and friends (1.27 KB, patch)
2018-03-29 01:40 UTC, Xavier Claessens
none Details | Review
Meson: Define G_ENABLE_DEBUG and friends (1.12 KB, patch)
2018-03-29 13:57 UTC, Xavier Claessens
committed Details | Review

Description Xavier Claessens 2018-03-29 01:39:28 UTC
The part that handles --enable-debug in configure.ac didn't got ported to meson.build. Gtk+ does it.
Comment 1 Xavier Claessens 2018-03-29 01:40:02 UTC
Created attachment 370278 [details] [review]
Meson: Define G_ENABLE_DEBUG and friends
Comment 2 Xavier Claessens 2018-03-29 01:42:54 UTC
For reference, here is what meson doc says about build types:
http://mesonbuild.com/Running-Meson.html#configuring-the-source
Comment 3 Emmanuele Bassi (:ebassi) 2018-03-29 08:55:07 UTC
Review of attachment 370278 [details] [review]:

::: meson.build
@@ +193,3 @@
+if buildtype.startswith('debug')
+  glib_debug_cflags += '-DG_ENABLE_DEBUG'
+elif buildtype == 'release'

No.

The old "--enable-debug=no" is *not* what we used for releases. Releases from unstable branches still had full debugging, and releases from stable branches only had '-DG_DISABLE_CAST_CHECKS' enabled.

Disabling everything was only ever meant for resource constrained environments, and with Meson those are much better served by using `--buildtype=plain` and injecting their own compiler flags.

Releases should just disable cast checks; see the equivalent check in GTK's meson.build file.
Comment 4 Xavier Claessens 2018-03-29 10:41:34 UTC
Meson doc says "release" is full optimization, and distro should build "plain". So I think it makes sense to disable everything on release build. The terminology in meson is counter intuitive.
Comment 5 Emmanuele Bassi (:ebassi) 2018-03-29 11:02:47 UTC
(In reply to Xavier Claessens from comment #4)
> Meson doc says "release" is full optimization, and distro should build
> "plain".

I really care zero or less about what Meson considers "full optimization". :-P

Disabling pre-condition checks and assertions is *not* something we do, especially for releases. Full stop.

> So I think it makes sense to disable everything on release build.

No, it doesn't make any sense. It will lead to undiagnosable crash reports, to the effect that nobody will *ever* use `--buildtype=release`.

Again: we only ever allowed people to disable everything because they needed a very specific build of GLib/GTK for very specific environments. Those are never to be considered "release" builds, to the point that people that used to configure GLib and/or GTK with `--enable-debug=no` are *much* better served by using `--buildtype=plain` and figuring out what they need to pass themselves.
Comment 6 Xavier Claessens 2018-03-29 13:57:37 UTC
Created attachment 370297 [details] [review]
Meson: Define G_ENABLE_DEBUG and friends
Comment 7 Iñigo Martínez 2018-03-29 20:58:49 UTC
Just as a side note, I remember discussing this, but I can't remember which package was involved and if it was on the IRC, on a bug at bugzilla, or at gitlab, so I don't have the final conclusions.

Having said this, I used to apply the following convention[0] by using both `buildtype` and `b_ndebug` (this one is used to enable or disable assertions) meson options:

- If builtype is a `debug` build, set the `G_ENABLE_DEBUG` macro.
- If builtype is a `debugoptimized` build, set the `G_DISABLE_CAST_CHECKS` macro (somehow equivalent to `debug=minimum`).
- If builtype is not a `debug*` build, set both `G_DISABLE_CAST_CHECKS` and `-G_DISABLE_CHECKS`.
- If `b_ndebug` is true, set `G_DISABLE_ASSERT`.

However, I have the feeling that this wasn't right and it was later changed. I applied a different solution in `gnome-settings-daemon`[1]:

- If buildtype is `debug*`, set the `G_ENABLE_DEBUG` macro.
- If buildtype is `release`, set the `G_DISABLE_CAST_CHECKS` macro.
- If `b_ndebug` is true, set `G_DISABLE_ASSERT`.

If this doesn't make sense for you, I can search harder and try to find that discussion.

Hope it helps,

[0] https://bugzilla.gnome.org/show_bug.cgi?id=792699#c7
[1] https://gitlab.gnome.org/GNOME/gnome-settings-daemon/blob/master/meson.build#L59
Comment 8 Emmanuele Bassi (:ebassi) 2018-04-19 13:50:53 UTC
Review of attachment 370297 [details] [review]:

:+1:
Comment 9 Xavier Claessens 2018-04-19 14:39:23 UTC
Attachment 370297 [details] pushed as cc7e0f6 - Meson: Define G_ENABLE_DEBUG and friends