From 78103450b4dd7d704b9acd517a28c669a0120b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 12 Jun 2023 10:45:48 +0200 Subject: [PATCH] meson: define _GNU_SOURCE as '1' 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 51a5fc82e3..fe3ec079cf 100644 --- a/meson.build +++ b/meson.build @@ -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)