Skip to content

build: Bump GLIB_VERSION_MAX_ALLOWED to 2.76#724

Closed
bbhtt wants to merge 1 commit intoflatpak-builder-1.4.xfrom
bbhtt/prevent-glib-warnings-1.4
Closed

build: Bump GLIB_VERSION_MAX_ALLOWED to 2.76#724
bbhtt wants to merge 1 commit intoflatpak-builder-1.4.xfrom
bbhtt/prevent-glib-warnings-1.4

Conversation

@bbhtt
Copy link
Copy Markdown
Contributor

@bbhtt bbhtt commented Apr 8, 2026

libglnx update in d7fcee0 uses g_clear_fd() (GLib >= 2.76), but GLIB_VERSION_MAX_ALLOWED was still 2.70, triggering deprecation warnings when compiling with newer Glib.

g_clear_fd() has a compat implementation inside libglnx so there's no need to bump the minimum GLib requirement.

libglnx update in d7fcee0 uses g_clear_fd() (GLib >= 2.76), but
GLIB_VERSION_MAX_ALLOWED was still 2.70, triggering
deprecation warnings when compiling with newer Glib.

g_clear_fd() has a compat implementation inside libglnx so there's no
need to bump the minimum GLib requirement.
@bbhtt bbhtt force-pushed the bbhtt/prevent-glib-warnings-1.4 branch from 5cc3355 to e6ccd24 Compare April 8, 2026 02:45
@bbhtt bbhtt changed the title meson: Bump GLIB_VERSION_MAX_ALLOWED to 2.76 build: Bump GLIB_VERSION_MAX_ALLOWED to 2.76 Apr 8, 2026
@bbhtt
Copy link
Copy Markdown
Contributor Author

bbhtt commented Apr 8, 2026

this is a bit tricky, if API newer than 2.66 is accidentally used, we won't get the warning and CI has 2.72 so it won't fail.

@bbhtt
Copy link
Copy Markdown
Contributor Author

bbhtt commented Apr 8, 2026

One option is to wrap it in libglnx for >=2.76

#if !GLIB_CHECK_VERSION(2, 76, 0)
static inline gboolean
g_clear_fd (int     *fd_ptr,
            GError **error)
{
  int fd = *fd_ptr;

  *fd_ptr = -1;

  if (fd < 0)
    return TRUE;

  /* Suppress "Not available before" warning */
  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  /* This importantly calls _glnx_close to always get async-signal-safe if
   * error == NULL */
  return _glnx_close (fd, error);
  G_GNUC_END_IGNORE_DEPRECATIONS
}

#else

static inline gboolean
_glnx_clear_fd (int     *fd_ptr,
                GError **error)
{
    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
    return g_clear_fd (fd_ptr, error);
    G_GNUC_END_IGNORE_DEPRECATIONS
}
#define g_clear_fd _glnx_clear_fd

#endif

@smcv
Copy link
Copy Markdown
Collaborator

smcv commented Apr 8, 2026

GLIB_VERSION_MAX_ALLOWED just doesn't work very well with a library like libglnx that provides opportunistic backports. It's a useful mechanism to avoid some unintended dependencies on newer GLib versions, but there isn't really any substitute for actually compiling against the oldest distro that is aimed to be supported in CI.

One option is to wrap it in libglnx for >=2.76

Yeah, perhaps libglnx should do that.

@bbhtt
Copy link
Copy Markdown
Contributor Author

bbhtt commented Apr 8, 2026

Opened https://gitlab.gnome.org/GNOME/libglnx/-/issues/7 for this. The min/max macros were added during the Meson port, but the intention is not clear to me in the commit message 62c85a1.

I can drop them but it seems somewhat useful to me to have

@smcv
Copy link
Copy Markdown
Collaborator

smcv commented Apr 8, 2026

In the failing builds, is it failing because of a use of g_clear_fd() in a macro or inline function in a libglnx header, or is libglnx itself being compiled with GLIB_VERSION_MAX_ALLOWED?

If libglnx itself is being compiled with GLIB_VERSION_MAX_ALLOWED, I think the intention is to not do that, and instead compile only the dependent project (flatpak-builder in this case) with options like that.

Or if there's a new use of g_clear_fd() in a macro or inline function in a libglnx header, that could get a more targeted change.

@bbhtt
Copy link
Copy Markdown
Contributor Author

bbhtt commented Apr 8, 2026

If libglnx itself is being compiled with GLIB_VERSION_MAX_ALLOWED, I think the intention is to not do that, and instead compile only the dependent project (flatpak-builder in this case) with options like that.

Yea, f-b's config.h is leaking into libglnx, the Makefile is globally injecting it through AM_CPPFLAGS which is doing echo '#include "config.h"' > libglnx-config.h.

This doesn't affect Meson, only the autotools build system.

@bbhtt
Copy link
Copy Markdown
Contributor Author

bbhtt commented Apr 8, 2026

@smcv
Copy link
Copy Markdown
Collaborator

smcv commented Apr 8, 2026

The unique quirk of flatpak-builder that is making this worse for f-b than for other libglnx users might be as simple as "is still on Autotools", then.

@bbhtt
Copy link
Copy Markdown
Contributor Author

bbhtt commented Apr 8, 2026

#725 moves it to flatpak-builder only.

@bbhtt bbhtt closed this Apr 8, 2026
@bbhtt bbhtt deleted the bbhtt/prevent-glib-warnings-1.4 branch April 8, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants