glib: update and build dynamic library

This commit is contained in:
Jeremy Soller 2025-04-10 15:20:26 -06:00
parent 0df243b4cb
commit 505d492a94
No known key found for this signature in database
GPG Key ID: 670FDFB5428E05CA
2 changed files with 173 additions and 338 deletions

View File

@ -1,6 +1,6 @@
[source]
tar = "https://download.gnome.org/sources/glib/2.59/glib-2.59.0.tar.xz"
blake3 = "4b10f071bad767bbed9dc3ca742aac4de1f5746c03d515908e7dad4ea8334cbf"
tar = "https://download.gnome.org/sources/glib/2.82/glib-2.82.5.tar.xz"
blake3 = "9f5b4a12c6f328b167e81f457319f199acbaa02a63107d698ee9953193740b5f"
patches = [
"redox.patch"
]
@ -15,13 +15,54 @@ dependencies = [
"zlib",
]
script = """
"${COOKBOOK_SOURCE}/autogen.sh" \
"${COOKBOOK_CONFIGURE_FLAGS[@]}" \
glib_cv_stack_grows=no \
glib_cv_uscore=no
DYNAMIC_INIT
sed -i 's/#define HAVE_SYS_RESOURCE_H 1/#undef HAVE_SYS_RESOURCE_H/' config.h
#TODO: do this in cook instead
unset AR AS CC CXX LD NM OBJCOPY OBJDUMP RANLIB READELF STRIP
COOKBOOK_CONFIGURE="true"
cookbook_configure
#export CFLAGS="-I${COOKBOOK_SYSROOT}/include"
#export CPPFLAGS="-I${COOKBOOK_SYSROOT}/include"
#export LDFLAGS="-L${COOKBOOK_SYSROOT}/lib --static"
# TODO: Fix this annoying shite
echo "[binaries]" > cross_file.txt
echo "c = '${TARGET}-gcc'" >> cross_file.txt
echo "cpp = '${TARGET}-g++'" >> cross_file.txt
echo "ar = '${TARGET}-ar'" >> cross_file.txt
echo "strip = '${TARGET}-strip'" >> cross_file.txt
echo "pkg-config = '${TARGET}-pkg-config'" >> cross_file.txt
echo "[host_machine]" >> cross_file.txt
echo "system = 'redox'" >> cross_file.txt
echo "cpu_family = '$(echo "${TARGET}" | cut -d - -f1)'" >> cross_file.txt
echo "cpu = '$(echo "${TARGET}" | cut -d - -f1)'" >> cross_file.txt
echo "endian = 'little'" >> cross_file.txt
echo "[paths]" >> cross_file.txt
echo "prefix = '/usr'" >> cross_file.txt
echo "libdir = 'lib'" >> cross_file.txt
echo "bindir = 'bin'" >> cross_file.txt
echo "[properties]" >> cross_file.txt
echo "needs_exe_wrapper = true" >> cross_file.txt
meson \
setup \
"${COOKBOOK_SOURCE}" \
. \
--cross-file cross_file.txt \
--buildtype release \
--strip \
-Ddefault_library=shared \
-Dxattr=false
ninja -v
DESTDIR="${COOKBOOK_STAGE}" ninja install
"""
#TODO: shared deps
[package]
shared-deps = [
"libffi",
"libgcc",
"libiconv",
]

View File

