[Hackage] #853: Building mixed-language programs with Apple's Objective-C garbage-collection feature is difficult

Hackage cvs-ghc at haskell.org
Tue May 31 09:20:57 CEST 2011

#853: Building mixed-language programs with Apple's Objective-C garbage-
collection feature is difficult
  Reporter:  dankna         |        Owner:      
      Type:  enhancement    |       Status:  new 
  Priority:  normal         |    Milestone:      
 Component:  Cabal library  |      Version:  HEAD
  Severity:  normal         |     Keywords:      
Difficulty:  unknown        |   Ghcversion:      
  Platform:                 |  
 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.

Ticket URL: <http://hackage.haskell.org/trac/hackage/ticket/853>
Hackage <http://haskell.org/cabal/>
Hackage: Cabal and related projects

More information about the cabal-devel mailing list