Merge branch 'trac_5025' of https://github.com/thoughtpolice/ghc
authorSimon Marlow <marlowsd@gmail.com>
Wed, 6 Apr 2011 13:30:59 +0000 (14:30 +0100)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 6 Apr 2011 13:30:59 +0000 (14:30 +0100)
* 'trac_5025' of https://github.com/thoughtpolice/ghc:
  Teach GHC to compile objective-c files; trac #5025

Conflicts:
compiler/main/DriverPipeline.hs

1  2 
compiler/main/DriverPhases.hs
compiler/main/DriverPipeline.hs

@@@ -75,7 -75,9 +75,8 @@@ data Phas
          | Hsc   HscSource
          | Ccpp
          | Cc
+         | Cobjc
          | HCc           -- Haskellised C (as opposed to vanilla C) compilation
 -        | Mangle        -- assembly mangling, now done by a separate script.
          | SplitMangle   -- after mangler if splitting
          | SplitAs
          | As
@@@ -110,7 -111,9 +111,8 @@@ eqPhase (HsPp  _)   (HsPp  _)   = Tru
  eqPhase (Hsc   _)   (Hsc   _)   = True
  eqPhase Ccpp        Ccpp        = True
  eqPhase Cc          Cc          = True
+ eqPhase Cobjc       Cobjc       = True
  eqPhase HCc         HCc         = True
 -eqPhase Mangle      Mangle      = True
  eqPhase SplitMangle SplitMangle = True
  eqPhase SplitAs     SplitAs     = True
  eqPhase As          As          = True
@@@ -147,13 -151,12 +149,14 @@@ nextPhase LlvmLlc       = LlvmMangl
  nextPhase LlvmLlc       = As
  #endif
  nextPhase LlvmMangle    = As
 -nextPhase SplitAs       = StopLn
 +nextPhase SplitAs       = MergeStub
  nextPhase Ccpp          = As
  nextPhase Cc            = As
+ nextPhase Cobjc         = As
  nextPhase CmmCpp        = Cmm
  nextPhase Cmm           = HCc
 +nextPhase HCc           = As
 +nextPhase MergeStub     = StopLn
  nextPhase StopLn        = panic "nextPhase: nothing after StopLn"
  
  -- the first compilation phase for a given file is determined
@@@ -170,8 -173,10 +173,9 @@@ startPhase "hc"       = HC
  startPhase "c"        = Cc
  startPhase "cpp"      = Ccpp
  startPhase "C"        = Cc
+ startPhase "m"        = Cobjc
  startPhase "cc"       = Ccpp
  startPhase "cxx"      = Ccpp
 -startPhase "raw_s"    = Mangle
  startPhase "split_s"  = SplitMangle
  startPhase "s"        = As
  startPhase "S"        = As
@@@ -198,7 -203,9 +202,8 @@@ phaseInputExt (Hsc   _)           = "hs
          --     output filename.  That could be fixed, but watch out.
  phaseInputExt HCc                 = "hc"
  phaseInputExt Ccpp                = "cpp"
+ phaseInputExt Cobjc               = "m"
  phaseInputExt Cc                  = "c"
 -phaseInputExt Mangle              = "raw_s"
  phaseInputExt SplitMangle         = "split_s"   -- not really generated
  phaseInputExt As                  = "s"
  phaseInputExt LlvmOpt             = "ll"
@@@ -985,9 -911,9 +985,9 @@@ runPhase Cmm input_fn dflag
  -- we don't support preprocessing .c files (with -E) now.  Doing so introduces
  -- way too many hacks, and I can't say I've ever used it anyway.
  
 -runPhase cc_phase _stop hsc_env _basename _suff input_fn get_output_fn maybe_loc
 +runPhase cc_phase input_fn dflags
-    | cc_phase `eqPhase` Cc || cc_phase `eqPhase` Ccpp || cc_phase `eqPhase` HCc
+    | cc_phase `eqPhase` Cc || cc_phase `eqPhase` Ccpp || cc_phase `eqPhase` HCc || cc_phase `eqPhase` Cobjc
 -   = do let dflags = hsc_dflags hsc_env
 +   = do
          let cc_opts = getOpts dflags opt_c
              hcc = cc_phase `eqPhase` HCc
  
                  -- very weakly typed, being derived from C--.
                  ["-fno-strict-aliasing"]
  
+         let gcc_lang_opt | cc_phase `eqPhase` Ccpp  = "c++"
+                          | cc_phase `eqPhase` Cobjc = "objective-c"
+                          | otherwise                = "c"
 -        SysTools.runCc dflags (
 +        io $ SysTools.runCc dflags (
                  -- force the C compiler to interpret this file as C when
                  -- compiling .hc files, by adding the -x c option.
                  -- Also useful for plain .c files, just in case GHC saw a