[PATCH] glibcompat: remove obsolete clang workaround

Daniel P. Berrangé posted 1 patch 3 months, 1 week ago
src/util/glibcompat.h | 28 +---------------------------
1 file changed, 1 insertion(+), 27 deletions(-)
[PATCH] glibcompat: remove obsolete clang workaround
Posted by Daniel P. Berrangé 3 months, 1 week ago
This mostly reverts commit 65491a2dfe00bfcf9f09a8d6eab60234b56c8cc4.

There was a bug introduced in glib 2.67.0 which impacted libvirt with
clang causing -Wincompatible-pointer-types-discards-qualifiers warnings.

This was actually fixed quite quickly in 2.67.1 with

 https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Our workaround was then broken with glib 2.81.1 due to commit
14b3d5da9019150d821f6178a075d85044b4c255 changing the signature of the
(private) macro we were overriding.

Since odd-number glib releases are development snapshots, and the
original problem was only present in 2.67.0 and no other releases,
just drop the workaround entirely.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/util/glibcompat.h | 28 +---------------------------
 1 file changed, 1 insertion(+), 27 deletions(-)

diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h
index 3518023a41..474ff95bc5 100644
--- a/src/util/glibcompat.h
+++ b/src/util/glibcompat.h
@@ -22,33 +22,7 @@
 #include <glib/gstdio.h>
 #include <glib-object.h>
 
-#if GLIB_CHECK_VERSION(2, 67, 0)
-
-# if defined(__clang__)
-
-/*
- * Clang detects (valid) issue in G_DEFINE_TYPE and derivatives starting with
- * glib >= 2.67.0.  See https://gitlab.gnome.org/GNOME/glib/-/issues/600
- *
- * For that we need to disable the one check that produces an error in our
- * builds when using any G_DEFINE_TYPE* macro.  Thankfully all those macros end
- * up using _G_DEFINE_TYPE_EXTENDED_BEGIN.  Because with that we can redefine
- * this one macro to cover all use cases.  The macro is defined the same way it
- * is defined in glib (with a very low probability of being changed thanks to a
- * comment above it).
- */
-#  undef _G_DEFINE_TYPE_EXTENDED_BEGIN
-
-#  define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \
-    _Pragma("GCC diagnostic push") \
-    _Pragma("GCC diagnostic ignored \"-Wincompatible-pointer-types-discards-qualifiers\"") \
-    _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \
-    _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
-    _Pragma("GCC diagnostic pop")
-
-# endif /* __clang__ */
-
-#else /* GLib < 2.67.0 */
+#if !GLIB_CHECK_VERSION(2, 67, 0)
 
 /*
  * ...meanwhile GCC >= 11 has started issuing warnings about volatile
-- 
2.45.2
Re: [PATCH] glibcompat: remove obsolete clang workaround
Posted by Michal Prívozník 3 months, 1 week ago
On 8/12/24 12:30, Daniel P. Berrangé wrote:
> This mostly reverts commit 65491a2dfe00bfcf9f09a8d6eab60234b56c8cc4.
> 
> There was a bug introduced in glib 2.67.0 which impacted libvirt with
> clang causing -Wincompatible-pointer-types-discards-qualifiers warnings.
> 
> This was actually fixed quite quickly in 2.67.1 with
> 
>  https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719
> 
> Our workaround was then broken with glib 2.81.1 due to commit
> 14b3d5da9019150d821f6178a075d85044b4c255 changing the signature of the
> (private) macro we were overriding.
> 
> Since odd-number glib releases are development snapshots, and the
> original problem was only present in 2.67.0 and no other releases,
> just drop the workaround entirely.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  src/util/glibcompat.h | 28 +---------------------------
>  1 file changed, 1 insertion(+), 27 deletions(-)

I've tested this locally against glib's main and can confirm it fixes
the problem.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal