GNOME Bugzilla – Bug 647145
glib2 2.28.5 not compiling on Leopard ppc64
Last modified: 2013-09-19 12:41:47 UTC
Created attachment 185500 [details] glib2 debug build log I am using MacPorts to try and install glib2 on a PowerPC Mac running OS X 10.5.8 (Leopard) with the arch set as ppc64. Kernel version is: Darwin Power-Mac-G5.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh I am also running XCode 3.1.4. Debug build log attached.
oh, hey, a macppc compile problem that isn't my fault it looks like the version of gcc you have doesn't support the anonymous union syntax used by G_DEFINE_BOXED_TYPE in gobject/gtype.h. This means that either (a) the gcc version checks in that macro are wrong, and we're trying to use an anonymous union on a version of gcc that doesn't actually support them, or (b) gcc on that version of mac os is broken, and does not support all the same features as the upstream version with the same number did.
Ok, is there a test I can run to determine which of those possibilities might be true?
At the moment the version of gcc installed is: gcc --version powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493) There would seem to be much later versions available in the MacPorts tree: gcc40 @4.0.4 (lang) gcc41 @4.1.2 (lang) gcc42 @4.2.4 (lang) gcc43 @4.3.5 (lang) gcc44 @4.4.5 (lang) gcc45 @4.5.2 (lang) Would there be a version that is recommended to try and compile glib2 with other than the latest available. If not I'll try and get 4.5.x up and running and see how how goes.
*** Bug 652912 has been marked as a duplicate of this bug. ***
I can confirm that this is still an issue, as reported by a user of Tigerbrew here: https://github.com/mistydemeo/tigerbrew/issues/53 This issue occurs only when building for ppc64 (CFLAGS using `-arch ppc64` or `-mcpu=970 -m64`), with GCC 4.0.1 or 4.2. The same compilers can build glib correctly when building for 32-bit PPC arches.
Created attachment 245663 [details] [review] Patch for gobject _G_DEFINE_BOXED_TYPE_BEGIN on ppc64 It turns out that this issue is specifically an issue with 64-bit pointers in a transparent union on ppc64 in Apple's GCC; see Macports's ticket here: https://trac.macports.org/ticket/31221 No wonder tracking it down was tricky, given how highly specific it is. I've attached a proposed patch. Currently untested, but it should work by making ppc64 builds fall down to the generic case. I'll let you know if I can get a G5 user to try it.
Comment on attachment 245663 [details] [review] Patch for gobject _G_DEFINE_BOXED_TYPE_BEGIN on ppc64 >+#if !defined (__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) && !defined (__ppc64__)) that's not quite right; the "&& !defined (__ppc64__)" should go outside the GNUC version check. (As it is now, I assume it will generate a warning about mixing || and && without parentheses...) But glib gets compiled on non-OS X ppc64 architectures too, so this needs to check the OS in addition to the architecture. So #if !defined (__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !(defined (__WHATEVER_OS_X_DEFINES__) && defined (__ppc64__)) or so Also, can you submit the patch in "git format-patch" format? https://live.gnome.org/Git/Developers#Contributing_patches
Created attachment 255271 [details] [review] Patch to fix gobject compilation on OS X/ppc64 Sorry this fell off my radar. I've attached an amended patch via git format-patch.
It seems unlikely Apple's GCC will be fixed, so yeah, let's go with this patch. I also added a comment which links back to this bug. "git blame" tends to be hard to use for single lines.