summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wortmann <peter@grayson-heights-pc028-118.student-halls.leeds.ac.uk>2011-04-22 10:35:35 +0100
committerIan Lynagh <igloo@earth.li>2011-08-06 14:46:30 +0100
commite17c1568baf142c2d2ddca4a4b4a7ba5a4ceddca (patch)
tree55680b78d7b40c3029db1deef4e4a6c3c11a8cd1
parentda0493e48e089ce6fcb9675658ae17c35869207c (diff)
downloadhaskell-e17c1568baf142c2d2ddca4a4b4a7ba5a4ceddca.tar.gz
Teach GHC to compile objective-c++ files as well (trac #5150)
-rw-r--r--compiler/main/DriverPhases.hs8
-rw-r--r--compiler/main/DriverPipeline.hs3
-rw-r--r--ghc/Main.hs2
3 files changed, 10 insertions, 3 deletions
diff --git a/compiler/main/DriverPhases.hs b/compiler/main/DriverPhases.hs
index 4702682ee4..3cafd9814d 100644
--- a/compiler/main/DriverPhases.hs
+++ b/compiler/main/DriverPhases.hs
@@ -76,6 +76,7 @@ data Phase
| Ccpp
| Cc
| Cobjc
+ | Cobjcpp
| HCc -- Haskellised C (as opposed to vanilla C) compilation
| SplitMangle -- after mangler if splitting
| SplitAs
@@ -112,6 +113,7 @@ eqPhase (Hsc _) (Hsc _) = True
eqPhase Ccpp Ccpp = True
eqPhase Cc Cc = True
eqPhase Cobjc Cobjc = True
+eqPhase Cobjcpp Cobjcpp = True
eqPhase HCc HCc = True
eqPhase SplitMangle SplitMangle = True
eqPhase SplitAs SplitAs = True
@@ -149,6 +151,7 @@ nextPhase SplitAs = MergeStub
nextPhase Ccpp = As
nextPhase Cc = As
nextPhase Cobjc = As
+nextPhase Cobjcpp = As
nextPhase CmmCpp = Cmm
nextPhase Cmm = HCc
nextPhase HCc = As
@@ -170,6 +173,8 @@ startPhase "c" = Cc
startPhase "cpp" = Ccpp
startPhase "C" = Cc
startPhase "m" = Cobjc
+startPhase "M" = Cobjcpp
+startPhase "mm" = Cobjcpp
startPhase "cc" = Ccpp
startPhase "cxx" = Ccpp
startPhase "split_s" = SplitMangle
@@ -199,6 +204,7 @@ phaseInputExt (Hsc _) = "hspp" -- intermediate only
phaseInputExt HCc = "hc"
phaseInputExt Ccpp = "cpp"
phaseInputExt Cobjc = "m"
+phaseInputExt Cobjcpp = "mm"
phaseInputExt Cc = "c"
phaseInputExt SplitMangle = "split_s" -- not really generated
phaseInputExt As = "s"
@@ -217,7 +223,7 @@ haskellish_src_suffixes, haskellish_suffixes, cish_suffixes,
haskellish_src_suffixes = haskellish_user_src_suffixes ++
[ "hspp", "hscpp", "hcr", "cmm", "cmmcpp" ]
haskellish_suffixes = haskellish_src_suffixes ++ ["hc", "raw_s"]
-cish_suffixes = [ "c", "cpp", "C", "cc", "cxx", "s", "S", "ll", "bc", "m" ]
+cish_suffixes = [ "c", "cpp", "C", "cc", "cxx", "s", "S", "ll", "bc", "m", "M", "mm" ]
extcoreish_suffixes = [ "hcr" ]
-- Will not be deleted as temp files:
haskellish_user_src_suffixes = [ "hs", "lhs", "hs-boot", "lhs-boot" ]
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index ebd8d39a5a..fdb5ce316e 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1008,7 +1008,7 @@ runPhase Cmm input_fn dflags
-- way too many hacks, and I can't say I've ever used it anyway.
runPhase cc_phase input_fn dflags
- | cc_phase `eqPhase` Cc || cc_phase `eqPhase` Ccpp || cc_phase `eqPhase` HCc || cc_phase `eqPhase` Cobjc
+ | any (cc_phase `eqPhase`) [Cc, Ccpp, HCc, Cobjc, Cobjcpp]
= do
let cc_opts = getOpts dflags opt_c
hcc = cc_phase `eqPhase` HCc
@@ -1076,6 +1076,7 @@ runPhase cc_phase input_fn dflags
let gcc_lang_opt | cc_phase `eqPhase` Ccpp = "c++"
| cc_phase `eqPhase` Cobjc = "objective-c"
+ | cc_phase `eqPhase` Cobjcpp = "objective-c++"
| otherwise = "c"
io $ SysTools.runCc dflags (
-- force the C compiler to interpret this file as C when
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 8b7597cddf..0514fd2556 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -606,7 +606,7 @@ doMake srcs = do
haskellish (f,Nothing) =
looksLikeModuleName f || isHaskellSrcFilename f || '.' `notElem` f
haskellish (_,Just phase) =
- phase `notElem` [As, Cc, Cobjc, CmmCpp, Cmm, StopLn]
+ phase `notElem` [As, Cc, Cobjc, Cobjcpp, CmmCpp, Cmm, StopLn]
hsc_env <- GHC.getSession