PageRenderTime 34ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/ghc-7.4.1/compiler/main/DriverPipeline.hs

#
Haskell | 2131 lines | 1313 code | 323 blank | 495 comment | 109 complexity | d773f56a28587051d85143bf956b21d5 MD5 | raw file
Possible License(s): LGPL-3.0, BSD-3-Clause, BSD-2-Clause

Large files files are truncated, but you can click here to view the full file

  1. {-# OPTIONS -fno-cse #-}
  2. {-# LANGUAGE NamedFieldPuns #-}
  3. -- -fno-cse is needed for GLOBAL_VAR's to behave properly
  4. -----------------------------------------------------------------------------
  5. --
  6. -- GHC Driver
  7. --
  8. -- (c) The University of Glasgow 2005
  9. --
  10. -----------------------------------------------------------------------------
  11. module DriverPipeline (
  12. -- Run a series of compilation steps in a pipeline, for a
  13. -- collection of source files.
  14. oneShot, compileFile,
  15. -- Interfaces for the batch-mode driver
  16. linkBinary,
  17. -- Interfaces for the compilation manager (interpreted/batch-mode)
  18. preprocess,
  19. compile, compile',
  20. link,
  21. ) where
  22. #include "HsVersions.h"
  23. import Packages
  24. import HeaderInfo
  25. import DriverPhases
  26. import SysTools
  27. import HscMain
  28. import Finder
  29. import HscTypes
  30. import Outputable
  31. import Module
  32. import UniqFM ( eltsUFM )
  33. import ErrUtils
  34. import DynFlags
  35. import StaticFlags ( v_Ld_inputs, opt_PIC, opt_Static, WayName(..) )
  36. import Config
  37. import Panic
  38. import Util
  39. import StringBuffer ( hGetStringBuffer )
  40. import BasicTypes ( SuccessFlag(..) )
  41. import Maybes ( expectJust )
  42. import ParserCoreUtils ( getCoreModuleName )
  43. import SrcLoc
  44. import FastString
  45. import LlvmCodeGen ( llvmFixupAsm )
  46. import MonadUtils
  47. import Platform
  48. import Exception
  49. import Data.IORef ( readIORef )
  50. import System.Directory
  51. import System.FilePath
  52. import System.IO
  53. import Control.Monad
  54. import Data.List ( isSuffixOf )
  55. import Data.Maybe
  56. import System.Environment
  57. import Data.Char
  58. -- ---------------------------------------------------------------------------
  59. -- Pre-process
  60. -- | Just preprocess a file, put the result in a temp. file (used by the
  61. -- compilation manager during the summary phase).
  62. --
  63. -- We return the augmented DynFlags, because they contain the result
  64. -- of slurping in the OPTIONS pragmas
  65. preprocess :: HscEnv
  66. -> (FilePath, Maybe Phase) -- ^ filename and starting phase
  67. -> IO (DynFlags, FilePath)
  68. preprocess hsc_env (filename, mb_phase) =
  69. ASSERT2(isJust mb_phase || isHaskellSrcFilename filename, text filename)
  70. runPipeline anyHsc hsc_env (filename, mb_phase)
  71. Nothing Temporary Nothing{-no ModLocation-} Nothing{-no stub-}
  72. -- ---------------------------------------------------------------------------
  73. -- | Compile
  74. --
  75. -- Compile a single module, under the control of the compilation manager.
  76. --
  77. -- This is the interface between the compilation manager and the
  78. -- compiler proper (hsc), where we deal with tedious details like
  79. -- reading the OPTIONS pragma from the source file, converting the
  80. -- C or assembly that GHC produces into an object file, and compiling
  81. -- FFI stub files.
  82. --
  83. -- NB. No old interface can also mean that the source has changed.
  84. compile :: HscEnv
  85. -> ModSummary -- ^ summary for module being compiled
  86. -> Int -- ^ module N ...
  87. -> Int -- ^ ... of M
  88. -> Maybe ModIface -- ^ old interface, if we have one
  89. -> Maybe Linkable -- ^ old linkable, if we have one
  90. -> SourceModified
  91. -> IO HomeModInfo -- ^ the complete HomeModInfo, if successful
  92. compile = compile' (hscCompileNothing, hscCompileInteractive, hscCompileBatch)
  93. compile' ::
  94. (Compiler (HscStatus, ModIface, ModDetails),
  95. Compiler (InteractiveStatus, ModIface, ModDetails),
  96. Compiler (HscStatus, ModIface, ModDetails))
  97. -> HscEnv
  98. -> ModSummary -- ^ summary for module being compiled
  99. -> Int -- ^ module N ...
  100. -> Int -- ^ ... of M
  101. -> Maybe ModIface -- ^ old interface, if we have one
  102. -> Maybe Linkable -- ^ old linkable, if we have one
  103. -> SourceModified
  104. -> IO HomeModInfo -- ^ the complete HomeModInfo, if successful
  105. compile' (nothingCompiler, interactiveCompiler, batchCompiler)
  106. hsc_env0 summary mod_index nmods mb_old_iface maybe_old_linkable
  107. source_modified0
  108. = do
  109. let dflags0 = ms_hspp_opts summary
  110. this_mod = ms_mod summary
  111. src_flavour = ms_hsc_src summary
  112. location = ms_location summary
  113. input_fn = expectJust "compile:hs" (ml_hs_file location)
  114. input_fnpp = ms_hspp_file summary
  115. debugTraceMsg dflags0 2 (text "compile: input file" <+> text input_fnpp)
  116. let basename = dropExtension input_fn
  117. -- We add the directory in which the .hs files resides) to the import path.
  118. -- This is needed when we try to compile the .hc file later, if it
  119. -- imports a _stub.h file that we created here.
  120. let current_dir = case takeDirectory basename of
  121. "" -> "." -- XXX Hack required for filepath-1.1 and earlier
  122. -- (GHC 6.12 and earlier)
  123. d -> d
  124. old_paths = includePaths dflags0
  125. dflags = dflags0 { includePaths = current_dir : old_paths }
  126. hsc_env = hsc_env0 {hsc_dflags = dflags}
  127. -- Figure out what lang we're generating
  128. let hsc_lang = hscTarget dflags
  129. -- ... and what the next phase should be
  130. let next_phase = hscPostBackendPhase dflags src_flavour hsc_lang
  131. -- ... and what file to generate the output into
  132. output_fn <- getOutputFilename next_phase
  133. Temporary basename dflags next_phase (Just location)
  134. let dflags' = dflags { hscTarget = hsc_lang,
  135. hscOutName = output_fn,
  136. extCoreName = basename ++ ".hcr" }
  137. let hsc_env' = hsc_env { hsc_dflags = dflags' }
  138. -- -fforce-recomp should also work with --make
  139. let force_recomp = dopt Opt_ForceRecomp dflags
  140. source_modified
  141. | force_recomp || isNothing maybe_old_linkable = SourceModified
  142. | otherwise = source_modified0
  143. object_filename = ml_obj_file location
  144. let handleBatch HscNoRecomp
  145. = ASSERT (isJust maybe_old_linkable)
  146. return maybe_old_linkable
  147. handleBatch (HscRecomp hasStub _)
  148. | isHsBoot src_flavour
  149. = do when (isObjectTarget hsc_lang) $ -- interpreted reaches here too
  150. liftIO $ touchObjectFile dflags' object_filename
  151. return maybe_old_linkable
  152. | otherwise
  153. = do (hs_unlinked, unlinked_time) <-
  154. case hsc_lang of
  155. HscNothing ->
  156. return ([], ms_hs_date summary)
  157. -- We're in --make mode: finish the compilation pipeline.
  158. _other -> do
  159. maybe_stub_o <- case hasStub of
  160. Nothing -> return Nothing
  161. Just stub_c -> do
  162. stub_o <- compileStub hsc_env' stub_c
  163. return (Just stub_o)
  164. _ <- runPipeline StopLn hsc_env' (output_fn,Nothing)
  165. (Just basename)
  166. Persistent
  167. (Just location)
  168. maybe_stub_o
  169. -- The object filename comes from the ModLocation
  170. o_time <- getModificationTime object_filename
  171. return ([DotO object_filename], o_time)
  172. let linkable = LM unlinked_time this_mod hs_unlinked
  173. return (Just linkable)
  174. handleInterpreted HscNoRecomp
  175. = ASSERT (isJust maybe_old_linkable)
  176. return maybe_old_linkable
  177. handleInterpreted (HscRecomp _hasStub Nothing)
  178. = ASSERT (isHsBoot src_flavour)
  179. return maybe_old_linkable
  180. handleInterpreted (HscRecomp hasStub (Just (comp_bc, modBreaks)))
  181. = do stub_o <- case hasStub of
  182. Nothing -> return []
  183. Just stub_c -> do
  184. stub_o <- compileStub hsc_env' stub_c
  185. return [DotO stub_o]
  186. let hs_unlinked = [BCOs comp_bc modBreaks]
  187. unlinked_time = ms_hs_date summary
  188. -- Why do we use the timestamp of the source file here,
  189. -- rather than the current time? This works better in
  190. -- the case where the local clock is out of sync
  191. -- with the filesystem's clock. It's just as accurate:
  192. -- if the source is modified, then the linkable will
  193. -- be out of date.
  194. let linkable = LM unlinked_time this_mod
  195. (hs_unlinked ++ stub_o)
  196. return (Just linkable)
  197. let -- runCompiler :: Compiler result -> (result -> Maybe Linkable)
  198. -- -> m HomeModInfo
  199. runCompiler compiler handle
  200. = do (result, iface, details)
  201. <- compiler hsc_env' summary source_modified mb_old_iface
  202. (Just (mod_index, nmods))
  203. linkable <- handle result
  204. return (HomeModInfo{ hm_details = details,
  205. hm_iface = iface,
  206. hm_linkable = linkable })
  207. -- run the compiler
  208. case hsc_lang of
  209. HscInterpreted -> runCompiler interactiveCompiler handleInterpreted
  210. HscNothing -> runCompiler nothingCompiler handleBatch
  211. _other -> runCompiler batchCompiler handleBatch
  212. -----------------------------------------------------------------------------
  213. -- stub .h and .c files (for foreign export support)
  214. -- The _stub.c file is derived from the haskell source file, possibly taking
  215. -- into account the -stubdir option.
  216. --
  217. -- The object file created by compiling the _stub.c file is put into a
  218. -- temporary file, which will be later combined with the main .o file
  219. -- (see the MergeStubs phase).
  220. compileStub :: HscEnv -> FilePath -> IO FilePath
  221. compileStub hsc_env stub_c = do
  222. (_, stub_o) <- runPipeline StopLn hsc_env (stub_c,Nothing) Nothing
  223. Temporary Nothing{-no ModLocation-} Nothing
  224. return stub_o
  225. -- ---------------------------------------------------------------------------
  226. -- Link
  227. link :: GhcLink -- interactive or batch
  228. -> DynFlags -- dynamic flags
  229. -> Bool -- attempt linking in batch mode?
  230. -> HomePackageTable -- what to link
  231. -> IO SuccessFlag
  232. -- For the moment, in the batch linker, we don't bother to tell doLink
  233. -- which packages to link -- it just tries all that are available.
  234. -- batch_attempt_linking should only be *looked at* in batch mode. It
  235. -- should only be True if the upsweep was successful and someone
  236. -- exports main, i.e., we have good reason to believe that linking
  237. -- will succeed.
  238. link LinkInMemory _ _ _
  239. = if cGhcWithInterpreter == "YES"
  240. then -- Not Linking...(demand linker will do the job)
  241. return Succeeded
  242. else panicBadLink LinkInMemory
  243. link NoLink _ _ _
  244. = return Succeeded
  245. link LinkBinary dflags batch_attempt_linking hpt
  246. = link' dflags batch_attempt_linking hpt
  247. link LinkDynLib dflags batch_attempt_linking hpt
  248. = link' dflags batch_attempt_linking hpt
  249. panicBadLink :: GhcLink -> a
  250. panicBadLink other = panic ("link: GHC not built to link this way: " ++
  251. show other)
  252. link' :: DynFlags -- dynamic flags
  253. -> Bool -- attempt linking in batch mode?
  254. -> HomePackageTable -- what to link
  255. -> IO SuccessFlag
  256. link' dflags batch_attempt_linking hpt
  257. | batch_attempt_linking
  258. = do
  259. let
  260. home_mod_infos = eltsUFM hpt
  261. -- the packages we depend on
  262. pkg_deps = concatMap (map fst . dep_pkgs . mi_deps . hm_iface) home_mod_infos
  263. -- the linkables to link
  264. linkables = map (expectJust "link".hm_linkable) home_mod_infos
  265. debugTraceMsg dflags 3 (text "link: linkables are ..." $$ vcat (map ppr linkables))
  266. -- check for the -no-link flag
  267. if isNoLink (ghcLink dflags)
  268. then do debugTraceMsg dflags 3 (text "link(batch): linking omitted (-c flag given).")
  269. return Succeeded
  270. else do
  271. let getOfiles (LM _ _ us) = map nameOfObject (filter isObject us)
  272. obj_files = concatMap getOfiles linkables
  273. exe_file = exeFileName dflags
  274. linking_needed <- linkingNeeded dflags linkables pkg_deps
  275. if not (dopt Opt_ForceRecomp dflags) && not linking_needed
  276. then do debugTraceMsg dflags 2 (text exe_file <+> ptext (sLit "is up to date, linking not required."))
  277. return Succeeded
  278. else do
  279. compilationProgressMsg dflags $ showSDoc $
  280. (ptext (sLit "Linking") <+> text exe_file <+> text "...")
  281. -- Don't showPass in Batch mode; doLink will do that for us.
  282. let link = case ghcLink dflags of
  283. LinkBinary -> linkBinary
  284. LinkDynLib -> linkDynLib
  285. other -> panicBadLink other
  286. link dflags obj_files pkg_deps
  287. debugTraceMsg dflags 3 (text "link: done")
  288. -- linkBinary only returns if it succeeds
  289. return Succeeded
  290. | otherwise
  291. = do debugTraceMsg dflags 3 (text "link(batch): upsweep (partially) failed OR" $$
  292. text " Main.main not exported; not linking.")
  293. return Succeeded
  294. linkingNeeded :: DynFlags -> [Linkable] -> [PackageId] -> IO Bool
  295. linkingNeeded dflags linkables pkg_deps = do
  296. -- if the modification time on the executable is later than the
  297. -- modification times on all of the objects and libraries, then omit
  298. -- linking (unless the -fforce-recomp flag was given).
  299. let exe_file = exeFileName dflags
  300. e_exe_time <- tryIO $ getModificationTime exe_file
  301. case e_exe_time of
  302. Left _ -> return True
  303. Right t -> do
  304. -- first check object files and extra_ld_inputs
  305. extra_ld_inputs <- readIORef v_Ld_inputs
  306. e_extra_times <- mapM (tryIO . getModificationTime) extra_ld_inputs
  307. let (errs,extra_times) = splitEithers e_extra_times
  308. let obj_times = map linkableTime linkables ++ extra_times
  309. if not (null errs) || any (t <) obj_times
  310. then return True
  311. else do
  312. -- next, check libraries. XXX this only checks Haskell libraries,
  313. -- not extra_libraries or -l things from the command line.
  314. let pkg_map = pkgIdMap (pkgState dflags)
  315. pkg_hslibs = [ (libraryDirs c, lib)
  316. | Just c <- map (lookupPackage pkg_map) pkg_deps,
  317. lib <- packageHsLibs dflags c ]
  318. pkg_libfiles <- mapM (uncurry findHSLib) pkg_hslibs
  319. if any isNothing pkg_libfiles then return True else do
  320. e_lib_times <- mapM (tryIO . getModificationTime)
  321. (catMaybes pkg_libfiles)
  322. let (lib_errs,lib_times) = splitEithers e_lib_times
  323. if not (null lib_errs) || any (t <) lib_times
  324. then return True
  325. else checkLinkInfo dflags pkg_deps exe_file
  326. -- Returns 'False' if it was, and we can avoid linking, because the
  327. -- previous binary was linked with "the same options".
  328. checkLinkInfo :: DynFlags -> [PackageId] -> FilePath -> IO Bool
  329. checkLinkInfo dflags pkg_deps exe_file
  330. | not (platformSupportsSavingLinkOpts (platformOS (targetPlatform dflags)))
  331. -- ToDo: Windows and OS X do not use the ELF binary format, so
  332. -- readelf does not work there. We need to find another way to do
  333. -- this.
  334. = return False -- conservatively we should return True, but not
  335. -- linking in this case was the behaviour for a long
  336. -- time so we leave it as-is.
  337. | otherwise
  338. = do
  339. link_info <- getLinkInfo dflags pkg_deps
  340. debugTraceMsg dflags 3 $ text ("Link info: " ++ link_info)
  341. m_exe_link_info <- readElfSection dflags ghcLinkInfoSectionName exe_file
  342. debugTraceMsg dflags 3 $ text ("Exe link info: " ++ show m_exe_link_info)
  343. return (Just link_info /= m_exe_link_info)
  344. platformSupportsSavingLinkOpts :: OS -> Bool
  345. platformSupportsSavingLinkOpts os
  346. | os == OSSolaris2 = False -- see #5382
  347. | otherwise = osElfTarget os
  348. ghcLinkInfoSectionName :: String
  349. ghcLinkInfoSectionName = ".debug-ghc-link-info"
  350. -- if we use the ".debug" prefix, then strip will strip it by default
  351. findHSLib :: [String] -> String -> IO (Maybe FilePath)
  352. findHSLib dirs lib = do
  353. let batch_lib_file = "lib" ++ lib <.> "a"
  354. found <- filterM doesFileExist (map (</> batch_lib_file) dirs)
  355. case found of
  356. [] -> return Nothing
  357. (x:_) -> return (Just x)
  358. -- -----------------------------------------------------------------------------
  359. -- Compile files in one-shot mode.
  360. oneShot :: HscEnv -> Phase -> [(String, Maybe Phase)] -> IO ()
  361. oneShot hsc_env stop_phase srcs = do
  362. o_files <- mapM (compileFile hsc_env stop_phase) srcs
  363. doLink (hsc_dflags hsc_env) stop_phase o_files
  364. compileFile :: HscEnv -> Phase -> (FilePath, Maybe Phase) -> IO FilePath
  365. compileFile hsc_env stop_phase (src, mb_phase) = do
  366. exists <- doesFileExist src
  367. when (not exists) $
  368. ghcError (CmdLineError ("does not exist: " ++ src))
  369. let
  370. dflags = hsc_dflags hsc_env
  371. split = dopt Opt_SplitObjs dflags
  372. mb_o_file = outputFile dflags
  373. ghc_link = ghcLink dflags -- Set by -c or -no-link
  374. -- When linking, the -o argument refers to the linker's output.
  375. -- otherwise, we use it as the name for the pipeline's output.
  376. output
  377. | StopLn <- stop_phase, not (isNoLink ghc_link) = Persistent
  378. -- -o foo applies to linker
  379. | Just o_file <- mb_o_file = SpecificFile o_file
  380. -- -o foo applies to the file we are compiling now
  381. | otherwise = Persistent
  382. stop_phase' = case stop_phase of
  383. As | split -> SplitAs
  384. _ -> stop_phase
  385. ( _, out_file) <- runPipeline stop_phase' hsc_env
  386. (src, mb_phase) Nothing output
  387. Nothing{-no ModLocation-} Nothing
  388. return out_file
  389. doLink :: DynFlags -> Phase -> [FilePath] -> IO ()
  390. doLink dflags stop_phase o_files
  391. | not (isStopLn stop_phase)
  392. = return () -- We stopped before the linking phase
  393. | otherwise
  394. = case ghcLink dflags of
  395. NoLink -> return ()
  396. LinkBinary -> linkBinary dflags o_files []
  397. LinkDynLib -> linkDynLib dflags o_files []
  398. other -> panicBadLink other
  399. -- ---------------------------------------------------------------------------
  400. data PipelineOutput
  401. = Temporary
  402. -- ^ Output should be to a temporary file: we're going to
  403. -- run more compilation steps on this output later.
  404. | Persistent
  405. -- ^ We want a persistent file, i.e. a file in the current directory
  406. -- derived from the input filename, but with the appropriate extension.
  407. -- eg. in "ghc -c Foo.hs" the output goes into ./Foo.o.
  408. | SpecificFile FilePath
  409. -- ^ The output must go into the specified file.
  410. -- | Run a compilation pipeline, consisting of multiple phases.
  411. --
  412. -- This is the interface to the compilation pipeline, which runs
  413. -- a series of compilation steps on a single source file, specifying
  414. -- at which stage to stop.
  415. --
  416. -- The DynFlags can be modified by phases in the pipeline (eg. by
  417. -- OPTIONS_GHC pragmas), and the changes affect later phases in the
  418. -- pipeline.
  419. runPipeline
  420. :: Phase -- ^ When to stop
  421. -> HscEnv -- ^ Compilation environment
  422. -> (FilePath,Maybe Phase) -- ^ Input filename (and maybe -x suffix)
  423. -> Maybe FilePath -- ^ original basename (if different from ^^^)
  424. -> PipelineOutput -- ^ Output filename
  425. -> Maybe ModLocation -- ^ A ModLocation, if this is a Haskell module
  426. -> Maybe FilePath -- ^ stub object, if we have one
  427. -> IO (DynFlags, FilePath) -- ^ (final flags, output filename)
  428. runPipeline stop_phase hsc_env0 (input_fn, mb_phase)
  429. mb_basename output maybe_loc maybe_stub_o
  430. = do
  431. let dflags0 = hsc_dflags hsc_env0
  432. (input_basename, suffix) = splitExtension input_fn
  433. suffix' = drop 1 suffix -- strip off the .
  434. basename | Just b <- mb_basename = b
  435. | otherwise = input_basename
  436. -- Decide where dump files should go based on the pipeline output
  437. dflags = dflags0 { dumpPrefix = Just (basename ++ ".") }
  438. hsc_env = hsc_env0 {hsc_dflags = dflags}
  439. -- If we were given a -x flag, then use that phase to start from
  440. start_phase = fromMaybe (startPhase suffix') mb_phase
  441. -- We want to catch cases of "you can't get there from here" before
  442. -- we start the pipeline, because otherwise it will just run off the
  443. -- end.
  444. --
  445. -- There is a partial ordering on phases, where A < B iff A occurs
  446. -- before B in a normal compilation pipeline.
  447. when (not (start_phase `happensBefore` stop_phase)) $
  448. ghcError (UsageError
  449. ("cannot compile this file to desired target: "
  450. ++ input_fn))
  451. -- this is a function which will be used to calculate output file names
  452. -- as we go along (we partially apply it to some of its inputs here)
  453. let get_output_fn = getOutputFilename stop_phase output basename
  454. -- Execute the pipeline...
  455. let env = PipeEnv{ stop_phase,
  456. src_basename = basename,
  457. src_suffix = suffix',
  458. output_spec = output }
  459. state = PipeState{ hsc_env, maybe_loc, maybe_stub_o = maybe_stub_o }
  460. (state', output_fn) <- unP (pipeLoop start_phase input_fn) env state
  461. let PipeState{ hsc_env=hsc_env', maybe_loc } = state'
  462. dflags' = hsc_dflags hsc_env'
  463. -- Sometimes, a compilation phase doesn't actually generate any output
  464. -- (eg. the CPP phase when -fcpp is not turned on). If we end on this
  465. -- stage, but we wanted to keep the output, then we have to explicitly
  466. -- copy the file, remembering to prepend a {-# LINE #-} pragma so that
  467. -- further compilation stages can tell what the original filename was.
  468. case output of
  469. Temporary ->
  470. return (dflags', output_fn)
  471. _other ->
  472. do final_fn <- get_output_fn dflags' stop_phase maybe_loc
  473. when (final_fn /= output_fn) $ do
  474. let msg = ("Copying `" ++ output_fn ++"' to `" ++ final_fn ++ "'")
  475. line_prag = Just ("{-# LINE 1 \"" ++ input_fn ++ "\" #-}\n")
  476. copyWithHeader dflags msg line_prag output_fn final_fn
  477. return (dflags', final_fn)
  478. -- -----------------------------------------------------------------------------
  479. -- The pipeline uses a monad to carry around various bits of information
  480. -- PipeEnv: invariant information passed down
  481. data PipeEnv = PipeEnv {
  482. stop_phase :: Phase, -- ^ Stop just before this phase
  483. src_basename :: String, -- ^ basename of original input source
  484. src_suffix :: String, -- ^ its extension
  485. output_spec :: PipelineOutput -- ^ says where to put the pipeline output
  486. }
  487. -- PipeState: information that might change during a pipeline run
  488. data PipeState = PipeState {
  489. hsc_env :: HscEnv,
  490. -- ^ only the DynFlags change in the HscEnv. The DynFlags change
  491. -- at various points, for example when we read the OPTIONS_GHC
  492. -- pragmas in the Cpp phase.
  493. maybe_loc :: Maybe ModLocation,
  494. -- ^ the ModLocation. This is discovered during compilation,
  495. -- in the Hsc phase where we read the module header.
  496. maybe_stub_o :: Maybe FilePath
  497. -- ^ the stub object. This is set by the Hsc phase if a stub
  498. -- object was created. The stub object will be joined with
  499. -- the main compilation object using "ld -r" at the end.
  500. }
  501. getPipeEnv :: CompPipeline PipeEnv
  502. getPipeEnv = P $ \env state -> return (state, env)
  503. getPipeState :: CompPipeline PipeState
  504. getPipeState = P $ \_env state -> return (state, state)
  505. getDynFlags :: CompPipeline DynFlags
  506. getDynFlags = P $ \_env state -> return (state, hsc_dflags (hsc_env state))
  507. setDynFlags :: DynFlags -> CompPipeline ()
  508. setDynFlags dflags = P $ \_env state ->
  509. return (state{hsc_env= (hsc_env state){ hsc_dflags = dflags }}, ())
  510. setModLocation :: ModLocation -> CompPipeline ()
  511. setModLocation loc = P $ \_env state ->
  512. return (state{ maybe_loc = Just loc }, ())
  513. setStubO :: FilePath -> CompPipeline ()
  514. setStubO stub_o = P $ \_env state ->
  515. return (state{ maybe_stub_o = Just stub_o }, ())
  516. newtype CompPipeline a = P { unP :: PipeEnv -> PipeState -> IO (PipeState, a) }
  517. instance Monad CompPipeline where
  518. return a = P $ \_env state -> return (state, a)
  519. P m >>= k = P $ \env state -> do (state',a) <- m env state
  520. unP (k a) env state'
  521. io :: IO a -> CompPipeline a
  522. io m = P $ \_env state -> do a <- m; return (state, a)
  523. phaseOutputFilename :: Phase{-next phase-} -> CompPipeline FilePath
  524. phaseOutputFilename next_phase = do
  525. PipeEnv{stop_phase, src_basename, output_spec} <- getPipeEnv
  526. PipeState{maybe_loc, hsc_env} <- getPipeState
  527. let dflags = hsc_dflags hsc_env
  528. io $ getOutputFilename stop_phase output_spec
  529. src_basename dflags next_phase maybe_loc
  530. -- ---------------------------------------------------------------------------
  531. -- outer pipeline loop
  532. -- | pipeLoop runs phases until we reach the stop phase
  533. pipeLoop :: Phase -> FilePath -> CompPipeline FilePath
  534. pipeLoop phase input_fn = do
  535. PipeEnv{stop_phase} <- getPipeEnv
  536. PipeState{hsc_env} <- getPipeState
  537. case () of
  538. _ | phase `eqPhase` stop_phase -- All done
  539. -> return input_fn
  540. | not (phase `happensBefore` stop_phase)
  541. -- Something has gone wrong. We'll try to cover all the cases when
  542. -- this could happen, so if we reach here it is a panic.
  543. -- eg. it might happen if the -C flag is used on a source file that
  544. -- has {-# OPTIONS -fasm #-}.
  545. -> panic ("pipeLoop: at phase " ++ show phase ++
  546. " but I wanted to stop at phase " ++ show stop_phase)
  547. | otherwise
  548. -> do io $ debugTraceMsg (hsc_dflags hsc_env) 4
  549. (ptext (sLit "Running phase") <+> ppr phase)
  550. dflags <- getDynFlags
  551. (next_phase, output_fn) <- runPhase phase input_fn dflags
  552. pipeLoop next_phase output_fn
  553. -- -----------------------------------------------------------------------------
  554. -- In each phase, we need to know into what filename to generate the
  555. -- output. All the logic about which filenames we generate output
  556. -- into is embodied in the following function.
  557. getOutputFilename
  558. :: Phase -> PipelineOutput -> String
  559. -> DynFlags -> Phase{-next phase-} -> Maybe ModLocation -> IO FilePath
  560. getOutputFilename stop_phase output basename
  561. = func
  562. where
  563. func dflags next_phase maybe_location
  564. | is_last_phase, Persistent <- output = persistent_fn
  565. | is_last_phase, SpecificFile f <- output = return f
  566. | keep_this_output = persistent_fn
  567. | otherwise = newTempName dflags suffix
  568. where
  569. hcsuf = hcSuf dflags
  570. odir = objectDir dflags
  571. osuf = objectSuf dflags
  572. keep_hc = dopt Opt_KeepHcFiles dflags
  573. keep_s = dopt Opt_KeepSFiles dflags
  574. keep_bc = dopt Opt_KeepLlvmFiles dflags
  575. myPhaseInputExt HCc = hcsuf
  576. myPhaseInputExt MergeStub = osuf
  577. myPhaseInputExt StopLn = osuf
  578. myPhaseInputExt other = phaseInputExt other
  579. is_last_phase = next_phase `eqPhase` stop_phase
  580. -- sometimes, we keep output from intermediate stages
  581. keep_this_output =
  582. case next_phase of
  583. As | keep_s -> True
  584. LlvmOpt | keep_bc -> True
  585. HCc | keep_hc -> True
  586. _other -> False
  587. suffix = myPhaseInputExt next_phase
  588. -- persistent object files get put in odir
  589. persistent_fn
  590. | StopLn <- next_phase = return odir_persistent
  591. | otherwise = return persistent
  592. persistent = basename <.> suffix
  593. odir_persistent
  594. | Just loc <- maybe_location = ml_obj_file loc
  595. | Just d <- odir = d </> persistent
  596. | otherwise = persistent
  597. -- -----------------------------------------------------------------------------
  598. -- | Each phase in the pipeline returns the next phase to execute, and the
  599. -- name of the file in which the output was placed.
  600. --
  601. -- We must do things dynamically this way, because we often don't know
  602. -- what the rest of the phases will be until part-way through the
  603. -- compilation: for example, an {-# OPTIONS -fasm #-} at the beginning
  604. -- of a source file can change the latter stages of the pipeline from
  605. -- taking the via-C route to using the native code generator.
  606. --
  607. runPhase :: Phase -- ^ Run this phase
  608. -> FilePath -- ^ name of the input file
  609. -> DynFlags -- ^ for convenience, we pass the current dflags in
  610. -> CompPipeline (Phase, -- next phase to run
  611. FilePath) -- output filename
  612. -- Invariant: the output filename always contains the output
  613. -- Interesting case: Hsc when there is no recompilation to do
  614. -- Then the output filename is still a .o file
  615. -------------------------------------------------------------------------------
  616. -- Unlit phase
  617. runPhase (Unlit sf) input_fn dflags
  618. = do
  619. output_fn <- phaseOutputFilename (Cpp sf)
  620. let unlit_flags = getOpts dflags opt_L
  621. flags = map SysTools.Option unlit_flags ++
  622. [ -- The -h option passes the file name for unlit to
  623. -- put in a #line directive
  624. SysTools.Option "-h"
  625. , SysTools.Option $ escape $ normalise input_fn
  626. , SysTools.FileOption "" input_fn
  627. , SysTools.FileOption "" output_fn
  628. ]
  629. io $ SysTools.runUnlit dflags flags
  630. return (Cpp sf, output_fn)
  631. where
  632. -- escape the characters \, ", and ', but don't try to escape
  633. -- Unicode or anything else (so we don't use Util.charToC
  634. -- here). If we get this wrong, then in
  635. -- Coverage.addTicksToBinds where we check that the filename in
  636. -- a SrcLoc is the same as the source filenaame, the two will
  637. -- look bogusly different. See test:
  638. -- libraries/hpc/tests/function/subdir/tough2.lhs
  639. escape ('\\':cs) = '\\':'\\': escape cs
  640. escape ('\"':cs) = '\\':'\"': escape cs
  641. escape ('\'':cs) = '\\':'\'': escape cs
  642. escape (c:cs) = c : escape cs
  643. escape [] = []
  644. -------------------------------------------------------------------------------
  645. -- Cpp phase : (a) gets OPTIONS out of file
  646. -- (b) runs cpp if necessary
  647. runPhase (Cpp sf) input_fn dflags0
  648. = do
  649. src_opts <- io $ getOptionsFromFile dflags0 input_fn
  650. (dflags1, unhandled_flags, warns)
  651. <- io $ parseDynamicFilePragma dflags0 src_opts
  652. setDynFlags dflags1
  653. io $ checkProcessArgsResult unhandled_flags
  654. if not (xopt Opt_Cpp dflags1) then do
  655. -- we have to be careful to emit warnings only once.
  656. unless (dopt Opt_Pp dflags1) $ io $ handleFlagWarnings dflags1 warns
  657. -- no need to preprocess CPP, just pass input file along
  658. -- to the next phase of the pipeline.
  659. return (HsPp sf, input_fn)
  660. else do
  661. output_fn <- phaseOutputFilename (HsPp sf)
  662. io $ doCpp dflags1 True{-raw-} False{-no CC opts-} input_fn output_fn
  663. -- re-read the pragmas now that we've preprocessed the file
  664. -- See #2464,#3457
  665. src_opts <- io $ getOptionsFromFile dflags0 output_fn
  666. (dflags2, unhandled_flags, warns)
  667. <- io $ parseDynamicFilePragma dflags0 src_opts
  668. io $ checkProcessArgsResult unhandled_flags
  669. unless (dopt Opt_Pp dflags2) $ io $ handleFlagWarnings dflags2 warns
  670. -- the HsPp pass below will emit warnings
  671. setDynFlags dflags2
  672. return (HsPp sf, output_fn)
  673. -------------------------------------------------------------------------------
  674. -- HsPp phase
  675. runPhase (HsPp sf) input_fn dflags
  676. = do
  677. if not (dopt Opt_Pp dflags) then
  678. -- no need to preprocess, just pass input file along
  679. -- to the next phase of the pipeline.
  680. return (Hsc sf, input_fn)
  681. else do
  682. let hspp_opts = getOpts dflags opt_F
  683. PipeEnv{src_basename, src_suffix} <- getPipeEnv
  684. let orig_fn = src_basename <.> src_suffix
  685. output_fn <- phaseOutputFilename (Hsc sf)
  686. io $ SysTools.runPp dflags
  687. ( [ SysTools.Option orig_fn
  688. , SysTools.Option input_fn
  689. , SysTools.FileOption "" output_fn
  690. ] ++
  691. map SysTools.Option hspp_opts
  692. )
  693. -- re-read pragmas now that we've parsed the file (see #3674)
  694. src_opts <- io $ getOptionsFromFile dflags output_fn
  695. (dflags1, unhandled_flags, warns)
  696. <- io $ parseDynamicFilePragma dflags src_opts
  697. setDynFlags dflags1
  698. io $ checkProcessArgsResult unhandled_flags
  699. io $ handleFlagWarnings dflags1 warns
  700. return (Hsc sf, output_fn)
  701. -----------------------------------------------------------------------------
  702. -- Hsc phase
  703. -- Compilation of a single module, in "legacy" mode (_not_ under
  704. -- the direction of the compilation manager).
  705. runPhase (Hsc src_flavour) input_fn dflags0
  706. = do -- normal Hsc mode, not mkdependHS
  707. PipeEnv{ stop_phase=stop,
  708. src_basename=basename,
  709. src_suffix=suff } <- getPipeEnv
  710. -- we add the current directory (i.e. the directory in which
  711. -- the .hs files resides) to the include path, since this is
  712. -- what gcc does, and it's probably what you want.
  713. let current_dir = case takeDirectory basename of
  714. "" -> "." -- XXX Hack required for filepath-1.1 and earlier
  715. -- (GHC 6.12 and earlier)
  716. d -> d
  717. paths = includePaths dflags0
  718. dflags = dflags0 { includePaths = current_dir : paths }
  719. setDynFlags dflags
  720. -- gather the imports and module name
  721. (hspp_buf,mod_name,imps,src_imps) <- io $
  722. case src_flavour of
  723. ExtCoreFile -> do -- no explicit imports in ExtCore input.
  724. m <- getCoreModuleName input_fn
  725. return (Nothing, mkModuleName m, [], [])
  726. _ -> do
  727. buf <- hGetStringBuffer input_fn
  728. (src_imps,imps,L _ mod_name) <- getImports dflags buf input_fn (basename <.> suff)
  729. return (Just buf, mod_name, imps, src_imps)
  730. -- Build a ModLocation to pass to hscMain.
  731. -- The source filename is rather irrelevant by now, but it's used
  732. -- by hscMain for messages. hscMain also needs
  733. -- the .hi and .o filenames, and this is as good a way
  734. -- as any to generate them, and better than most. (e.g. takes
  735. -- into accout the -osuf flags)
  736. location1 <- io $ mkHomeModLocation2 dflags mod_name basename suff
  737. -- Boot-ify it if necessary
  738. let location2 | isHsBoot src_flavour = addBootSuffixLocn location1
  739. | otherwise = location1
  740. -- Take -ohi into account if present
  741. -- This can't be done in mkHomeModuleLocation because
  742. -- it only applies to the module being compiles
  743. let ohi = outputHi dflags
  744. location3 | Just fn <- ohi = location2{ ml_hi_file = fn }
  745. | otherwise = location2
  746. -- Take -o into account if present
  747. -- Very like -ohi, but we must *only* do this if we aren't linking
  748. -- (If we're linking then the -o applies to the linked thing, not to
  749. -- the object file for one module.)
  750. -- Note the nasty duplication with the same computation in compileFile above
  751. let expl_o_file = outputFile dflags
  752. location4 | Just ofile <- expl_o_file
  753. , isNoLink (ghcLink dflags)
  754. = location3 { ml_obj_file = ofile }
  755. | otherwise = location3
  756. o_file = ml_obj_file location4 -- The real object file
  757. setModLocation location4
  758. -- Figure out if the source has changed, for recompilation avoidance.
  759. --
  760. -- Setting source_unchanged to True means that M.o seems
  761. -- to be up to date wrt M.hs; so no need to recompile unless imports have
  762. -- changed (which the compiler itself figures out).
  763. -- Setting source_unchanged to False tells the compiler that M.o is out of
  764. -- date wrt M.hs (or M.o doesn't exist) so we must recompile regardless.
  765. src_timestamp <- io $ getModificationTime (basename <.> suff)
  766. let hsc_lang = hscTarget dflags
  767. source_unchanged <- io $
  768. if not (isStopLn stop)
  769. -- SourceModified unconditionally if
  770. -- (a) recompilation checker is off, or
  771. -- (b) we aren't going all the way to .o file (e.g. ghc -S)
  772. then return SourceModified
  773. -- Otherwise look at file modification dates
  774. else do o_file_exists <- doesFileExist o_file
  775. if not o_file_exists
  776. then return SourceModified -- Need to recompile
  777. else do t2 <- getModificationTime o_file
  778. if t2 > src_timestamp
  779. then return SourceUnmodified
  780. else return SourceModified
  781. -- get the DynFlags
  782. let next_phase = hscPostBackendPhase dflags src_flavour hsc_lang
  783. output_fn <- phaseOutputFilename next_phase
  784. let dflags' = dflags { hscTarget = hsc_lang,
  785. hscOutName = output_fn,
  786. extCoreName = basename ++ ".hcr" }
  787. setDynFlags dflags'
  788. PipeState{hsc_env=hsc_env'} <- getPipeState
  789. -- Tell the finder cache about this module
  790. mod <- io $ addHomeModuleToFinder hsc_env' mod_name location4
  791. -- Make the ModSummary to hand to hscMain
  792. let
  793. mod_summary = ModSummary { ms_mod = mod,
  794. ms_hsc_src = src_flavour,
  795. ms_hspp_file = input_fn,
  796. ms_hspp_opts = dflags,
  797. ms_hspp_buf = hspp_buf,
  798. ms_location = location4,
  799. ms_hs_date = src_timestamp,
  800. ms_obj_date = Nothing,
  801. ms_textual_imps = imps,
  802. ms_srcimps = src_imps }
  803. -- run the compiler!
  804. result <- io $ hscCompileOneShot hsc_env'
  805. mod_summary source_unchanged
  806. Nothing -- No iface
  807. Nothing -- No "module i of n" progress info
  808. case result of
  809. HscNoRecomp
  810. -> do io $ touchObjectFile dflags' o_file
  811. -- The .o file must have a later modification date
  812. -- than the source file (else we wouldn't be in HscNoRecomp)
  813. -- but we touch it anyway, to keep 'make' happy (we think).
  814. return (StopLn, o_file)
  815. (HscRecomp hasStub _)
  816. -> do case hasStub of
  817. Nothing -> return ()
  818. Just stub_c ->
  819. do stub_o <- io $ compileStub hsc_env' stub_c
  820. setStubO stub_o
  821. -- In the case of hs-boot files, generate a dummy .o-boot
  822. -- stamp file for the benefit of Make
  823. when (isHsBoot src_flavour) $
  824. io $ touchObjectFile dflags' o_file
  825. return (next_phase, output_fn)
  826. -----------------------------------------------------------------------------
  827. -- Cmm phase
  828. runPhase CmmCpp input_fn dflags
  829. = do
  830. output_fn <- phaseOutputFilename Cmm
  831. io $ doCpp dflags False{-not raw-} True{-include CC opts-}
  832. input_fn output_fn
  833. return (Cmm, output_fn)
  834. runPhase Cmm input_fn dflags
  835. = do
  836. PipeEnv{src_basename} <- getPipeEnv
  837. let hsc_lang = hscTarget dflags
  838. let next_phase = hscPostBackendPhase dflags HsSrcFile hsc_lang
  839. output_fn <- phaseOutputFilename next_phase
  840. let dflags' = dflags { hscTarget = hsc_lang,
  841. hscOutName = output_fn,
  842. extCoreName = src_basename ++ ".hcr" }
  843. setDynFlags dflags'
  844. PipeState{hsc_env} <- getPipeState
  845. io $ hscCompileCmmFile hsc_env input_fn
  846. return (next_phase, output_fn)
  847. -----------------------------------------------------------------------------
  848. -- Cc phase
  849. -- we don't support preprocessing .c files (with -E) now. Doing so introduces
  850. -- way too many hacks, and I can't say I've ever used it anyway.
  851. runPhase cc_phase input_fn dflags
  852. | any (cc_phase `eqPhase`) [Cc, Ccpp, HCc, Cobjc, Cobjcpp]
  853. = do
  854. let platform = targetPlatform dflags
  855. cc_opts = getOpts dflags opt_c
  856. hcc = cc_phase `eqPhase` HCc
  857. let cmdline_include_paths = includePaths dflags
  858. -- HC files have the dependent packages stamped into them
  859. pkgs <- if hcc then io $ getHCFilePackages input_fn else return []
  860. -- add package include paths even if we're just compiling .c
  861. -- files; this is the Value Add(TM) that using ghc instead of
  862. -- gcc gives you :)
  863. pkg_include_dirs <- io $ getPackageIncludePath dflags pkgs
  864. let include_paths = foldr (\ x xs -> "-I" : x : xs) []
  865. (cmdline_include_paths ++ pkg_include_dirs)
  866. let gcc_extra_viac_flags = extraGccViaCFlags dflags
  867. let pic_c_flags = picCCOpts dflags
  868. let verbFlags = getVerbFlags dflags
  869. -- cc-options are not passed when compiling .hc files. Our
  870. -- hc code doesn't not #include any header files anyway, so these
  871. -- options aren't necessary.
  872. pkg_extra_cc_opts <- io $
  873. if cc_phase `eqPhase` HCc
  874. then return []
  875. else getPackageExtraCcOpts dflags pkgs
  876. framework_paths <-
  877. case platformOS platform of
  878. OSDarwin ->
  879. do pkgFrameworkPaths <- io $ getPackageFrameworkPath dflags pkgs
  880. let cmdlineFrameworkPaths = frameworkPaths dflags
  881. return $ map ("-F"++)
  882. (cmdlineFrameworkPaths ++ pkgFrameworkPaths)
  883. _ ->
  884. return []
  885. let split_objs = dopt Opt_SplitObjs dflags
  886. split_opt | hcc && split_objs = [ "-DUSE_SPLIT_MARKERS" ]
  887. | otherwise = [ ]
  888. let cc_opt | optLevel dflags >= 2 = "-O2"
  889. | otherwise = "-O"
  890. -- Decide next phase
  891. let next_phase = As
  892. output_fn <- phaseOutputFilename next_phase
  893. let
  894. more_hcc_opts =
  895. -- on x86 the floating point regs have greater precision
  896. -- than a double, which leads to unpredictable results.
  897. -- By default, we turn this off with -ffloat-store unless
  898. -- the user specified -fexcess-precision.
  899. (if platformArch platform == ArchX86 &&
  900. not (dopt Opt_ExcessPrecision dflags)
  901. then [ "-ffloat-store" ]
  902. else []) ++
  903. -- gcc's -fstrict-aliasing allows two accesses to memory
  904. -- to be considered non-aliasing if they have different types.
  905. -- This interacts badly with the C code we generate, which is
  906. -- very weakly typed, being derived from C--.
  907. ["-fno-strict-aliasing"]
  908. let gcc_lang_opt | cc_phase `eqPhase` Ccpp = "c++"
  909. | cc_phase `eqPhase` Cobjc = "objective-c"
  910. | cc_phase `eqPhase` Cobjcpp = "objective-c++"
  911. | otherwise = "c"
  912. io $ SysTools.runCc dflags (
  913. -- force the C compiler to interpret this file as C when
  914. -- compiling .hc files, by adding the -x c option.
  915. -- Also useful for plain .c files, just in case GHC saw a
  916. -- -x c option.
  917. [ SysTools.Option "-x", SysTools.Option gcc_lang_opt
  918. , SysTools.FileOption "" input_fn
  919. , SysTools.Option "-o"
  920. , SysTools.FileOption "" output_fn
  921. ]
  922. ++ map SysTools.Option (
  923. pic_c_flags
  924. -- Stub files generated for foreign exports references the runIO_closure
  925. -- and runNonIO_closure symbols, which are defined in the base package.
  926. -- These symbols are imported into the stub.c file via RtsAPI.h, and the
  927. -- way we do the import depends on whether we're currently compiling
  928. -- the base package or not.
  929. ++ (if platformOS platform == OSMinGW32 &&
  930. thisPackage dflags == basePackageId
  931. then [ "-DCOMPILING_BASE_PACKAGE" ]
  932. else [])
  933. -- We only support SparcV9 and better because V8 lacks an atomic CAS
  934. -- instruction. Note that the user can still override this
  935. -- (e.g., -mcpu=ultrasparc) as GCC picks the "best" -mcpu flag
  936. -- regardless of the ordering.
  937. --
  938. -- This is a temporary hack.
  939. ++ (if platformArch platform == ArchSPARC
  940. then ["-mcpu=v9"]
  941. else [])
  942. ++ (if hcc
  943. then gcc_extra_viac_flags ++ more_hcc_opts
  944. else [])
  945. ++ verbFlags
  946. ++ [ "-S", "-Wimplicit", cc_opt ]
  947. ++ [ "-D__GLASGOW_HASKELL__="++cProjectVersionInt ]
  948. ++ framework_paths
  949. ++ cc_opts
  950. ++ split_opt
  951. ++ include_paths
  952. ++ pkg_extra_cc_opts
  953. ))
  954. return (next_phase, output_fn)
  955. -----------------------------------------------------------------------------
  956. -- Splitting phase
  957. runPhase Splitter input_fn dflags
  958. = do -- tmp_pfx is the prefix used for the split .s files
  959. split_s_prefix <- io $ SysTools.newTempName dflags "split"
  960. let n_files_fn = split_s_prefix
  961. io $ SysTools.runSplit dflags
  962. [ SysTools.FileOption "" input_fn
  963. , SysTools.FileOption "" split_s_prefix
  964. , SysTools.FileOption "" n_files_fn
  965. ]
  966. -- Save the number of split files for future references
  967. s <- io $ readFile n_files_fn
  968. let n_files = read s :: Int
  969. dflags' = dflags { splitInfo = Just (split_s_prefix, n_files) }
  970. setDynFlags dflags'
  971. -- Remember to delete all these files
  972. io $ addFilesToClean dflags' [ split_s_prefix ++ "__" ++ show n ++ ".s"
  973. | n <- [1..n_files]]
  974. return (SplitAs,
  975. "**splitter**") -- we don't use the filename in SplitAs
  976. -----------------------------------------------------------------------------
  977. -- As, SpitAs phase : Assembler
  978. -- This is for calling the assembler on a regular assembly file (not split).
  979. runPhase As input_fn dflags
  980. = do
  981. -- LLVM from version 3.0 onwards doesn't support the OS X system
  982. -- assembler, so we use clang as the assembler instead. (#5636)
  983. let whichAsProg | hscTarget dflags == HscLlvm &&
  984. platformOS (targetPlatform dflags) == OSDarwin
  985. = do
  986. llvmVer <- io $ figureLlvmVersion dflags
  987. return $ case llvmVer of
  988. Just n | n >= 30 -> SysTools.runClang
  989. _ -> SysTools.runAs
  990. | otherwise
  991. = return SysTools.runAs
  992. as_prog <- whichAsProg
  993. let as_opts = getOpts dflags opt_a
  994. let cmdline_include_paths = includePaths dflags
  995. next_phase <- maybeMergeStub
  996. output_fn <- phaseOutputFilename next_phase
  997. -- we create directories for the object file, because it
  998. -- might be a hierarchical module.
  999. io $ createDirectoryHierarchy (takeDirectory output_fn)
  1000. io $ as_p

Large files files are truncated, but you can click here to view the full file