glib: various fixes (#48840)

* remove preferred to allow seamless python@3.12 usage

* glib: remove deprecated versions

* glib: use extends because python-venv is pulled in from build deps and put into path

* dont patch patch versions, use new patch releases containing the fix instead

* restrict patch of shebangs, group relevant bits together

* simplify lowerbound

* fix pinned glib version

---------

Co-authored-by: Chris Marsh <chrismarsh.c2@gmail.com>
This commit is contained in:
Harmen Stoppels 2025-02-24 09:17:45 +01:00 committed by GitHub
parent 6cd74efa90
commit 9555ceeb8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 52 additions and 261 deletions

View File

@ -1,34 +0,0 @@
From 00148329967adb196138372771052a3f606a6ea3 Mon Sep 17 00:00:00 2001
From: coypu <coypu@sdf.org>
Date: Wed, 2 Mar 2016 19:43:10 +0200
Subject: [PATCH 2/2] gdate: Suppress string format literal warning
Newer versions of GCC emit an error here, but we know it's safe.
https://bugzilla.gnome.org/761550
---
glib/gdate.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/glib/gdate.c b/glib/gdate.c
index 4aece02..92c34d2 100644
--- a/glib/gdate.c
+++ b/glib/gdate.c
@@ -2439,6 +2439,9 @@ win32_strftime_helper (const GDate *d,
*
* Returns: number of characters written to the buffer, or 0 the buffer was too small
*/
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
gsize
g_date_strftime (gchar *s,
gsize slen,
@@ -2549,3 +2552,5 @@ g_date_strftime (gchar *s,
return retval;
#endif
}
+
+#pragma GCC diagnostic pop
--
2.7.1

View File

@ -1,13 +0,0 @@
--- a/configure 2017-05-12 16:03:01.000000000 -0500
+++ b/configure 2017-05-12 16:01:58.000000000 -0500
@@ -29273,8 +29273,8 @@
for flag in \
-Wall -Wstrict-prototypes -Werror=declaration-after-statement \
-Werror=missing-prototypes -Werror=implicit-function-declaration \
- -Werror=pointer-arith -Werror=init-self -Werror=format-security \
- -Werror=format=2 -Werror=missing-include-dirs; do
+ -Werror=pointer-arith -Werror=init-self \
+ -Werror=missing-include-dirs; do
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports flag $flag in envvar CFLAGS" >&5
$as_echo_n "checking if $CC supports flag $flag in envvar CFLAGS... " >&6; }

View File

@ -1,16 +0,0 @@
--- a/gio/gfile.c 2018-06-11 15:28:30.527667202 -0500
+++ b/gio/gfile.c 2018-03-12 11:23:37.000000000 -0500
@@ -3014,11 +3014,11 @@
/* Try a 1MiB buffer for improved throughput. If that fails, use the default
* pipe size. See: https://bugzilla.gnome.org/791457 */
- buffer_size = fcntl (buffer[1], F_SETPIPE_SZ, 1024 * 1024);
+ buffer_size = -1;
if (buffer_size <= 0)
{
int errsv;
- buffer_size = fcntl (buffer[1], F_GETPIPE_SZ);
+ buffer_size = 65536;
errsv = errno;
if (buffer_size <= 0)

View File

@ -4,24 +4,22 @@
import os
import spack.build_systems.autotools
import spack.build_systems.meson
from spack.package import *
from spack.util.environment import is_system_path
class Glib(MesonPackage, AutotoolsPackage):
"""GLib provides the core application building blocks for
libraries and applications written in C.
class Glib(MesonPackage):
"""GLib provides the core application building blocks for libraries and applications written
in C.
The GLib package contains a low-level libraries useful for
providing data structure handling for C, portability wrappers
and interfaces for such runtime functionality as an event loop,
The GLib package contains a low-level libraries useful for providing data structure handling
for C, portability wrappers and interfaces for such runtime functionality as an event loop,
threads, dynamic loading and an object system.
"""
homepage = "https://developer.gnome.org/glib/"
url = "https://download.gnome.org/sources/glib/2.53/glib-2.53.1.tar.xz"
url = "https://download.gnome.org/sources/glib/2.82/glib-2.82.2.tar.xz"
list_url = "https://download.gnome.org/sources/glib"
list_depth = 1
@ -31,12 +29,7 @@ class Glib(MesonPackage, AutotoolsPackage):
# Even minor versions are stable, odd minor versions are development, only add even numbers
version("2.82.2", sha256="ab45f5a323048b1659ee0fbda5cecd94b099ab3e4b9abf26ae06aeb3e781fd63")
# No real reason to prefer older versions, `preferred` should be removed after testing
version(
"2.78.3",
sha256="609801dd373796e515972bf95fc0b2daa44545481ee2f465c4f204d224b2bc21",
preferred=True,
)
version("2.78.3", sha256="609801dd373796e515972bf95fc0b2daa44545481ee2f465c4f204d224b2bc21")
version("2.78.0", sha256="44eaab8b720877ce303c5540b657b126f12dc94972d9880b52959f43fb537b30")
version("2.76.6", sha256="1136ae6987dcbb64e0be3197a80190520f7acab81e2bfb937dc85c11c8aa9f04")
version("2.76.4", sha256="5a5a191c96836e166a7771f7ea6ca2b0069c603c7da3cba1cd38d1694a395dda")
@ -72,64 +65,9 @@ class Glib(MesonPackage, AutotoolsPackage):
version("2.62.6", sha256="104fa26fbefae8024ff898330c671ec23ad075c1c0bce45c325c6d5657d58b9c")
version("2.60.7", sha256="8b12c0af569afd3b71200556ad751bad4cf4bf7bc4b5f880638459a42ca86310")
version("2.58.3", sha256="8f43c31767e88a25da72b52a40f3301fefc49a665b56dc10ee7cc9565cbe7481")
version(
"2.56.4",
sha256="27f703d125efb07f8a743666b580df0b4095c59fc8750e8890132c91d437504c",
deprecated=True,
)
version(
"2.56.3",
sha256="a9a4c5b4c81b6c75bc140bdf5e32120ef3ce841b7413214ecf5f987acec74cb2",
deprecated=True,
)
version(
"2.56.2",
sha256="d64abd16813501c956c4e123ae79f47f1b58de573df9fdd3b0795f1e2c1aa789",
deprecated=True,
)
version(
"2.56.1",
sha256="40ef3f44f2c651c7a31aedee44259809b6f03d3d20be44545cd7d177221c0b8d",
deprecated=True,
)
version(
"2.56.0",
sha256="ecef6e17e97b8d9150d0e8a4b3edee1ac37331213b8a2a87a083deea408a0fc7",
deprecated=True,
)
version(
"2.55.1",
sha256="0cbb3d31c9d181bbcc97cba3d9dbe3250f75e2da25e5f7c8bf5a993fe54baf6a",
deprecated=True,
)
version(
"2.53.1",
sha256="c8740f1d1a138086eede889b596a511fddda180646ab2f1d98aed4fdb6be7f72",
deprecated=True,
)
version(
"2.49.7",
sha256="0fd13406ca31d6f654c3be620e0adaaa4f9fb788e164e265e33edf4b21e64ef6",
deprecated=True,
)
version(
"2.49.4",
sha256="9e914f9d7ebb88f99f234a7633368a7c1133ea21b5cac9db2a33bc25f7a0e0d1",
deprecated=True,
)
version(
"2.48.1",
sha256="74411bff489cb2a3527bac743a51018841a56a4d896cc1e0d0d54f8166a14612",
deprecated=True,
)
version(
"2.42.1",
sha256="8f3f0865280e45b8ce840e176ef83bcfd511148918cc8d39df2ee89b67dcf89a",
deprecated=True,
)
depends_on("c", type="build") # generated
depends_on("cxx", type="build") # generated
depends_on("c", type="build")
depends_on("cxx", type="build")
variant("libmount", default=False, description="Build with libmount support")
variant(
@ -138,69 +76,38 @@ class Glib(MesonPackage, AutotoolsPackage):
description="Enable tracing support",
)
build_system(
conditional("meson", when="@2.58:"),
conditional("autotools", when="@:2.57"),
default="meson",
)
with when("build_system=meson"):
depends_on("meson@1.4:", when="@2.83:", type="build")
depends_on("meson@1.2:", when="@2.79:", type="build")
depends_on("meson@0.60.0:", when="@2.73:", type="build")
depends_on("meson@0.52.0:", when="@2.71:2.72", type="build")
depends_on("meson@0.49.2:", when="@2.61.2:2.70", type="build")
depends_on("meson@0.48.0:", when="@:2.61.1", type="build")
with default_args(type="build"):
depends_on("meson@1.4:", when="@2.83:")
depends_on("meson@1.2:", when="@2.79:")
depends_on("meson@0.60.0:", when="@2.73:")
depends_on("meson@0.52.0:", when="@2.71:")
depends_on("meson@0.49.2:", when="@2.61.2:")
depends_on("meson@0.48.0:")
depends_on("pkgconfig", type="build")
depends_on("libffi")
depends_on("zlib-api")
depends_on("gettext")
depends_on("perl", type=("build", "run"))
depends_on("python", type=("build", "run"), when="@2.53.4:")
extends("python", type=("build", "run"))
# Uses distutils in gio/gdbus-2.0/codegen/utils.py
depends_on("python@:3.11", type=("build", "run"), when="@2.53.4:2.78")
depends_on("python@:3.11", type=("build", "run"), when="@:2.78")
depends_on("pcre2", when="@2.73.2:")
depends_on("pcre2@10.34:", when="@2.74:")
depends_on("pcre+utf", when="@2.48:2.73.1")
depends_on("pcre+utf", when="@:2.73.1")
depends_on("uuid", when="+libmount")
depends_on("util-linux", when="+libmount")
depends_on("iconv")
depends_on("elf") # bin/gresource
# The following patch is needed for gcc-6.1
patch("g_date_strftime.patch", when="@2.42.1")
# Clang doesn't seem to acknowledge the pragma lines to disable the -Werror
# around a legitimate usage.
patch("no-Werror=format-security.patch", when="@:2.57")
# Patch to prevent compiler errors in kernels older than 2.6.35
patch("old-kernels.patch", when="@2.56.0:2.56.1 os=rhel6")
patch("old-kernels.patch", when="@2.56.0:2.56.1 os=centos6")
patch("old-kernels.patch", when="@2.56.0:2.56.1 os=scientific6")
# fix multiple definition error in gio tests for 2.76.1
patch(
"https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3368.diff",
sha256="fa31180b55a832cbb75cc640bb115b7b092a26d7bcf0f48768de55576f0a38d3",
when="@2.76.1",
)
# glib prefers the libc version of gettext, which breaks the build if the
# external version is also found.
patch("meson-gettext.patch", when="@2.58:2.64")
patch("meson-gettext.patch", when="@:2.64")
patch("meson-gettext-2.66.patch", when="@2.66:2.68,2.72")
patch("meson-gettext-2.70.patch", when="@2.70")
# Don't use PTRACE_O_EXITKILL if it's not defined
patch(
"https://gitlab.gnome.org/GNOME/glib/-/commit/bda87264372c006c94e21ffb8ff9c50ecb3e14bd.diff",
sha256="2c25d7b3bf581b3ec992d7af997fa6c769174d49b9350e0320c33f5e048cba99",
when="@2.78.0",
)
def url_for_version(self, version):
"""Handle glib's version-based custom URLs."""
url = "https://download.gnome.org/sources/glib"
return url + "/%s/glib-%s.tar.xz" % (version.up_to(2), version)
return f"https://download.gnome.org/sources/glib/{version.up_to(2)}/glib-{version}.tar.xz"
def patch(self):
"""A few glib tests have external dependencies / try to access the X server"""
@ -219,27 +126,37 @@ def libs(self):
return find_libraries(["libglib*"], root=self.prefix, recursive=True)
class AnyBuilder(BaseBuilder):
class MesonBuilder(spack.build_systems.meson.MesonBuilder):
@property
def dtrace_copy_path(self):
return join_path(self.stage.source_path, "dtrace-copy")
@run_before("install")
def fix_python_path(self):
if not self.spec.satisfies("@2.53.4:"):
return
files = ["gobject/glib-genmarshal.in", "gobject/glib-mkenums.in"]
@run_before("install", when="@:2.80") # @2.81: uses meson found python abs path.
def fix_python_path_before_install(self):
filter_file(
"^#!/usr/bin/env @PYTHON@",
"#!/usr/bin/env {0}".format(os.path.basename(self.spec["python"].command.path)),
*files,
f"#!/usr/bin/env {os.path.basename(self.spec['python'].command.path)}",
"gobject/glib-genmarshal.in",
"gobject/glib-mkenums.in",
)
@run_after("install", when="@:2.80")
def fix_python_path_after_install(self):
# Revert shebang, so Spack's sbang hook can fix it up (we have to do
# this after install because otherwise the install target will try
# to rebuild files as filter_file updates the timestamps)
python_path = os.path.basename(self.spec["python"].command.path)
filter_file(
f"^#!/usr/bin/env {os.path.basename(python_path)}",
f"#!{self.spec['python'].command.path}",
join_path(self.prefix.bin, "glib-genmarshal"),
join_path(self.prefix.bin, "glib-mkenums"),
)
@run_before("install")
def fix_dtrace_usr_bin_path(self):
if "tracing=dtrace" not in self.spec:
if not self.spec.satisfies("tracing=dtrace"):
return
# dtrace may cause glib build to fail because it uses
@ -253,7 +170,7 @@ def fix_dtrace_usr_bin_path(self):
copy(dtrace, dtrace_copy)
filter_file(
"^#!/usr/bin/python",
"#!/usr/bin/env {0}".format(os.path.basename(self.spec["python"].command.path)),
f"#!/usr/bin/env {os.path.basename(self.spec['python'].command.path)}",
dtrace_copy,
)
@ -261,25 +178,6 @@ def fix_dtrace_usr_bin_path(self):
# prepend to PATH the temporary folder where it resides
env["PATH"] = ":".join([self.dtrace_copy_path] + env["PATH"].split(":"))
@run_after("install")
def filter_sbang(self):
# Revert sbang, so Spack's sbang hook can fix it up (we have to do
# this after install because otherwise the install target will try
# to rebuild files as filter_file updates the timestamps)
if self.spec.satisfies("@2.53.4:"):
pattern = "^#!/usr/bin/env {0}".format(
os.path.basename(self.spec["python"].command.path)
)
repl = "#!{0}".format(self.spec["python"].command.path)
files = ["glib-genmarshal", "glib-mkenums"]
else:
pattern = "^#! /usr/bin/perl"
repl = "#!{0}".format(self.spec["perl"].command.path)
files = ["glib-mkenums"]
files = [join_path(self.prefix.bin, file) for file in files]
filter_file(pattern, repl, *files, backup=False)
@run_after("install")
def gettext_libdir(self):
# Packages that link to glib were also picking up -lintl from glib's
@ -289,17 +187,16 @@ def gettext_libdir(self):
# appropriate -L path.
spec = self.spec
if (
spec.satisfies("@2.0:2")
and "intl" in self.spec["gettext"].libs.names
spec.satisfies("@2")
and "intl" in spec["gettext"].libs.names
and not is_system_path(spec["gettext"].prefix)
):
pattern = "Libs:"
repl = "Libs: -L{0} -Wl,-rpath={0} ".format(spec["gettext"].libs.directories[0])
myfile = join_path(self.spec["glib"].libs.directories[0], "pkgconfig", "glib-2.0.pc")
filter_file(pattern, repl, myfile, backup=False)
filter_file(
"Libs:",
"Libs: -L{0} -Wl,-rpath={0} ".format(spec["gettext"].libs.directories[0]),
join_path(self.spec["glib"].libs.directories[0], "pkgconfig", "glib-2.0.pc"),
)
class MesonBuilder(AnyBuilder, spack.build_systems.meson.MesonBuilder):
def meson_args(self):
args = []
if self.spec.satisfies("@2.63.5:"):
@ -339,46 +236,3 @@ def meson_args(self):
else:
args.append("-Diconv=libc")
return args
class AutotoolsBuilder(AnyBuilder, spack.build_systems.autotools.AutotoolsBuilder):
def configure_args(self):
args = []
if self.spec.satisfies("+libmount"):
args.append("--enable-libmount")
else:
args.append("--disable-libmount")
if self.spec.satisfies("@2.53.4:"):
args.append(
"--with-python={0}".format(os.path.basename(self.spec["python"].command.path))
)
if self.spec["iconv"].name == "libiconv":
args.append("--with-libiconv=gnu")
else:
args.append("--with-libiconv=maybe")
if self.spec.satisfies("@2.56:"):
for value in ("dtrace", "systemtap"):
if ("tracing=" + value) in self.spec:
args.append("--enable-" + value)
else:
args.append("--disable-" + value)
else:
if self.spec.satisfies("tracing=dtrace") or self.spec.satisfies("tracing=systemtap"):
args.append("--enable-tracing")
else:
args.append("--disable-tracing")
# SELinux is not available in Spack, so glib should not use it.
args.append("--disable-selinux")
# glib should not use the globally installed gtk-doc. Otherwise,
# gtk-doc can fail with Python errors such as "ImportError: No module
# named site". This is due to the fact that Spack sets PYTHONHOME,
# which can confuse the global Python installation used by gtk-doc.
args.append("--disable-gtk-doc-html")
# glib uses gtk-doc even though it should be disabled if it can find
# its binaries. Override the checks to use the true binary.
true = which("true")
args.append("GTKDOC_CHECK={0}".format(true))
args.append("GTKDOC_CHECK_PATH={0}".format(true))
args.append("GTKDOC_MKPDF={0}".format(true))
args.append("GTKDOC_REBASE={0}".format(true))
return args

View File

@ -49,7 +49,7 @@ class GobjectIntrospection(MesonPackage, AutotoolsPackage):
depends_on("glib@2.58:", when="@1.60:1.72")
depends_on("glib@2.56:", when="@1.56")
depends_on("glib@2.49.2:", when="@1.49.2")
depends_on("glib@2.48.1", when="@1.48.0")
depends_on("glib@2.48.1:", when="@1.48.0")
depends_on("libffi")
# https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/283