libvirt-glib/build-don-t-set-glib-version-constraints-for-g-ir-sc.patch
Sun Dongxu f688392730 build: don't set glib version constraints for g-ir-scanner
Signed-off-by: yezengruan <yezengruan@huawei.com>
2022-06-13 12:13:39 +08:00

140 lines
5.2 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 9a34c4ea55e0246c34896e48b8ecd637bc559ac7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
Date: Mon, 27 Sep 2021 14:58:17 +0100
Subject: [PATCH] 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_global_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
/root/rpmbuild/BUILD/libvirt-glib-4.0.0/redhat-linux-build/tmp-introspectkrq1wuz9/LibvirtGLib-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 /root/rpmbuild/BUILD/libvirt-glib-4.0.0/redhat-linux-build/tmp-introspectkrq1wuz9/LibvirtGLib-1.0.c:30:
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_global_arguments()
and set cflags explicitly on each target.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
examples/meson.build | 2 ++
libvirt-gconfig/tests/meson.build | 3 +++
meson.build | 5 ++---
tests/meson.build | 2 ++
4 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/examples/meson.build b/examples/meson.build
index 221356b..c1779e3 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -1,5 +1,6 @@
executable(
'event-test',
+ c_args: common_cflags,
sources: ['event-test.c'],
dependencies: libvirt_glib_dep,
include_directories: top_include_dir,
@@ -7,6 +8,7 @@ executable(
executable(
'conn-test',
+ c_args: common_cflags,
sources: ['conn-test.c'],
dependencies: [libvirt_glib_dep, libvirt_gconfig_dep, libvirt_gobject_dep],
include_directories: top_include_dir,
diff --git a/libvirt-gconfig/tests/meson.build b/libvirt-gconfig/tests/meson.build
index 7d85f03..2a1b252 100644
--- a/libvirt-gconfig/tests/meson.build
+++ b/libvirt-gconfig/tests/meson.build
@@ -1,5 +1,6 @@
test_domain_create = executable(
'test-domain-create',
+ c_args: common_cflags,
sources: ['test-domain-create.c'],
include_directories: top_include_dir,
dependencies: [libvirt_gconfig_dep]
@@ -7,6 +8,7 @@ test_domain_create = executable(
test_domain_parse = executable(
'test-domain-parse',
+ c_args: common_cflags,
sources: ['test-domain-parse.c'],
include_directories: top_include_dir,
dependencies: [libvirt_gconfig_dep]
@@ -14,6 +16,7 @@ test_domain_parse = executable(
test_capabilities_parse = executable(
'test-capabilities-parse',
+ c_args: common_cflags,
sources: ['test-capabilities-parse.c'],
include_directories: top_include_dir,
dependencies: [libvirt_gconfig_dep]
diff --git a/meson.build b/meson.build
index c4e69dd..eb1f313 100644
--- a/meson.build
+++ b/meson.build
@@ -50,9 +50,6 @@ libvirt_dep = dependency('libvirt', version: '>=' + libvirt_version)
libxml_min_version='>=2.9.1'
libxml_dep = dependency('libxml-2.0', version: libxml_min_version)
-add_global_arguments('-DGLIB_VERSION_MIN_REQUIRED=@0@'.format(glib_min_version_symbol), language: 'c')
-add_global_arguments('-DGLIB_VERSION_MAX_ALLOWED=@0@'.format(glib_min_version_symbol), language: 'c')
-
prefix = get_option('prefix')
localedir = join_paths(prefix, get_option('localedir'))
datadir = join_paths(prefix, get_option('datadir'))
@@ -520,6 +517,8 @@ common_cflags = [
'-DLOCALEDIR="@0@"'.format(localedir),
'-DDATADIR="@0@"'.format(datadir),
'-DLIBVIRT_GLIB_BUILD',
+ '-DGLIB_VERSION_MIN_REQUIRED=@0@'.format(glib_min_version_symbol),
+ '-DGLIB_VERSION_MAX_ALLOWED=@0@'.format(glib_min_version_symbol),
]
gnome = import('gnome')
diff --git a/tests/meson.build b/tests/meson.build
index df55930..444645f 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -4,6 +4,7 @@ testenv.append('G_TEST_BUILDDIR', meson.current_build_dir())
test_gconfig = executable(
'test-gconfig',
+ c_args: common_cflags,
sources: ['test-gconfig.c'],
include_directories: top_include_dir,
dependencies: [libvirt_gconfig_dep]
@@ -12,6 +13,7 @@ test('gconfig', test_gconfig, env: testenv)
test_events = executable(
'test-events',
+ c_args: common_cflags,
sources: ['test-events.c'],
include_directories: top_include_dir,
dependencies: [libvirt_glib_dep]
--
2.27.0