From 4dde72e0389e9a08a4341aed09018bd9da651f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Sun, 30 Jul 2023 17:29:27 +0400 Subject: [PATCH] meson: warn if -mms-bitfields is necessary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC >= 4.7 and clang >= 12 don't need it. It should be left to the user to decide what ABI convention should be used, and it creates some issues with some tools to have this flag in cflags. We leave the flag for now, but print a warning at compile time so people get a chance to change their build system before we drop it from glib.pc Signed-off-by: Marc-André Lureau --- meson.build | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/meson.build b/meson.build index 99faf5af4..bdb2afee4 100644 --- a/meson.build +++ b/meson.build @@ -2358,6 +2358,20 @@ if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang- # Ensure MSVC-compatible struct packing convention is used when # compiling for Win32 with gcc. It is used for the whole project and exposed # in glib-2.0.pc. + if not cc.compiles(''' +struct _GTestMSBitfields +{ + int a : 1; + short b : 1; +}; + +typedef char _StaticCheck[sizeof(struct _GTestMSBitfields) != sizeof(int) ? 1 : -1]; +''') + warning(''' +Your compiler does not have ms-bitfields packing by default. +Please use gcc >= 4.7 or clang >= 12: GLib will drop -mms-bitfields in the future. +''') + endif win32_cflags = ['-mms-bitfields'] add_project_arguments(win32_cflags, language : 'c')