Skip to content
Snippets Groups Projects
Commit 0a4c03a8 authored by David Himmelstrup's avatar David Himmelstrup
Browse files

Add a C++ phase. Fixes bug #800

parent 55b21ce8
No related branches found
No related tags found
No related merge requests found
......@@ -71,6 +71,7 @@ data Phase
| Cpp HscSource
| HsPp HscSource
| Hsc HscSource
| Ccpp
| Cc
| HCc -- Haskellised C (as opposed to vanilla C) compilation
| Mangle -- assembly mangling, now done by a separate script.
......@@ -99,6 +100,7 @@ eqPhase (Unlit _) (Unlit _) = True
eqPhase (Cpp _) (Cpp _) = True
eqPhase (HsPp _) (HsPp _) = True
eqPhase (Hsc _) (Hsc _) = True
eqPhase Ccpp Ccpp = True
eqPhase Cc Cc = True
eqPhase HCc HCc = True
eqPhase Mangle Mangle = True
......@@ -129,6 +131,7 @@ nextPhase Mangle = SplitMangle
nextPhase SplitMangle = As
nextPhase As = SplitAs
nextPhase SplitAs = StopLn
nextPhase Ccpp = As
nextPhase Cc = As
nextPhase CmmCpp = Cmm
nextPhase Cmm = HCc
......@@ -145,10 +148,10 @@ startPhase "hspp" = Hsc HsSrcFile
startPhase "hcr" = Hsc ExtCoreFile
startPhase "hc" = HCc
startPhase "c" = Cc
startPhase "cpp" = Cc
startPhase "cpp" = Ccpp
startPhase "C" = Cc
startPhase "cc" = Cc
startPhase "cxx" = Cc
startPhase "cc" = Ccpp
startPhase "cxx" = Ccpp
startPhase "raw_s" = Mangle
startPhase "split_s" = SplitMangle
startPhase "s" = As
......@@ -171,6 +174,7 @@ phaseInputExt (Hsc _) = "hspp" -- intermediate only
-- because runPipeline uses the StopBefore phase to pick the
-- output filename. That could be fixed, but watch out.
phaseInputExt HCc = "hc"
phaseInputExt Ccpp = "cpp"
phaseInputExt Cc = "c"
phaseInputExt Mangle = "raw_s"
phaseInputExt SplitMangle = "split_s" -- not really generated
......
......@@ -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.
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
hcc = cc_phase `eqPhase` HCc
......@@ -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.
-- Also useful for plain .c files, just in case GHC saw a
-- -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.Option "-o"
, SysTools.FileOption "" output_fn
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment