Blame 0001-build-don-t-set-glib-version-constraints-for-g-ir-sc.patch

2d40367
From d5807a0f458b310112c0794e7ea43ccd55a8bba5 Mon Sep 17 00:00:00 2001
2d40367
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
2d40367
Date: Mon, 27 Sep 2021 15:21:52 +0100
2d40367
Subject: [PATCH libosinfo] build: don't set glib version constraints for
2d40367
 g-ir-scanner
2d40367
MIME-Version: 1.0
2d40367
Content-Type: text/plain; charset=UTF-8
2d40367
Content-Transfer-Encoding: 8bit
2d40367
2d40367
add_project_arguments() sets flags that apply to all invokations of the C
2d40367
compiler toolchain by meson. On the surface it sounds fine to use this
2d40367
for setting
2d40367
2d40367
  -DGLIB_VERSION_MIN_REQUIRED=VER
2d40367
  -DGLIB_VERSION_MAX_ALLOWED=VER
2d40367
2d40367
as we want all our code to be constrained by these declared glib
2d40367
versions to prevent us accidentally using APIS from newer glib by
2d40367
mistake.
2d40367
2d40367
A subtle problem was revealed with the arrival of gobject-introspection
2d40367
version 1.70.  The g-ir-scanner program auto-generates some glib code
2d40367
for handling introspection, and this generated code uses glib APIs that
2d40367
are newer than our declared version and this triggers compile failures
2d40367
2d40367
tmp-introspectg6xadxkr/Libosinfo-1.0.c:251:3: error: ‘G_TYPE_FLAG_FINAL’ is deprecated: Not available before 2.70 [-Werror=deprecated-declarations]
2d40367
  251 |   if (G_TYPE_IS_FINAL (type))
2d40367
      |   ^~
2d40367
In file included from /usr/include/glib-2.0/gobject/gobject.h:24,
2d40367
                 from /usr/include/glib-2.0/gobject/gbinding.h:29,
2d40367
                 from /usr/include/glib-2.0/glib-object.h:22,
2d40367
                 from tmp-introspectg6xadxkr/Libosinfo-1.0.c:30:
2d40367
/usr/include/glib-2.0/gobject/gtype.h:1050:3: note: declared here
2d40367
 1050 |   G_TYPE_FLAG_FINAL GLIB_AVAILABLE_ENUMERATOR_IN_2_70 = (1 << 6)
2d40367
      |   ^~~~~~~~~~~~~~~~~
2d40367
tmp-introspectg6xadxkr/Libosinfo-1.0.c:251:13: error: Not available before 2.70 [-Werror]
2d40367
  251 |   if (G_TYPE_IS_FINAL (type))
2d40367
      |             ^~~~~~~~~~~~~~~~~
2d40367
2d40367
This is actually harmless, because systems with an older glib will also
2d40367
have older g-ir-scanner and thus not be using these new APIs.
2d40367
2d40367
We need to exclude the glib version constraints from code generated by
2d40367
glib tools, and thus means we have to stop using add_project_arguments()
2d40367
and set cflags explicitly on each target.
2d40367
2d40367
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2d40367
---
2d40367
 meson.build        | 2 --
2d40367
 osinfo/meson.build | 1 +
2d40367
 tests/meson.build  | 2 +-
2d40367
 tools/meson.build  | 3 +++
2d40367
 4 files changed, 5 insertions(+), 3 deletions(-)
2d40367
2d40367
diff --git a/meson.build b/meson.build
2d40367
index 0cbdb50..18dd26c 100644
2d40367
--- a/meson.build
2d40367
+++ b/meson.build
2d40367
@@ -331,8 +331,6 @@ if usb_ids_path != ''
2d40367
     message('Location of usb.ids: "@0@"'.format(usb_ids_path))
2d40367
 endif
2d40367
 
2d40367
-add_project_arguments(libosinfo_cflags, language: 'c')
2d40367
-
2d40367
 libosinfo_version = meson.project_version()
2d40367
 libosinfo_major_version = libosinfo_version.split('.')[0].to_int()
2d40367
 libosinfo_minor_version = libosinfo_version.split('.')[1].to_int()
2d40367
diff --git a/osinfo/meson.build b/osinfo/meson.build
2d40367
index d127143..cdd150a 100644
2d40367
--- a/osinfo/meson.build
2d40367
+++ b/osinfo/meson.build
2d40367
@@ -149,6 +149,7 @@ libosinfo = library(
2d40367
         libosinfo_sources,
2d40367
         libosinfo_enum_types,
2d40367
     ],
2d40367
+    c_args: libosinfo_cflags,
2d40367
     dependencies: libosinfo_dependencies,
2d40367
     include_directories: libosinfo_include,
2d40367
     link_args: libosinfo_link_args,
2d40367
diff --git a/tests/meson.build b/tests/meson.build
2d40367
index 3e631dd..2716ef9 100644
2d40367
--- a/tests/meson.build
2d40367
+++ b/tests/meson.build
2d40367
@@ -51,7 +51,7 @@ foreach src: tests_sources
2d40367
     exe = executable(name,
2d40367
         sources: src,
2d40367
         dependencies: libosinfo_dep,
2d40367
-        c_args: [
2d40367
+        c_args: libosinfo_cflags + [
2d40367
             '-DSRCDIR="@0@"'.format(meson.source_root()),
2d40367
             '-DBUILDDIR="@0@"'.format(meson.build_root()),
2d40367
         ],
2d40367
diff --git a/tools/meson.build b/tools/meson.build
2d40367
index 0a95664..248b1e9 100644
2d40367
--- a/tools/meson.build
2d40367
+++ b/tools/meson.build
2d40367
@@ -1,6 +1,7 @@
2d40367
 # osinfo-detect
2d40367
 executable(
2d40367
     'osinfo-detect',
2d40367
+    c_args: libosinfo_cflags,
2d40367
     sources: 'osinfo-detect.c',
2d40367
     dependencies: [
2d40367
         glib_dep,
2d40367
@@ -15,6 +16,7 @@ executable(
2d40367
 # osinfo-install-script
2d40367
 executable(
2d40367
     'osinfo-install-script',
2d40367
+    c_args: libosinfo_cflags,
2d40367
     sources: 'osinfo-install-script.c',
2d40367
     dependencies: [
2d40367
         glib_dep,
2d40367
@@ -28,6 +30,7 @@ executable(
2d40367
 # osinfo-query
2d40367
 executable(
2d40367
     'osinfo-query',
2d40367
+    c_args: libosinfo_cflags,
2d40367
     sources: 'osinfo-query.c',
2d40367
     dependencies: [
2d40367
         glib_dep,