Commit 0a4c03a8 authored by David Himmelstrup's avatar David Himmelstrup

Add a C++ phase. Fixes bug #800

parent 55b21ce8
...@@ -71,6 +71,7 @@ data Phase ...@@ -71,6 +71,7 @@ data Phase
| Cpp HscSource | Cpp HscSource
| HsPp HscSource | HsPp HscSource
| Hsc HscSource | Hsc HscSource
| Ccpp
| Cc | Cc
| HCc -- Haskellised C (as opposed to vanilla C) compilation | HCc -- Haskellised C (as opposed to vanilla C) compilation
| Mangle -- assembly mangling, now done by a separate script. | Mangle -- assembly mangling, now done by a separate script.
...@@ -99,6 +100,7 @@ eqPhase (Unlit _) (Unlit _) = True ...@@ -99,6 +100,7 @@ eqPhase (Unlit _) (Unlit _) = True
eqPhase (Cpp _) (Cpp _) = True eqPhase (Cpp _) (Cpp _) = True
eqPhase (HsPp _) (HsPp _) = True eqPhase (HsPp _) (HsPp _) = True
eqPhase (Hsc _) (Hsc _) = True eqPhase (Hsc _) (Hsc _) = True
eqPhase Ccpp Ccpp = True
eqPhase Cc Cc = True eqPhase Cc Cc = True
eqPhase HCc HCc = True eqPhase HCc HCc = True
eqPhase Mangle Mangle = True eqPhase Mangle Mangle = True
...@@ -129,6 +131,7 @@ nextPhase Mangle = SplitMangle ...@@ -129,6 +131,7 @@ nextPhase Mangle = SplitMangle
nextPhase SplitMangle = As nextPhase SplitMangle = As
nextPhase As = SplitAs nextPhase As = SplitAs
nextPhase SplitAs = StopLn nextPhase SplitAs = StopLn
nextPhase Ccpp = As
nextPhase Cc = As nextPhase Cc = As
nextPhase CmmCpp = Cmm nextPhase CmmCpp = Cmm
nextPhase Cmm = HCc nextPhase Cmm = HCc
...@@ -145,10 +148,10 @@ startPhase "hspp" = Hsc HsSrcFile ...@@ -145,10 +148,10 @@ startPhase "hspp" = Hsc HsSrcFile
startPhase "hcr" = Hsc ExtCoreFile startPhase "hcr" = Hsc ExtCoreFile
startPhase "hc" = HCc startPhase "hc" = HCc
startPhase "c" = Cc startPhase "c" = Cc
startPhase "cpp" = Cc startPhase "cpp" = Ccpp
startPhase "C" = Cc startPhase "C" = Cc
startPhase "cc" = Cc startPhase "cc" = Ccpp
startPhase "cxx" = Cc startPhase "cxx" = Ccpp
startPhase "raw_s" = Mangle startPhase "raw_s" = Mangle
startPhase "split_s" = SplitMangle startPhase "split_s" = SplitMangle
startPhase "s" = As startPhase "s" = As
...@@ -171,6 +174,7 @@ phaseInputExt (Hsc _) = "hspp" -- intermediate only ...@@ -171,6 +174,7 @@ phaseInputExt (Hsc _) = "hspp" -- intermediate only
-- because runPipeline uses the StopBefore phase to pick the -- because runPipeline uses the StopBefore phase to pick the
-- output filename. That could be fixed, but watch out. -- output filename. That could be fixed, but watch out.
phaseInputExt HCc = "hc" phaseInputExt HCc = "hc"
phaseInputExt Ccpp = "cpp"
phaseInputExt Cc = "c" phaseInputExt Cc = "c"
phaseInputExt Mangle = "raw_s" phaseInputExt Mangle = "raw_s"
phaseInputExt SplitMangle = "split_s" -- not really generated phaseInputExt SplitMangle = "split_s" -- not really generated
......
...@@ -789,7 +789,7 @@ runPhase Cmm stop dflags basename suff input_fn get_output_fn maybe_loc ...@@ -789,7 +789,7 @@ runPhase Cmm stop dflags basename suff input_fn get_output_fn maybe_loc
-- way too many hacks, and I can't say I've ever used it anyway. -- way too many hacks, and I can't say I've ever used it anyway.
runPhase cc_phase stop dflags basename suff input_fn get_output_fn maybe_loc runPhase cc_phase stop dflags basename suff input_fn get_output_fn maybe_loc
| cc_phase `eqPhase` Cc || cc_phase `eqPhase` HCc | cc_phase `eqPhase` Cc || cc_phase `eqPhase` Ccpp || cc_phase `eqPhase` HCc
= do let cc_opts = getOpts dflags opt_c = do let cc_opts = getOpts dflags opt_c
hcc = cc_phase `eqPhase` HCc hcc = cc_phase `eqPhase` HCc
...@@ -851,7 +851,8 @@ runPhase cc_phase stop dflags basename suff input_fn get_output_fn maybe_loc ...@@ -851,7 +851,8 @@ runPhase cc_phase stop dflags basename suff input_fn get_output_fn maybe_loc
-- compiling .hc files, by adding the -x c option. -- compiling .hc files, by adding the -x c option.
-- Also useful for plain .c files, just in case GHC saw a -- Also useful for plain .c files, just in case GHC saw a
-- -x c option. -- -x c option.
[ SysTools.Option "-x", SysTools.Option "c"] ++ [ SysTools.Option "-x", if cc_phase `eqPhase` Ccpp
then SysTools.Option "c++" else SysTools.Option "c"] ++
[ SysTools.FileOption "" input_fn [ SysTools.FileOption "" input_fn
, SysTools.Option "-o" , SysTools.Option "-o"
, SysTools.FileOption "" output_fn , SysTools.FileOption "" output_fn
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment