Re: [gtk-osx-users] Universal ppc/i386 build
- From: Steffen Gutmann <muibase yahoo com>
- To: John Ralls <jralls ceridwen us>
- Cc: "gtk-osx-users-list gnome org" <gtk-osx-users-list gnome org>
- Subject: Re: [gtk-osx-users] Universal ppc/i386 build
- Date: Thu, 24 Jan 2013 09:24:38 -0800 (PST)
Hi John!
> But that's not the *real* problem. That problem is that configure writes a
> value to G_BYTE_ORDER in $PREFIX/lib/glib-2.0/glibconfig.h, there's only
> one, and that's used not only in glib itself (where separate runs of
> configure for each architecture will take care of the problem for that
> particular build) but in other dependent libraries. Setup_universal_build()
> tries to finesse that by building separate trees for each architecture, but I
> was never able to get it to work right and gave up. The correct fix would
> determine endianess at compile time rather than at configure time.
I have attached a new diff for glib. It's basically the same as the previous one but the __POWERPC__ and __i386__ defines have been replaced by __BIG_ENDIAN__ and __LITTLE_ENDIAN__ which seems more appropriate here.
It's very much okay that these defines are Apple-only. Note the 3 case if-then-elseif-else statement:
+#if defined(__BIG_ENDIAN__)
+ #define G_BYTE_ORDER G_BIG_ENDIAN
+#elif defined(__LITTLE_ENDIAN__)
+ #define G_BYTE_ORDER G_LITTLE_ENDIAN
+#else
+ #define G_BYTE_ORDER $g_byte_order
+#endif
Thus, if neither __BIG_ENDIAN__ not __LITTLE_ENDIAN__ is defined, we fall back to whatever the configure script finds as the endianess.
With that change the relevant part of the glibconfig.h file turns into:
...
#if defined(__BIG_ENDIAN__)
#define GINT16_TO_BE(val)((gint16) (val))
#define GUINT16_TO_BE(val)((guint16) (val))
#define GINT16_TO_LE(val)((gint16) GUINT16_SWAP_LE_BE (val))
#define GUINT16_TO_LE(val)(GUINT16_SWAP_LE_BE (val))
#elif defined(__LITTLE_ENDIAN__)
#define GINT16_TO_LE(val)((gint16) (val))
#define GUINT16_TO_LE(val)((guint16) (val))
#define GINT16_TO_BE(val)((gint16) GUINT16_SWAP_LE_BE (val))
#define GUINT16_TO_BE(val)(GUINT16_SWAP_LE_BE (val))
#else
#define GINT16_TO_LE(val)((gint16) (val))
#define GUINT16_TO_LE(val)((guint16) (val))
#define GINT16_TO_BE(val)((gint16) GUINT16_SWAP_LE_BE (val))
#define GUINT16_TO_BE(val)(GUINT16_SWAP_LE_BE (val))
#endif
#if defined(__BIG_ENDIAN__)
#define GINT32_TO_BE(val)((gint32) (val))
#define GUINT32_TO_BE(val)((guint32) (val))
#define GINT32_TO_LE(val)((gint32) GUINT32_SWAP_LE_BE (val))
#define GUINT32_TO_LE(val)(GUINT32_SWAP_LE_BE (val))
#elif defined(__LITTLE_ENDIAN__)
#define GINT32_TO_LE(val)((gint32) (val))
#define GUINT32_TO_LE(val)((guint32) (val))
#define GINT32_TO_BE(val)((gint32) GUINT32_SWAP_LE_BE (val))
#define GUINT32_TO_BE(val)(GUINT32_SWAP_LE_BE (val))
#else
#define GINT32_TO_LE(val)((gint32) (val))
#define GUINT32_TO_LE(val)((guint32) (val))
#define GINT32_TO_BE(val)((gint32) GUINT32_SWAP_LE_BE (val))
#define GUINT32_TO_BE(val)(GUINT32_SWAP_LE_BE (val))
#endif
#if defined(__BIG_ENDIAN__)
#define GINT64_TO_BE(val)((gint64) (val))
#define GUINT64_TO_BE(val)((guint64) (val))
#define GINT64_TO_LE(val)((gint64) GUINT64_SWAP_LE_BE (val))
#define GUINT64_TO_LE(val)(GUINT64_SWAP_LE_BE (val))
#elif defined(__LITTLE_ENDIAN__)
#define GINT64_TO_LE(val)((gint64) (val))
#define GUINT64_TO_LE(val)((guint64) (val))
#define GINT64_TO_BE(val)((gint64) GUINT64_SWAP_LE_BE (val))
#define GUINT64_TO_BE(val)(GUINT64_SWAP_LE_BE (val))
#else
#define GINT64_TO_LE(val)((gint64) (val))
#define GUINT64_TO_LE(val)((guint64) (val))
#define GINT64_TO_BE(val)((gint64) GUINT64_SWAP_LE_BE (val))
#define GUINT64_TO_BE(val)(GUINT64_SWAP_LE_BE (val))
#endif
#define GLONG_TO_LE(val)((glong) GINT32_TO_LE (val))
#define GULONG_TO_LE(val)((gulong) GUINT32_TO_LE (val))
#define GLONG_TO_BE(val)((glong) GINT32_TO_BE (val))
#define GULONG_TO_BE(val)((gulong) GUINT32_TO_BE (val))
#define GINT_TO_LE(val)((gint) GINT32_TO_LE (val))
#define GUINT_TO_LE(val)((guint) GUINT32_TO_LE (val))
#define GINT_TO_BE(val)((gint) GINT32_TO_BE (val))
#define GUINT_TO_BE(val)((guint) GUINT32_TO_BE (val))
#define GSIZE_TO_LE(val)((gsize) GUINT32_TO_LE (val))
#define GSSIZE_TO_LE(val)((gssize) GINT32_TO_LE (val))
#define GSIZE_TO_BE(val)((gsize) GUINT32_TO_BE (val))
#define GSSIZE_TO_BE(val)((gssize) GINT32_TO_BE (val))
#if defined(__BIG_ENDIAN__)
#define G_BYTE_ORDER G_BIG_ENDIAN
#elif defined(__LITTLE_ENDIAN__)
#define G_BYTE_ORDER G_LITTLE_ENDIAN
#else
#define G_BYTE_ORDER G_LITTLE_ENDIAN
#endif
...
Isn't that almost exactly what we want?
Other modules that build on top of glib will then naturally use the right endianess.
The only other case I found that needs special handling is libffi. But maybe there are more things to check. Do you know of any other problems that need specific handling for universal builds?
Best regards,
Steffen
Only in glib-2.34.1: config.h.in.orig
Only in glib-2.34.1: config.h.in.rej
diff -ru glib-2.34.1-orig/configure glib-2.34.1/configure
--- glib-2.34.1-orig/configure 2012-10-15 17:29:14.000000000 -0700
+++ glib-2.34.1/configure 2013-01-21 13:19:46.000000000 -0800
@@ -32598,10 +32598,22 @@
g_bit_sizes="16 32 64"
for bits in $g_bit_sizes; do
cat >>$outfile <<_______EOF
+#if defined(__BIG_ENDIAN__)
+#define GINT${bits}_TO_BE(val) ((gint${bits}) (val))
+#define GUINT${bits}_TO_BE(val) ((guint${bits}) (val))
+#define GINT${bits}_TO_LE(val) ((gint${bits}) GUINT${bits}_SWAP_LE_BE (val))
+#define GUINT${bits}_TO_LE(val) (GUINT${bits}_SWAP_LE_BE (val))
+#elif defined(__LITTLE_ENDIAN__)
+#define GINT${bits}_TO_LE(val) ((gint${bits}) (val))
+#define GUINT${bits}_TO_LE(val) ((guint${bits}) (val))
+#define GINT${bits}_TO_BE(val) ((gint${bits}) GUINT${bits}_SWAP_LE_BE (val))
+#define GUINT${bits}_TO_BE(val) (GUINT${bits}_SWAP_LE_BE (val))
+#else
#define GINT${bits}_TO_${g_bs_native}(val) ((gint${bits}) (val))
#define GUINT${bits}_TO_${g_bs_native}(val) ((guint${bits}) (val))
#define GINT${bits}_TO_${g_bs_alien}(val) ((gint${bits}) GUINT${bits}_SWAP_LE_BE (val))
#define GUINT${bits}_TO_${g_bs_alien}(val) (GUINT${bits}_SWAP_LE_BE (val))
+#endif
_______EOF
done
@@ -32618,7 +32630,13 @@
#define GSSIZE_TO_LE(val) ((gssize) GINT${gsizebits}_TO_LE (val))
#define GSIZE_TO_BE(val) ((gsize) GUINT${gsizebits}_TO_BE (val))
#define GSSIZE_TO_BE(val) ((gssize) GINT${gsizebits}_TO_BE (val))
-#define G_BYTE_ORDER $g_byte_order
+#if defined(__BIG_ENDIAN__)
+ #define G_BYTE_ORDER G_BIG_ENDIAN
+#elif defined(__LITTLE_ENDIAN__)
+ #define G_BYTE_ORDER G_LITTLE_ENDIAN
+#else
+ #define G_BYTE_ORDER $g_byte_order
+#endif
#define GLIB_SYSDEF_POLLIN =$g_pollin
#define GLIB_SYSDEF_POLLOUT =$g_pollout
diff -ru glib-2.34.1-orig/configure.ac glib-2.34.1/configure.ac
--- glib-2.34.1-orig/configure.ac 2012-10-15 17:28:53.000000000 -0700
+++ glib-2.34.1/configure.ac 2013-01-21 13:19:52.000000000 -0800
@@ -3061,10 +3061,22 @@
g_bit_sizes="16 32 64"
for bits in $g_bit_sizes; do
cat >>$outfile <<_______EOF
+#if defined(__BIG_ENDIAN__)
+#define GINT${bits}_TO_BE(val) ((gint${bits}) (val))
+#define GUINT${bits}_TO_BE(val) ((guint${bits}) (val))
+#define GINT${bits}_TO_LE(val) ((gint${bits}) GUINT${bits}_SWAP_LE_BE (val))
+#define GUINT${bits}_TO_LE(val) (GUINT${bits}_SWAP_LE_BE (val))
+#elif defined(__LITTLE_ENDIAN__)
+#define GINT${bits}_TO_LE(val) ((gint${bits}) (val))
+#define GUINT${bits}_TO_LE(val) ((guint${bits}) (val))
+#define GINT${bits}_TO_BE(val) ((gint${bits}) GUINT${bits}_SWAP_LE_BE (val))
+#define GUINT${bits}_TO_BE(val) (GUINT${bits}_SWAP_LE_BE (val))
+#else
#define GINT${bits}_TO_${g_bs_native}(val) ((gint${bits}) (val))
#define GUINT${bits}_TO_${g_bs_native}(val) ((guint${bits}) (val))
#define GINT${bits}_TO_${g_bs_alien}(val) ((gint${bits}) GUINT${bits}_SWAP_LE_BE (val))
#define GUINT${bits}_TO_${g_bs_alien}(val) (GUINT${bits}_SWAP_LE_BE (val))
+#endif
_______EOF
done
@@ -3081,7 +3093,13 @@
#define GSSIZE_TO_LE(val) ((gssize) GINT${gsizebits}_TO_LE (val))
#define GSIZE_TO_BE(val) ((gsize) GUINT${gsizebits}_TO_BE (val))
#define GSSIZE_TO_BE(val) ((gssize) GINT${gsizebits}_TO_BE (val))
-#define G_BYTE_ORDER $g_byte_order
+#if defined(__BIG_ENDIAN__)
+ #define G_BYTE_ORDER G_BIG_ENDIAN
+#elif defined(__LITTLE_ENDIAN__)
+ #define G_BYTE_ORDER G_LITTLE_ENDIAN
+#else
+ #define G_BYTE_ORDER $g_byte_order
+#endif
#define GLIB_SYSDEF_POLLIN =$g_pollin
#define GLIB_SYSDEF_POLLOUT =$g_pollout
Only in glib-2.34.1: configure.ac.orig
Only in glib-2.34.1: configure.orig
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]