Ticket #31221 (new defect)
glib2 ppc64 build "cannot make union transparent"
| Reported by: | ccorn@… | Owned by: | ryandesign@… |
|---|---|---|---|
| Priority: | Normal | Milestone: | |
| Component: | ports | Version: | 2.0.3 |
| Keywords: | ppc64 powerpc LP64 haspatch | Cc: | tascafoo@… |
| Port: | glib2 |
Description
Platform: PowerMac G5 running MacOS X 10.5.8 (Darwin 9)
Xcode version: 3.1.4 (providing gcc-4.0 and gcc-4.2, default is gcc-4.0)
Port: glib2 @2.28.8_0+universal (SVN -r81247)
universal_archs: ppc64 ppc
Problem: Universal build with Xcode 3.1.4's gcc-4.0 or gcc-4.2 fails with warnings like
gobject/gboxed.c:120: warning: union cannot be made transparent
and subsequent errors due to function call signature mismatches.
Using 64-bit only (-universal build_arch=ppc64) fails in the same manner.
Using 32-bit only (-universal build_arch=ppc) works.
Using configure.compiler=gcc-4.2 (default is gcc-4.0) does not make a difference.
Apparent cause: Issues with (Apple Xcode 3.1.4's) GCC-4.0 and GCC-4.2 with regard to transparent unions (cf. GCC type attributes) containing 64-bit pointers.
Proposed fix: The affected GCC versions should be fixed, and glib2 should probably adapt to the broken versions. Consequently, this is an upstream issue. However, for the time being, I propose a workaround for MacPorts using the attached patch.
Explanation: The offending glib2 source code uses the function macro G_DEFINE_BOXED_TYPE which itself indirectly uses G_DEFINE_BOXED_TYPE_BEGIN in gobject/gtypes.h. Depending on the GCC version, glib2 selects one of two implementations of this macro. Recent GCC versions are made to use transparent unions. The #else implementation of G_DEFINE_BOXED_TYPE_BEGIN is portable.
Patching gobject/gtypes.h to always use the portable implementation of G_DEFINE_BOXED_TYPE_BEGIN lets the universal build succeed. This is the workaround I propose.
Attachments
Change History
Changed 22 months ago by ccorn@…
- Attachment patch-gobject-gtype.h.diff added
comment:1 follow-up: ↓ 2 Changed 22 months ago by ryandesign@…
- Cc ryandesign@… removed
- Owner changed from macports-tickets@… to ryandesign@…
- Keywords ppc64 powerpc LP64 haspatch added; universal, union, 64-bit removed
- Summary changed from glib2 +universal (ppc64 ppc) build "cannot make union transparent" to glib2 ppc64 build "cannot make union transparent"
You should probably report this problem to the developers of glib2 instead of to me. It doesn't seem to be a MacPorts-specific issue.
Also, consider not building 64-bit on PowerPC computers. The only reason to build 64-bit on PowerPC computers would be if you need to access more than 4GB of memory from a single program.
If I were to apply this patch to the port, I assume I should apply it only on PowerPC systems? I do have a Power Mac I can test on, but it is not a G5, so I cannot build ppc64.
comment:2 in reply to: ↑ 1 Changed 21 months ago by ccorn@…
Replying to ryandesign@…:
If I were to apply this patch to the port, I assume I should apply it only on PowerPC systems?
Having no more facts to report, I leave that to your judgement.
I do not have an x86_64 machine with macports to test whether building for x86_64 reproduces the bug. I have tested only with PowerPC. The root cause seems to be an (Apple) GCC bug affecting a GCC-specific feature. I cannot safely predict further manifestations of such a bug. Therefore, restricting the patch to builds including ppc64 would be ok for me. Then the bug might or might not appear then when building for x86_64.
The patch simply switches to an upstream-provided alternative implementation of an internal glib2 macro. The alternative implementation uses less type checking due to the lack of (working) transparent unions. If both implementations worked, they would produce identical machine code. Therefore, applying the patch should be safe not just for PowerPC.
Changed 10 months ago by naesten@…
- Attachment patch-gobject-gtype.h.2.diff added
Updated patch for glib 2.32.4


Proposed workaround for the "transparent union" glib2 issue