glib: Update to 2.70.5

Drop the gconvert patch as it was rejected upstream and it's unclear
what exactly it fixed for us.

Drop the gmodule patch as it's unclear if it's still needed, and module
loading seems to work for me.

Add a small patch replacing the cygwin DLL prefix. There are more cases
in the tests where MODULE_FILENAME_PREFIX and G_MODULE_SUFFIX are wrong,
or not set for cygwin, but that's for another time.
This commit is contained in:
Christoph Reiter 2022-04-03 12:26:31 +02:00
parent 409a7b8b19
commit 7b33d268cc
4 changed files with 39 additions and 187 deletions

View File

@ -0,0 +1,28 @@
--- glib-2.70.5/gmodule/gmodule-win32.c.orig 2022-04-03 11:58:46.475994600 +0200
+++ glib-2.70.5/gmodule/gmodule-win32.c 2022-04-03 11:58:23.491209800 +0200
@@ -211,10 +211,10 @@
if (k > 4 && g_ascii_strcasecmp (module_name + k - 4, ".dll") == 0)
return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, NULL);
#ifdef G_WITH_CYGWIN
- else if (strncmp (module_name, "lib", 3) == 0 || strncmp (module_name, "cyg", 3) == 0)
+ else if (strncmp (module_name, "lib", 3) == 0 || strncmp (module_name, "msys-", 4) == 0)
return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, ".dll", NULL);
else
- return g_strconcat (directory, G_DIR_SEPARATOR_S, "cyg", module_name, ".dll", NULL);
+ return g_strconcat (directory, G_DIR_SEPARATOR_S, "msys-", module_name, ".dll", NULL);
#else
else if (strncmp (module_name, "lib", 3) == 0)
return g_strconcat (directory, G_DIR_SEPARATOR_S, module_name, ".dll", NULL);
@@ -224,10 +224,10 @@
else if (k > 4 && g_ascii_strcasecmp (module_name + k - 4, ".dll") == 0)
return g_strdup (module_name);
#ifdef G_WITH_CYGWIN
- else if (strncmp (module_name, "lib", 3) == 0 || strncmp (module_name, "cyg", 3) == 0)
+ else if (strncmp (module_name, "lib", 3) == 0 || strncmp (module_name, "msys-", 4) == 0)
return g_strconcat (module_name, ".dll", NULL);
else
- return g_strconcat ("cyg", module_name, ".dll", NULL);
+ return g_strconcat ("msys-", module_name, ".dll", NULL);
#else
else if (strncmp (module_name, "lib", 3) == 0)
return g_strconcat (module_name, ".dll", NULL);

View File

