From 2d40367415ef437e30d89fac6475e4849bbc4937 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 11 Jan 2022 11:05:27 -0500 Subject: [PATCH] Fix build with glib 2.70 Signed-off-by: Cole Robinson --- ...glib-version-constraints-for-g-ir-sc.patch | 120 ++++++++++++++++++ libosinfo.spec | 6 +- 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 0001-build-don-t-set-glib-version-constraints-for-g-ir-sc.patch diff --git a/0001-build-don-t-set-glib-version-constraints-for-g-ir-sc.patch b/0001-build-don-t-set-glib-version-constraints-for-g-ir-sc.patch new file mode 100644 index 0000000..8452842 --- /dev/null +++ b/0001-build-don-t-set-glib-version-constraints-for-g-ir-sc.patch @@ -0,0 +1,120 @@ +From d5807a0f458b310112c0794e7ea43ccd55a8bba5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= +Date: Mon, 27 Sep 2021 15:21:52 +0100 +Subject: [PATCH libosinfo] build: don't set glib version constraints for + g-ir-scanner +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +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é +--- + meson.build | 2 -- + osinfo/meson.build | 1 + + tests/meson.build | 2 +- + tools/meson.build | 3 +++ + 4 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/meson.build b/meson.build +index 0cbdb50..18dd26c 100644 +--- a/meson.build ++++ b/meson.build +@@ -331,8 +331,6 @@ if usb_ids_path != '' + message('Location of usb.ids: "@0@"'.format(usb_ids_path)) + endif + +-add_project_arguments(libosinfo_cflags, language: 'c') +- + libosinfo_version = meson.project_version() + libosinfo_major_version = libosinfo_version.split('.')[0].to_int() + libosinfo_minor_version = libosinfo_version.split('.')[1].to_int() +diff --git a/osinfo/meson.build b/osinfo/meson.build +index d127143..cdd150a 100644 +--- a/osinfo/meson.build ++++ b/osinfo/meson.build +@@ -149,6 +149,7 @@ libosinfo = library( + libosinfo_sources, + libosinfo_enum_types, + ], ++ c_args: libosinfo_cflags, + dependencies: libosinfo_dependencies, + include_directories: libosinfo_include, + link_args: libosinfo_link_args, +diff --git a/tests/meson.build b/tests/meson.build +index 3e631dd..2716ef9 100644 +--- a/tests/meson.build ++++ b/tests/meson.build +@@ -51,7 +51,7 @@ foreach src: tests_sources + exe = executable(name, + sources: src, + dependencies: libosinfo_dep, +- c_args: [ ++ c_args: libosinfo_cflags + [ + '-DSRCDIR="@0@"'.format(meson.source_root()), + '-DBUILDDIR="@0@"'.format(meson.build_root()), + ], +diff --git a/tools/meson.build b/tools/meson.build +index 0a95664..248b1e9 100644 +--- a/tools/meson.build ++++ b/tools/meson.build +@@ -1,6 +1,7 @@ + # osinfo-detect + executable( + 'osinfo-detect', ++ c_args: libosinfo_cflags, + sources: 'osinfo-detect.c', + dependencies: [ + glib_dep, +@@ -15,6 +16,7 @@ executable( + # osinfo-install-script + executable( + 'osinfo-install-script', ++ c_args: libosinfo_cflags, + sources: 'osinfo-install-script.c', + dependencies: [ + glib_dep, +@@ -28,6 +30,7 @@ executable( + # osinfo-query + executable( + 'osinfo-query', ++ c_args: libosinfo_cflags, + sources: 'osinfo-query.c', + dependencies: [ + glib_dep, diff --git a/libosinfo.spec b/libosinfo.spec index 9598666..44220cb 100644 --- a/libosinfo.spec +++ b/libosinfo.spec @@ -3,12 +3,13 @@ Summary: A library for managing OS information for virtualization Name: libosinfo Version: 1.9.0 -Release: 2%{?dist} +Release: 3%{?dist} License: LGPLv2+ Source: https://releases.pagure.io/%{name}/%{name}-%{version}.tar.xz URL: https://libosinfo.org/ ### Patches ### +Patch0001: 0001-build-don-t-set-glib-version-constraints-for-g-ir-sc.patch BuildRequires: meson BuildRequires: gcc @@ -96,6 +97,9 @@ Libraries, includes, etc. to compile with the libosinfo library %{_datadir}/vala/vapi/libosinfo-1.0.vapi %changelog +* Tue Jan 11 2022 Cole Robinson - 1.9.0-3 +- Fix build with glib 2.70 + * Thu Jul 22 2021 Fedora Release Engineering - 1.9.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild