id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	difficulty	ghcversion	platform
853	Building mixed-language programs with Apple's Objective-C garbage-collection feature is difficult	dankna	dankna	"Ideally, there would be a single flag to set the ObjC garbage collection mode.  The three possibilities are, semantically, disabled, optional, and mandatory; I was experimenting with the mandatory mode, but there will be related issues with the others.

One might expect the following to work:

  ld-options: -fobjc-gc-only

In fact this will compile successfully but the linked object will have very subtle heap corruption due to the lack of a write barrier (which is implemented by gcc by hooking all field accessors, transparently to the developer).  Why yes, this /did/ take me a while to track down!  It is necessary to also add:

  cc-options:  -fobjc-gc-only

But once this is added, it is impossible to link any Haskell objects in, because they do not contain the magic flag which tells the linker they are GC-aware.  We therefore need:

  ghc-options: -optc-fobjc-gc-only

(I think this might force compilation via C when it wouldn't otherwise be used, which is of course undesirable, but I haven't looked into it.)

This is somewhat of an ugly situation, but fortuitously, it is simple to remedy - Cabal merely needs to understand what needs to be done and do it!

I propose to put the new field in BuildInfo, as it applies to both libraries and executables; to call it ""objc-gc:"", and to give it the values ""Disabled"", ""Optional"", and ""Mandatory"".  I expect to have a patch for this ready sometime tomorrow.
"	enhancement	assigned	normal		Cabal library	HEAD	normal				unknown		