@ -1,13 +0,0 @@
--- origsrc/glib-2.38.2/glib/gconvert.c 2014-04-02 01:48:25.505447200 -0500
+++ src/glib-2.38.2/glib/gconvert.c 2014-04-02 02:22:47.959345500 -0500
@@ -1583,7 +1583,9 @@ g_filename_from_uri (const gchar *uri,
return NULL;
}
- if (has_case_prefix (path_part, "///"))
+ if (has_case_prefix (path_part, "////"))
+ path_part += 1;
+ else if (has_case_prefix (path_part, "///"))
path_part += 2;
else if (has_case_prefix (path_part, "//"))
{

View File

@ -1,159 +0,0 @@
From e0732151aa27aea76f04558f6414bd95510621df Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Fri, 16 Oct 2020 14:44:15 +0200
Subject: [PATCH] 2.50-gmodule-cygwin (rebased)
---
gmodule/gmodule-win32.c | 72 +++++++++++++++++++++++++++++++++++------
1 file changed, 63 insertions(+), 9 deletions(-)
diff --git a/gmodule/gmodule-win32.c b/gmodule/gmodule-win32.c
index 2aea8bae9..4ee741cce 100644
--- a/gmodule/gmodule-win32.c
+++ b/gmodule/gmodule-win32.c
@@ -37,7 +37,20 @@
#ifdef G_WITH_CYGWIN
#include <sys/cygwin.h>
-#endif
+#include <dlfcn.h>
+
+static gchar*
+fetch_dlerror (gboolean replace_null)
+{
+ gchar *msg = dlerror ();
+
+ if (!msg && replace_null)
+ return "unknown dl-error";
+
+ return msg;
+}
+
+#else
static void G_GNUC_PRINTF (1, 2)
set_error (const gchar *format,
@@ -62,22 +75,26 @@ set_error (const gchar *format,
g_free (error);
}
+#endif /* G_WITH_CYGWIN */
+
/* --- functions --- */
static gpointer
_g_module_open (const gchar *file_name,
gboolean bind_lazy,
gboolean bind_local)
{
+#ifdef G_WITH_CYGWIN
+ gpointer handle;
+
+ handle = dlopen (file_name,
+ (bind_local ? RTLD_LOCAL : RTLD_GLOBAL) | (bind_lazy ? RTLD_LAZY : RTLD_NOW));
+ if (!handle)
+ g_module_set_error (fetch_dlerror (TRUE));
+#else
HINSTANCE handle;
wchar_t *wfilename;
DWORD old_mode;
BOOL success;
-#ifdef G_WITH_CYGWIN
- gchar tmp[MAX_PATH];
-
- cygwin_conv_to_win32_path(file_name, tmp);
- file_name = tmp;
-#endif
wfilename = g_utf8_to_utf16 (file_name, -1, NULL, NULL, NULL);
/* suppress error dialog */
@@ -99,25 +116,43 @@ _g_module_open (const gchar *file_name,
if (!handle)
set_error ("'%s': ", file_name);
+#endif
return handle;
}
+#ifndef G_WITH_CYGWIN
static gint dummy;
static gpointer null_module_handle = &dummy;
+#endif
static gpointer
_g_module_self (void)
{
+#ifdef G_WITH_CYGWIN
+ gpointer handle;
+
+ handle = dlopen (NULL, RTLD_GLOBAL | RTLD_LAZY);
+ if (!handle)
+ g_module_set_error (fetch_dlerror (TRUE));
+
+ return handle;
+#else
return null_module_handle;
+#endif
}
static void
_g_module_close (gpointer handle)
{
+#ifdef G_WITH_CYGWIN
+ if (dlclose (handle) != 0)
+ g_module_set_error (fetch_dlerror (TRUE));
+#else
if (handle != null_module_handle)
if (!FreeLibrary (handle))
set_error ("");
+#endif
}
static gpointer
@@ -152,8 +187,19 @@ find_in_any_module_using_toolhelp (const gchar *symbol_name)
if (Module32First (snapshot, &me32))
{
do {
- if ((p = GetProcAddress (me32.hModule, symbol_name)) != NULL)
- break;
+ if ((p = GetProcAddress (me32.hModule, symbol_name)) != NULL) {
+#ifdef G_WITH_CYGWIN
+ /* if symbol is found in another module, we probably do not want it */
+ ssize_t size = cygwin_conv_path (CCP_WIN_A_TO_POSIX, me32.szExePath, NULL, 0);
+ char *posix = (char *) alloca (size);
+ cygwin_conv_path (CCP_WIN_A_TO_POSIX, me32.szExePath, posix, size);
+ if (g_strstr_len (posix, size, "/usr/lib")
+ || g_strstr_len (posix, size, "/usr/local/lib"))
+ p = NULL;
+ else
+#endif
+ break;
+ }
} while (Module32Next (snapshot, &me32));
}
@@ -180,6 +226,13 @@ _g_module_symbol (gpointer handle,
{
gpointer p;
+#ifdef G_WITH_CYGWIN
+ p = dlsym (handle, symbol_name);
+ if (!p)
+ p = find_in_any_module (symbol_name);
+ if (!p)
+ g_module_set_error (fetch_dlerror (FALSE));
+#else
if (handle == null_module_handle)
{
if ((p = GetProcAddress (GetModuleHandle (NULL), symbol_name)) == NULL)
@@ -190,6 +243,7 @@ _g_module_symbol (gpointer handle,
if (!p)
set_error ("");
+#endif
return p;
}
--
2.28.0

View File

@ -2,7 +2,7 @@
pkgbase=glib2
pkgname=(glib2 glib2-devel glib2-docs)
pkgver=2.68.4
pkgver=2.70.5
pkgrel=1
pkgdesc="Common C routines used by GTK+ and other libs"
license=(LGPL2)
@ -22,31 +22,27 @@ makedepends=('docbook-xsl'
'ninja'
'zlib-devel')
source=(https://download.gnome.org/sources/glib/${pkgver%.*}/glib-$pkgver.tar.xz
2.38.2-gconvert-cygwin.patch
2.64-gmodule-cygwin-rebased.patch)
sha256sums=('62fd061d08a75492617e625a73e2c05e259f831acbb8e1f8b9c81f23f7993a3b'
'9054ae2ba34a12bcafa7659f9f21badbfa7aa6114657ed993818cd867ba698f4'
'dc7a6691f1a19c1b5c6765446d39838331126b29cad45594c100c73da737710c')
001-gmodule-lib-prefix.patch)
sha256sums=('f70bf76ebcc84e0705722f038be8e2f9a58d17e1a700810c635fcc18b8974b7e'
'31bce1aff2dab2262ea372d101081162a77e9310fe0d68400da8c85d698ce65e')
prepare() {
cd glib-${pkgver}
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/756
patch -p2 -i ${srcdir}/2.38.2-gconvert-cygwin.patch
# Unclear what this is about and why it's not upstream..
# Rebased from cygwin 2.50-gmodule-cygwin.patch
patch -p1 -i ${srcdir}/2.64-gmodule-cygwin-rebased.patch
patch -p1 -i ${srcdir}/001-gmodule-lib-prefix.patch
}
build() {
mkdir "${srcdir}"/build && cd "${srcdir}"/build
meson \
--wrap-mode=nodownload \
--auto-features=enabled \
--buildtype=plain \
--prefix=/usr \
-Dfam=true \
-Dgtk_doc=true \
-Dlibelf=disabled \
"../glib-${pkgver}"
meson compile