+doCpp :: DynFlags -> Bool -> Bool -> FilePath -> FilePath -> IO ()
+doCpp dflags raw include_cc_opts input_fn output_fn = do
+ let hscpp_opts = getOpts dflags opt_P
+
+ cmdline_include_paths <- readIORef v_Include_paths
+
+ pkg_include_dirs <- getPackageIncludePath dflags []
+ let include_paths = foldr (\ x xs -> "-I" : x : xs) []
+ (cmdline_include_paths ++ pkg_include_dirs)
+
+ let verb = getVerbFlag dflags
+
+ cc_opts <- if not include_cc_opts
+ then return []
+ else do let optc = getOpts dflags opt_c
+ (md_c_flags, _) <- machdepCCOpts dflags
+ return (optc ++ md_c_flags)
+
+ let cpp_prog args | raw = SysTools.runCpp dflags args
+ | otherwise = SysTools.runCc dflags (SysTools.Option "-E" : args)
+
+ let target_defs =
+ [ "-D" ++ HOST_OS ++ "BUILD_OS=1",
+ "-D" ++ HOST_ARCH ++ "BUILD_ARCH=1",
+ "-D" ++ TARGET_OS ++ "HOST_OS=1",
+ "-D" ++ TARGET_ARCH ++ "HOST_ARCH=1" ]
+ -- remember, in code we *compile*, the HOST is the same our TARGET,
+ -- and BUILD is the same as our HOST.
+
+ cpp_prog ([SysTools.Option verb]
+ ++ map SysTools.Option include_paths
+ ++ map SysTools.Option hsSourceCppOpts
+ ++ map SysTools.Option hscpp_opts
+ ++ map SysTools.Option cc_opts
+ ++ map SysTools.Option target_defs
+ ++ [ SysTools.Option "-x"
+ , SysTools.Option "c"
+ , SysTools.Option input_fn
+ -- We hackily use Option instead of FileOption here, so that the file
+ -- name is not back-slashed on Windows. cpp is capable of
+ -- dealing with / in filenames, so it works fine. Furthermore
+ -- if we put in backslashes, cpp outputs #line directives
+ -- with *double* backslashes. And that in turn means that
+ -- our error messages get double backslashes in them.
+ -- In due course we should arrange that the lexer deals
+ -- with these \\ escapes properly.
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" output_fn
+ ])
+
+-- -----------------------------------------------------------------------------
+-- Misc.
+
+hscNextPhase :: HscSource -> HscTarget -> IO Phase
+hscNextPhase HsBootFile hsc_lang
+ = return StopLn
+
+hscNextPhase other hsc_lang = do