gnome.generate_gir incorrectly filters clang cflags like -W , passed to g-ir-scanner, and gcc fails
See original GitHub issueDescribe the bug
The symptom is that, using clang, meson calls g-ir-scanner which calls gcc which fails with something like
"gcc: error: unrecognized command-line option ... -Wsometimes-unitialized"
It seems that gnome.generate_gir is passing clang specific c flags to generate warnings, but g-ir-scanner calls gcc, and gcc fails, not recognizing flags specific to clang compiler.
To Reproduce
The case is a meson build of the GIMP app v2.99, using clang, on Linux, Alpine or Ubuntu.
Analysis and suggested fix
In the code for gnome.generate_gir there is this:
def _get_scanner_cflags(cflags):
'g-ir-scanner only accepts -I/-D/-U; must ignore all other flags'
for f in cflags:
if f.startswith(('-D', '-U', '-I')):
yield f
So it seems that the intent is to filter out all the -W flags.
But later:
cflags, internal_ldflags, external_ldflags = self._get_langs_compilers_flags(state, langs_compilers)
...omitted...
dep_cflags, dep_internal_ldflags, dep_external_ldflags, gi_includes = \
self._get_dependencies_flags(deps, state, depends, use_gir_args=True)
cflags += list(self._get_scanner_cflags(dep_cflags))
In the above, cflags is initially an unfiltered list of cflags, and then the code appends more cflags that are filtered by calls to _get_scanner_cflags().
I believe a fix is to add one line like so:
cflags, internal_ldflags, external_ldflags = self._get_langs_compilers_flags(state, langs_compilers)
cflags = list(self._get_scanner_cflags(cflags))
That is, immediately filter the initial contents of the variable cflag.
I tested this fix minimally, only to build GIMP. The meson build of GIMP is “experimental”, not used for releases.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
I’ve opened an MR for gobject-introspection that adds a
--compiler
command line to g-ir-scanner. Hopefully, it’ll be available in the next gobject-introspection release in September.I have created #10875