Repository: mesonbuild/meson

Issue:
gobject-introspection fails with sanitizer
```
FAILED: contrib/gstyle/Gstyle-1.0.gir 
'g-ir-scanner' '../contrib/gstyle/gstyle-cielab.h' '../contrib/gstyle/gstyle-cielab.c' '../contrib/gstyle/gstyle-color.h' '../contrib/gstyle/gstyle-color.c' '../contrib/gstyle/gstyle-color-component.h' '../contrib/gstyle/gstyle-color-component.c' '../contrib/gstyle/gstyle-color-convert.h' '../contrib/gstyle/gstyle-color-convert.c' '../contrib/gstyle/gstyle-color-filter.h' '../contrib/gstyle/gstyle-color-filter.c' '../contrib/gstyle/gstyle-color-item.h' '../contrib/gstyle/gstyle-color-item.c' '../contrib/gstyle/gstyle-color-panel.h' '../contrib/gstyle/gstyle-color-panel.c' '../contrib/gstyle/gstyle-color-plane.h' '../contrib/gstyle/gstyle-color-plane.c' '../contrib/gstyle/gstyle-color-scale.h' '../contrib/gstyle/gstyle-color-scale.c' '../contrib/gstyle/gstyle-color-widget.h' '../contrib/gstyle/gstyle-color-widget.c' '../contrib/gstyle/gstyle-eyedropper.h' '../contrib/gstyle/gstyle-eyedropper.c' '../contrib/gstyle/gstyle-hsv.h' '../contrib/gstyle/gstyle-hsv.c' '../contrib/gstyle/gstyle-palette.h' '../contrib/gstyle/gstyle-palette.c' '../contrib/gstyle/gstyle-palette-widget.h' '../contrib/gstyle/gstyle-palette-widget.c' '../contrib/gstyle/gstyle-slidein.h' '../contrib/gstyle/gstyle-slidein.c' '../contrib/gstyle/gstyle-xyz.h' '../contrib/gstyle/gstyle-xyz.c' '-pthread' '-I/usr/include/gobject-introspection-1.0' '-I/usr/lib/libffi-3.2.1/include' '-I/usr/include/glib-2.0' '-I/usr/lib/glib-2.0/include' '--no-libtool' '--namespace=Gstyle' '--nsversion=1.0' '--warn-all' '--output' 'contrib/gstyle/Gstyle-1.0.gir' '--c-include=gstyle-private.h' '-I/home/tingping/Projects/gnome-builder/contrib/gstyle' '-I/home/tingping/Projects/gnome-builder/meson-build/contrib/gstyle' '-I/home/tingping/Projects/gnome-builder/contrib/search' '-I/home/tingping/Projects/gnome-builder/contrib/search' '-I/home/tingping/Projects/gnome-builder/contrib/xml' '-I/home/tingping/Projects/gnome-builder/contrib/xml' '--include=Gtk-3.0' '--include=GtkSource-3.0' '--cflags-begin' '-DHAVE_CONFIG_H' '-I/home/tingping/Projects/gnome-builder/meson-build' '-D_GNU_SOURCE' '-Wall' '-Wcast-align' '-Wdeclaration-after-statement' '-Werror=format=2' '-Wextra' '-Wformat-nonliteral' '-Wformat-security' '-Wmissing-include-dirs' '-Wnested-externs' '-Wno-missing-field-initializers' '-Wno-sign-compare' '-Wno-strict-aliasing' '-Wno-uninitialized' '-Wno-unused-parameter' '-Wpointer-arith' '-Wredundant-decls' '-Wshadow' '-Wswitch-default' '-Wswitch-enum' '-fstack-protector-strong' '--cflags-end' '--symbol-prefix=gstyle' '--identifier-prefix=Gstyle' '/home/tingping/Projects/gnome-builder/contrib/search' '-I/usr/include/gio-unix-2.0/' '-I/usr/include/pango-1.0' '-I/usr/include/glib-2.0' '-I/usr/include/cairo' '-I/usr/include/libdrm' '-I/usr/include/gdk-pixbuf-2.0' '-I/usr/include/dbus-1.0' '-I/usr/include/at-spi-2.0' '-I/usr/include/freetype2' '-I/usr/include/harfbuzz' '-I/usr/include/libpng16' '-I/usr/lib/glib-2.0/include' '-I/usr/include/libxml2' '-I/usr/lib/dbus-1.0/include' '-I/usr/include/gtk-3.0' '-pthread' '-I/usr/include/atk-1.0' '-I/usr/include/pixman-1' '-I/usr/include/at-spi2-atk/2.0' '/home/tingping/Projects/gnome-builder/contrib/xml' '-latk-1.0' '-lpangocairo-1.0' '-lgtk-3' '-lxml2' '-lpango-1.0' '-lgobject-2.0' '-lglib-2.0' '-lcairo-gobject' '-lgdk-3' '-lcairo' '-lgio-2.0' '-lgdk_pixbuf-2.0' '-L/home/tingping/Projects/gnome-builder/meson-build/contrib/gstyle' '--library' 'gstyle-private'
/usr/lib/libasan.so.3: warning: the use of `tmpnam' is dangerous, better use `mkstemp'
/usr/lib/libasan.so.3: warning: the use of `tempnam' is dangerous, better use `mkstemp'
/usr/lib/libasan.so.3: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
==11785==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
Command '['/home/tingping/Projects/gnome-builder/meson-build/tmp-introspectvsaoqlvj/Gstyle-1.0', '--introspect-dump=/home/tingping/Projects/gnome-builder/meson-build/tmp-introspectvsaoqlvj/functions.txt,/home/tingping/Projects/gnome-builder/meson-build/tmp-introspectvsaoqlvj/dump.xml']' returned non-zero exit status 1
```



Discussion:

Resolving patch:
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -344,9 +344,18 @@ def generate_gir(self, state, args, kwargs):
                 else:
                     raise MesonException(
                         'Gir includes must be str, GirTarget, or list of them')
+
+        cflags = []
         if state.global_args.get('c'):
+            cflags += state.global_args['c']
+        for compiler in state.compilers:
+            if compiler.get_language() == 'c':
+                sanitize = compiler.get_options().get('b_sanitize')
+                if sanitize:
+                    cflags += compilers.sanitizer_compile_args(sanitize)
+        if cflags:
             scan_command += ['--cflags-begin']
-            scan_command += state.global_args['c']
+            scan_command += cflags
             scan_command += ['--cflags-end']
         if kwargs.get('symbol_prefix'):
             sym_prefix = kwargs.pop('symbol_prefix')


Test patch: