]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: define _GNU_SOURCE as '1'
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 12 Jun 2023 08:45:48 +0000 (10:45 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 12 Jun 2023 08:59:45 +0000 (10:59 +0200)
This changes the generated config.h file thusly:
-#define _GNU_SOURCE
+#define _GNU_SOURCE 1

Canonically, _GNU_SOURCE is just defined, without any value, but g++ defines
_GNU_SOURCE implicitly [1]. This causes a warning about a redefinition during
complilation of C++ programs after '-include config.h'. Our config attempts to
inject this (and a bunch of other arguments) into all compliations. But before
meson 0.54, flags for dependencies were not propagated correctly (*), and the C++
compilation was done without various flags (**). Once that was fixed, we started
getting a warning.

[1] http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.predefined
(*) Actually, the changelog doesn't say anything. But it mentions various work
    related to dependency propagation, and apparently this changes as a side
    effect.
(**) -fno-strict-aliasing
    -fstrict-flex-arrays=1
    -fvisibility=hidden
    -fno-omit-frame-pointer
    -include config.h

This could be solved in various ways, but it'd require either making the
compilation command line longer, which we want to avoid for readability of the
build logs, or splitting the logic to define the args for C++ progs separately,
which would make our meson.build files more complicated. Changing the
definition to '1' also solves the issue (because apparently now we match the
implicit definition), and shouldn't have other effects. I checked compilation
with gcc and clang. Maybe on other systems this could cause problems. We can
revisit if people report issues.

meson.build

index 51a5fc82e33f6e8b9252c5b9626209f515320a78..fe3ec079cf1cec0a9d98c38319b0961d73c4b98c 100644 (file)
@@ -527,7 +527,7 @@ has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')
 #####################################################################
 # compilation result tests
 
-conf.set('_GNU_SOURCE', true)
+conf.set('_GNU_SOURCE', 1)
 conf.set('__SANE_USERSPACE_TYPES__', true)
 conf.set10('HAVE_WSTRINGOP_TRUNCATION', has_wstringop_truncation)