@ -1,61 +1,7 @@
diff -ruwN source/configure.ac source-new/configure.ac
--- source/configure.ac 2018-12-23 08:10:41.000000000 -0500
+++ source-new/configure.ac 2024-11-28 00:42:10.691094238 -0500
@@ -981,7 +981,7 @@
[int qclass = C_IN;])],
[AC_MSG_RESULT([yes])
NAMESER_COMPAT_INCLUDE="#include <arpa/nameser_compat.h>"],
- [AC_MSG_ERROR([could not compile test program either way])])])])
+ [AC_MSG_WARN([could not compile test program either way])])])])
AC_SUBST(NAMESER_COMPAT_INCLUDE)
# We can't just use AC_CHECK_FUNC/AC_CHECK_LIB here. Bug 586150
@@ -1009,7 +1009,7 @@
[res_query("test", 0, 0, (void *)0, 0);],
[AC_MSG_RESULT([in -lbind])
NETWORK_LIBS="-lbind $NETWORK_LIBS"],
- [AC_MSG_ERROR(not found)])])
+ [AC_MSG_WARN(not found)])])
LIBS="$save_libs"])
AC_CHECK_FUNC(socket, :, AC_CHECK_LIB(socket, socket,
[NETWORK_LIBS="-lsocket $NETWORK_LIBS"],
diff -ruwN source/gio/glocalfileinfo.c source-new/gio/glocalfileinfo.c
--- source/gio/glocalfileinfo.c 2018-12-23 08:10:41.000000000 -0500
+++ source-new/gio/glocalfileinfo.c 2024-11-28 00:42:10.691094238 -0500
@@ -1217,11 +1217,13 @@
lookup_gid_name (gid_t gid)
{
char *name;
+#if !defined(__redox__)
#if defined (HAVE_GETGRGID_R)
char buffer[4096];
struct group gbuf;
#endif
struct group *gbufp;
+#endif
if (gid_cache == NULL)
gid_cache = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)g_free);
@@ -1231,6 +1233,7 @@
if (name)
return name;
+#if !defined(__redox__)
#if defined (HAVE_GETGRGID_R)
getgrgid_r (gid, &gbuf, buffer, sizeof(buffer), &gbufp);
#else
@@ -1242,6 +1245,7 @@
gbufp->gr_name[0] != 0)
name = convert_pwd_string_to_utf8 (gbufp->gr_name);
else
+#endif
name = g_strdup_printf("%d", (int)gid);
g_hash_table_replace (gid_cache, GINT_TO_POINTER (gid), name);
diff -ruwN source/gio/gnetworking.h.in source-new/gio/gnetworking.h.in
--- source/gio/gnetworking.h.in 2018-12-23 08:10:41.000000000 -0500
+++ source-new/gio/gnetworking.h.in 2024-11-28 01:04:12.972229810 -0500
@@ -41,13 +41,17 @@
diff -ruwN '--exclude=subprojects' glib-2.82.5/gio/gnetworking.h.in source/gio/gnetworking.h.in
--- glib-2.82.5/gio/gnetworking.h.in 2025-02-20 06:08:16.000000000 -0700
+++ source/gio/gnetworking.h.in 2025-04-10 14:12:46.307891418 -0600
@@ -40,13 +40,17 @@
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@ -72,302 +18,150 @@ diff -ruwN source/gio/gnetworking.h.in source-new/gio/gnetworking.h.in
+#endif
@NAMESER_COMPAT_INCLUDE@
#ifndef T_SRV
diff -ruwN source/gio/gsocket.c source-new/gio/gsocket.c
--- source/gio/gsocket.c 2018-12-23 08:10:41.000000000 -0500
+++ source-new/gio/gsocket.c 2024-11-28 00:42:10.691094238 -0500
@@ -1539,6 +1539,7 @@
g_return_val_if_fail (G_IS_SOCKET (socket), 0);
+#if !defined(__redox__)
if (socket->priv->family == G_SOCKET_FAMILY_IPV4)
{
g_socket_get_option (socket, IPPROTO_IP, IP_TTL,
@@ -1550,6 +1551,7 @@
&value, &error);
}
else
+#endif
g_return_val_if_reached (0);
if (error)
@@ -1580,6 +1582,7 @@
g_return_if_fail (G_IS_SOCKET (socket));
+#if !defined(__redox__)
if (socket->priv->family == G_SOCKET_FAMILY_IPV4)
{
g_socket_set_option (socket, IPPROTO_IP, IP_TTL,
@@ -1593,6 +1596,7 @@
ttl, &error);
}
else
+#endif
g_return_if_reached ();
if (error)
@@ -1688,6 +1692,7 @@
g_return_val_if_fail (G_IS_SOCKET (socket), FALSE);
+#if !defined(__redox__)
if (socket->priv->family == G_SOCKET_FAMILY_IPV4)
{
g_socket_get_option (socket, IPPROTO_IP, IP_MULTICAST_LOOP,
@@ -1699,6 +1704,7 @@
&value, &error);
}
else
+#endif
g_return_val_if_reached (FALSE);
if (error)
@@ -1733,6 +1739,7 @@
loopback = !!loopback;
+#if !defined(__redox__)
if (socket->priv->family == G_SOCKET_FAMILY_IPV4)
{
g_socket_set_option (socket, IPPROTO_IP, IP_MULTICAST_LOOP,
@@ -1746,6 +1753,7 @@
loopback, &error);
}
else
+#endif
g_return_if_reached ();
if (error)
@@ -1777,6 +1785,7 @@
g_return_val_if_fail (G_IS_SOCKET (socket), 0);
+#if !defined(__redox__)
if (socket->priv->family == G_SOCKET_FAMILY_IPV4)
{
g_socket_get_option (socket, IPPROTO_IP, IP_MULTICAST_TTL,
@@ -1788,6 +1797,7 @@
&value, &error);
}
else
+#endif
g_return_val_if_reached (FALSE);
if (error)
@@ -1819,6 +1829,7 @@
g_return_if_fail (G_IS_SOCKET (socket));
+#if !defined(__redox__)
if (socket->priv->family == G_SOCKET_FAMILY_IPV4)
{
g_socket_set_option (socket, IPPROTO_IP, IP_MULTICAST_TTL,
@@ -1832,6 +1843,7 @@
ttl, &error);
}
else
+#endif
g_return_if_reached ();
if (error)
@@ -2191,6 +2203,7 @@
return FALSE;
native_addr = g_inet_address_to_bytes (group);
+#if !defined(__redox__)
if (g_inet_address_get_family (group) == G_SOCKET_FAMILY_IPV4)
{
#ifdef HAVE_IP_MREQN
@@ -2252,6 +2265,7 @@
&mc_req_ipv6, sizeof (mc_req_ipv6));
}
else
+#endif
g_return_val_if_reached (FALSE);
if (result < 0)
@@ -2912,6 +2926,7 @@
if (!check_timeout (socket, error))
return FALSE;
+#if !defined(__redox__)
if (!g_socket_get_option (socket, SOL_SOCKET, SO_ERROR, &value, error))
{
g_prefix_error (error, _("Unable to get pending error: "));
@@ -2929,6 +2944,7 @@
}
return FALSE;
}
+#endif
socket->priv->connected_read = TRUE;
socket->priv->connected_write = TRUE;
@@ -3001,7 +3017,7 @@
{
#ifdef G_OS_WIN32
if (ioctlsocket (socket->priv->fd, FIONREAD, &avail) < 0)
-#else
+#elif !defined(__redox__)
if (ioctl (socket->priv->fd, FIONREAD, &avail) < 0)
#endif
avail = -1;
@@ -4316,7 +4332,7 @@
#endif
#ifndef __GI_SCANNER__
diff -ruwN '--exclude=subprojects' glib-2.82.5/gio/gthreadedresolver.c source/gio/gthreadedresolver.c
--- glib-2.82.5/gio/gthreadedresolver.c 2025-02-20 06:08:16.000000000 -0700
+++ source/gio/gthreadedresolver.c 2025-04-10 15:19:32.649611384 -0600
@@ -579,8 +579,26 @@
return g_task_propagate_pointer (G_TASK (result), error);
}
-#ifndef G_OS_WIN32
+#if !defined(G_OS_WIN32) && !defined(__redox__)
/* Unfortunately these have to be macros rather than inline functions due to
* using alloca(). */
@@ -4673,7 +4689,9 @@
vectors = &one_vector;
}
-#ifndef G_OS_WIN32
+#if defined(__redox__)
+ return -1;
+#elif !defined(G_OS_WIN32)
{
GOutputMessage output_message;
struct msghdr msg;
@@ -5138,7 +5156,9 @@
vectors = &one_vector;
}
-#ifndef G_OS_WIN32
+#if defined(__redox__)
+ return -1;
+#elif !defined(G_OS_WIN32)
{
GInputMessage input_message;
struct msghdr msg;
@@ -5910,4 +5930,3 @@
#endif
return FALSE;
}
-
diff -ruwN source/gio/gthreadedresolver.c source-new/gio/gthreadedresolver.c
--- source/gio/gthreadedresolver.c 2018-12-23 08:10:41.000000000 -0500
+++ source-new/gio/gthreadedresolver.c 2024-11-28 00:42:10.694427677 -0500
@@ -289,6 +289,12 @@
gpointer task_data,
GCancellable *cancellable)
{
+#if defined(__redox__)
+ g_task_return_new_error (task,
+ G_RESOLVER_ERROR,
+ G_RESOLVER_ERROR_INTERNAL,
+ _("do_lookup_by_address not implemented on Redox"));
+#else
GInetAddress *address = task_data;
struct sockaddr_storage sockaddr;
gsize sockaddr_size;
@@ -319,6 +325,7 @@
gai_strerror (retval));
g_free (phys);
}
+#endif
}
static gchar *
@@ -369,7 +376,7 @@
}
+gint
+g_resolver_record_type_to_rrtype (GResolverRecordType type)
+{
+ g_return_val_if_reached (-1);
+}
-#if defined(G_OS_UNIX)
+GList *
+g_resolver_records_from_res_query (const gchar *rrname,
+ gint rrtype,
+ const guint8 *answer,
+ gssize len,
+ gint herr,
+ GError **error)
+{
+ return NULL;
+}
+#endif
+
+#if defined(G_OS_UNIX) && !defined(__redox__)
#if defined __BIONIC__ && !defined BIND_4_COMPAT
/* Copy from bionic/libc/private/arpa_nameser_compat.h
@@ -920,6 +927,12 @@
gpointer task_data,
GCancellable *cancellable)
{
@@ -1308,7 +1326,10 @@
for (;;)
{
g_byte_array_set_size (answer, len * 2);
-#if defined(HAVE_RES_NQUERY)
+#if defined(__redox__)
+ g_task_return_new_error (task,
+ G_RESOLVER_ERROR,
+ G_RESOLVER_ERROR_INTERNAL,
+ _("do_lookup_records not implemented on Redox"));
+#else
LookupRecordsData *lrd = task_data;
GList *records;
GError *error = NULL;
@@ -1005,6 +1018,7 @@
g_task_return_pointer (task, records, (GDestroyNotify) free_records);
else
g_task_return_error (task, error);
+#endif
+ //TODO: implement on redox
+ len = -1;
+#elif defined(HAVE_RES_NQUERY)
len = res_nquery (&res, rrname, C_IN, rrtype, answer->data, answer->len);
#else
len = res_query (rrname, C_IN, rrtype, answer->data, answer->len);
diff -ruwN '--exclude=subprojects' glib-2.82.5/gio/gunixmounts.c source/gio/gunixmounts.c
--- glib-2.82.5/gio/gunixmounts.c 2025-02-20 06:08:16.000000000 -0700
+++ source/gio/gunixmounts.c 2025-04-10 14:57:29.342807607 -0600
@@ -1135,6 +1135,37 @@
return NULL;
}
static GList *
diff -ruwN source/gio/gunixfdmessage.c source-new/gio/gunixfdmessage.c
--- source/gio/gunixfdmessage.c 2018-12-23 08:10:41.000000000 -0500
+++ source-new/gio/gunixfdmessage.c 2024-11-28 00:42:10.694427677 -0500
@@ -53,6 +53,10 @@
#include "gnetworking.h"
#include "gioerror.h"
+#if defined(__redox__)
+#define SCM_RIGHTS 1
+#endif
+/* Redox OS {{{2 */
+#elif defined (__redox__)
+
struct _GUnixFDMessagePrivate
{
GUnixFDList *list;
diff -ruwN source/gio/gunixmounts.c source-new/gio/gunixmounts.c
--- source/gio/gunixmounts.c 2018-12-23 08:10:41.000000000 -0500
+++ source-new/gio/gunixmounts.c 2024-11-28 00:42:10.694427677 -0500
@@ -949,6 +949,21 @@
return return_list;
}
+/* Redox {{{2 */
+#elif defined(__redox__)
+
+static const char *
+static char *
+get_mtab_monitor_file (void)
+{
+ /* TODO: Not implemented */
+ return NULL;
+}
+
+static GUnixMountEntry **
+_g_unix_mounts_get_from_file (const char *table_path,
+ uint64_t *time_read_out,
+ size_t *n_entries_out)
+{
+ /* Not implemented, as per _g_get_unix_mounts() below */
+ if (time_read_out != NULL)
+ *time_read_out = 0;
+ if (n_entries_out != NULL)
+ *n_entries_out = 0;
+
+ return NULL;
+}
+
+static GList *
+_g_get_unix_mounts (void)
+{
+ /* TODO: Not implemented */
+ return NULL;
+}
+
/* Common code {{{2 */
#else
#error No _g_get_unix_mounts() implementation for system
@@ -1465,7 +1480,7 @@
return g_list_reverse (return_list);
}
/* Interix {{{2 */
-#elif defined(__INTERIX)
+#elif defined(__INTERIX) || defined(__redox__)
static GList *
_g_get_unix_mount_points (void)
{
diff -ruwN source/glib/gthread-posix.c source-new/glib/gthread-posix.c
--- source/glib/gthread-posix.c 2018-12-23 08:10:41.000000000 -0500
+++ source-new/glib/gthread-posix.c 2024-11-28 00:42:10.694427677 -0500
@@ -660,6 +660,7 @@
#elif defined (HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined (CLOCK_MONOTONIC)
if G_UNLIKELY ((status = pthread_condattr_setclock (&attr, CLOCK_MONOTONIC)) != 0)
g_thread_abort (status, "pthread_condattr_setclock");
@@ -1745,6 +1776,28 @@
if (time_read_out != NULL)
*time_read_out = 0;
if (n_points_out != NULL)
+ *n_points_out = 0;
+ return NULL;
+}
+
+#elif defined(__redox__)
#else
#error Cannot support GCond on your platform.
#endif
@@ -896,7 +897,7 @@
if ((status = pthread_cond_timedwait_relative_np (g_cond_get_impl (cond), g_mutex_get_impl (mutex), &ts)) == 0)
return TRUE;
}
-#elif defined (HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined (CLOCK_MONOTONIC)
+#elif (defined (HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined (CLOCK_MONOTONIC)) || defined(__redox__)
/* This is the exact check we used during init to set the clock to
* monotonic, so if we're in this branch, timedwait() will already be
* expecting a monotonic clock.
+
+static GList *
+_g_get_unix_mount_points (void)
+{
+ /* Not implemented */
+ return NULL;
+}
+
+static GUnixMountPoint **
+_g_unix_mount_points_get_from_file (const char *table_path,
+ uint64_t *time_read_out,
+ size_t *n_points_out)
+{
+ /* Not implemented */
+ if (time_read_out != NULL)
+ *time_read_out = 0;
+ if (n_points_out != NULL)
*n_points_out = 0;
return NULL;
}
diff -ruwN '--exclude=subprojects' glib-2.82.5/gio/meson.build source/gio/meson.build
--- glib-2.82.5/gio/meson.build 2025-02-20 06:08:16.000000000 -0700
+++ source/gio/meson.build 2025-04-10 14:06:57.909467382 -0600
@@ -18,7 +18,7 @@
gnetworking_h_nameser_compat_include = ''
-if host_system not in ['windows', 'android']
+if host_system not in ['windows', 'android', 'redox']
# Don't check for C_IN on Android since it does not define it in public
# headers, we define it ourselves wherever necessary
if not cc.compiles('''#include <sys/types.h>
@@ -39,7 +39,7 @@
network_libs = [ ]
network_args = [ ]
-if host_system != 'windows'
+if host_system not in ['windows', 'redox']
# res_query()
res_query_test = '''#include <resolv.h>
int main (int argc, char ** argv) {
diff -ruwN '--exclude=subprojects' glib-2.82.5/gio/xdgmime/xdgmimecache.c source/gio/xdgmime/xdgmimecache.c
--- glib-2.82.5/gio/xdgmime/xdgmimecache.c 2025-02-20 06:08:16.000000000 -0700
+++ source/gio/xdgmime/xdgmimecache.c 2025-04-10 14:11:44.020815595 -0600
@@ -22,7 +22,7 @@
#include <fnmatch.h>
#include <assert.h>
-#include <netinet/in.h> /* for ntohl/ntohs */
+#include <arpa/inet.h> /* for ntohl/ntohs */
#ifdef HAVE_MMAP
#include <sys/mman.h>