(Imported from Trac #853, reported by @dankna on 2011-05-31)
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:
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:
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:
(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.
Since this ticket doesn't have any activity in the last few years, I propose closing. Please re-open or create a new ticket if this is something that is still desired.