diff mbox series

[meta-oe,6/6] libosinfo: Do not error on clang's -Wunused-but-set-global

Message ID 20260908020752.2748681-6-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-oe,1/6] assimp: Do not treat warnings as errors | expand

Commit Message

Khem Raj Sept. 8, 2026, 2:07 a.m. UTC
clang 23 added -Wunused-but-set-global to the -Wunused warning group, so
the -Werror that meson.build adds for git builds turns it into a hard
error:

  osinfo/osinfo_avatar_format.c:24:1: error: variable
    'osinfo_avatar_format_parent_class' set but not used
    [-Werror,-Wunused-but-set-global]

Add -Wno-error=unused-but-set-global to libosinfo_check_cflags so the
warning stays visible but is not fatal. The flag is placed in the list
that meson.build filters through compiler.has_argument(), so it is
dropped on compilers that do not know the warning group

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...ror-on-clang-s-unused-but-set-global.patch | 45 +++++++++++++++++++
 .../libosinfo/libosinfo_1.12.0.bb             |  1 +
 2 files changed, 46 insertions(+)
 create mode 100644 meta-oe/recipes-support/libosinfo/libosinfo/0002-meson-don-t-error-on-clang-s-unused-but-set-global.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/libosinfo/libosinfo/0002-meson-don-t-error-on-clang-s-unused-but-set-global.patch b/meta-oe/recipes-support/libosinfo/libosinfo/0002-meson-don-t-error-on-clang-s-unused-but-set-global.patch
new file mode 100644
index 0000000000..042aaac21a
--- /dev/null
+++ b/meta-oe/recipes-support/libosinfo/libosinfo/0002-meson-don-t-error-on-clang-s-unused-but-set-global.patch
@@ -0,0 +1,45 @@ 
+From ab54bb415451f0b85207867ae2d68c5dcf1a191c Mon Sep 17 00:00:00 2001
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Mon, 7 Sep 2026 18:39:42 -0700
+Subject: [PATCH] meson: don't error on clang's -Wunused-but-set-global
+
+clang 23 added -Wunused-but-set-global to the -Wunused warning group, so
+the -Werror that meson.build adds for git builds now turns it into a hard
+error:
+
+  osinfo/osinfo_avatar_format.c:24:1: error: variable
+    'osinfo_avatar_format_parent_class' set but not used
+    [-Werror,-Wunused-but-set-global]
+
+It fires on the <type>_parent_class variables that GLib's G_DEFINE_TYPE
+family of macros emit, which libosinfo cannot fix, and on the write-only
+'format' global in tools/osinfo-detect.c.
+
+Keep the warning visible but not fatal. gcc does not know this warning
+group and rejects the flag outright, so compiler.has_argument() drops it
+there.
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ meson.build | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/meson.build b/meson.build
+index 377539d..7fd9de7 100644
+--- a/meson.build
++++ b/meson.build
+@@ -246,6 +246,12 @@ if compiler.get_id() == 'clang'
+     libosinfo_check_cflags += [
+         '-Wno-typedef-redefinition',
+         '-Wno-missing-field-initializers',
++        # clang 23 added -Wunused-but-set-global to the -Wunused group. It
++        # fires on the <type>_parent_class variables that GLib's G_DEFINE_TYPE
++        # family of macros emit, which libosinfo cannot fix, and on the
++        # deliberately write-only 'format' global in osinfo-detect.
++        # Keep the warning visible but not fatal.
++        '-Wno-error=unused-but-set-global',
+     ]
+ endif
+
diff --git a/meta-oe/recipes-support/libosinfo/libosinfo_1.12.0.bb b/meta-oe/recipes-support/libosinfo/libosinfo_1.12.0.bb
index 94286872b3..2a8059cf22 100644
--- a/meta-oe/recipes-support/libosinfo/libosinfo_1.12.0.bb
+++ b/meta-oe/recipes-support/libosinfo/libosinfo_1.12.0.bb
@@ -9,6 +9,7 @@  SRC_URI = " \
 	git://gitlab.com/libosinfo/libosinfo.git;branch=main;protocol=https \
 	file://0001-meson.build-allow-crosscompiling-gir.patch \
 	file://0adf38535637ec668e658d43f04f60f11f51574f.patch \
+	file://0002-meson-don-t-error-on-clang-s-unused-but-set-global.patch \
 "

 SRCREV = "b505ef5161d2552102a743acd4ad83298d3d8f99"