Skip to content
Snippets Groups Projects
Commit 9214b289 authored by Debarshi Ray's avatar Debarshi Ray
Browse files

build: Silence warning about _FORTIFY_SOURCE requiring optimization

Building with AX_CHECK_ENABLE_DEBUG([yes]), which is what happens by
default for non-release builds, turns off compiler optimizations and
overrides any optimization specified via CFLAGS in the build
environment. This means that the nightly Flatpaks, and almost all
other non-release builds, are built without any optimization. This
triggers a warning about _FORTIFY_SOURCE requiring optimization, on
distributions that build with _FORTIFY_SOURCE, when running
g-ir-scanner to generate Goa-1.0.gir.

Since g-ir-scanner uses Python's distutils.ccompiler, the compiler
flags with which Python itself was built gets tagged into the
compilation of the generated code that's used to generate the GIR. If
the Python installation being used was built with _FORTIFY_SOURCE, the
warning is triggered.

It can be useful to turn off compiler optimizations to get a better
debugging experience, but it becomes a problem if it stomps over the
build environment while doing so. The person doing the builds should
should get to decide between ease of debugging and other factors.
After all, debugging is not the only thing that a developer does. One
can use GDB reasonably well with the Autoconf default, which also
happens to be what most distributions use, of "-g O2".

This wouldn't have been such a problem if AX_CHECK_ENABLE_DEBUG
attached its flags before the values from the environment instead of
after, because in case of multiple -O options, the last such option is
the one that's effective.

Thankfully, "no" doesn't override the environment, which is what
happens for release builds, and distributions generally set their own
CFLAGS. Otherwise every single user-facing build would have been
broken. Note that any release build without CFLAGS set in the
environment would neither get debug symbols (ie., no "-g") nor any
compiler optimization because AX_CHECK_ENABLE_DEBUG always suppresses
the Autoconf defaults of "-g -O2".

One solution could have been to default to "info" for non-release
builds and recommend the use of --enable-debug=info while building from
Git, but that would not address release builds without CFLAGS.

Given that the only other thing the macro does is to define the NDEBUG
pre-processor macro when debugging is set to "no", which isn't widely
used in the GLib-based GNOME platform [1], it seems better to just
remove it altogether.

[1] glib/gio/xdgmime is the only widely used code path where assert(3)
    is used. It's also used in gio/kqueue/dep-list.c, which is
    *BSD-specific and in GTK+'s Broadway backend. All those can
    probably be replaced with g_assert*.

https://gitlab.gnome.org/GNOME/gnome-online-accounts/issues/10
parent 2b981374
No related branches found
No related tags found
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment