Skip to content

build: don't set glib version constraints as global arguments

Daniel P. Berrangé requested to merge berrange/libosinfo:max-allowed into master

add_project_arguments() sets flags that apply to all invokations of the C compiler toolchain by meson. On the surface it sounds fine to use this for setting

-DGLIB_VERSION_MIN_REQUIRED=VER -DGLIB_VERSION_MAX_ALLOWED=VER

as we want all our code to be constrained by these declared glib versions to prevent us accidentally using APIS from newer glib by mistake.

A subtle problem was revealed with the arrival of gobject-introspection version 1.70. The g-ir-scanner program auto-generates some glib code for handling introspection, and this generated code uses glib APIs that are newer than our declared version and this triggers compile failures

tmp-introspectg6xadxkr/Libosinfo-1.0.c:251:3: error: ‘G_TYPE_FLAG_FINAL’ is deprecated: Not available before 2.70 [-Werror=deprecated-declarations] 251 | if (G_TYPE_IS_FINAL (type)) | ^~ In file included from /usr/include/glib-2.0/gobject/gobject.h:24, from /usr/include/glib-2.0/gobject/gbinding.h:29, from /usr/include/glib-2.0/glib-object.h:22, from tmp-introspectg6xadxkr/Libosinfo-1.0.c:30: /usr/include/glib-2.0/gobject/gtype.h:1050:3: note: declared here 1050 | G_TYPE_FLAG_FINAL GLIB_AVAILABLE_ENUMERATOR_IN_2_70 = (1 << 6) | ^~~~~~~~~~~~~~~~~ tmp-introspectg6xadxkr/Libosinfo-1.0.c:251:13: error: Not available before 2.70 [-Werror] 251 | if (G_TYPE_IS_FINAL (type)) | ^~~~~~~~~~~~~~~~~

This is actually harmless, because systems with an older glib will also have older g-ir-scanner and thus not be using these new APIs.

We need to exclude the glib version constraints from code generated by glib tools, and thus means we have to stop using add_project_arguments() and set cflags explicitly on each target.

Signed-off-by: Daniel P. Berrangé berrange@redhat.com

Merge request reports