1 -----------------------------------------------------------------------------
2 -- $Id: DriverPhases.hs,v 1.30 2004/09/30 10:37:11 simonpj Exp $
6 -- (c) The University of Glasgow 2002
8 -----------------------------------------------------------------------------
10 #include "../includes/ghcconfig.h"
15 startPhase, -- :: String -> Phase
16 phaseInputExt, -- :: Phase -> String
24 isHaskellUserSrcFilename,
25 isSourceFilename -- :: FilePath -> Bool
30 -----------------------------------------------------------------------------
34 Phase of the | Suffix saying | Flag saying | (suffix of)
35 compilation system | ``start here''| ``stop after''| output file
37 literate pre-processor | .lhs | - | -
38 C pre-processor (opt.) | - | -E | -
39 Haskell compiler | .hs | -C, -S | .hc, .s
40 C compiler (opt.) | .hc or .c | -S | .s
41 assembler | .s or .S | -c | .o
42 linker | other | - | a.out
51 | HCc -- Haskellised C (as opposed to vanilla C) compilation
52 | Mangle -- assembly mangling, now done by a separate script.
53 | SplitMangle -- after mangler if splitting
57 | CmmCpp -- pre-process Cmm source
58 | Cmm -- parse & compile Cmm code
65 -- Partial ordering on phases: we want to know which phases will occur before
66 -- which others. This is used for sanity checking, to ensure that the
67 -- pipeline will stop at some point (see DriverPipeline.runPipeline).
69 | x `elem` haskell_pipe = y `elem` tail (dropWhile (/= x) haskell_pipe)
70 | x `elem` cmm_pipe = y `elem` tail (dropWhile (/= x) cmm_pipe)
71 | x `elem` c_pipe = y `elem` tail (dropWhile (/= x) c_pipe)
74 haskell_post_hsc = [HCc,Mangle,SplitMangle,As,SplitAs,Ln]
75 haskell_pipe = Unlit : Cpp : HsPp : Hsc : haskell_post_hsc
76 cmm_pipe = CmmCpp : Cmm : haskell_post_hsc
79 -- the first compilation phase for a given file is determined
81 startPhase "lhs" = Unlit
83 startPhase "hscpp" = HsPp
84 startPhase "hspp" = Hsc
85 startPhase "hcr" = Hsc
92 startPhase "raw_s" = Mangle
96 startPhase "cmm" = CmmCpp
97 startPhase "cmmcpp" = Cmm
98 startPhase _ = Ln -- all unknown file types
100 -- the output suffix for a given phase is uniquely determined by
101 -- the input requirements of the next phase.
102 phaseInputExt Unlit = "lhs"
103 phaseInputExt Cpp = "lpp" -- intermediate only
104 phaseInputExt HsPp = "hscpp"
105 phaseInputExt Hsc = "hspp"
106 phaseInputExt HCc = "hc"
107 phaseInputExt Cc = "c"
108 phaseInputExt Mangle = "raw_s"
109 phaseInputExt SplitMangle = "split_s" -- not really generated
110 phaseInputExt As = "s"
111 phaseInputExt SplitAs = "split_s" -- not really generated
112 phaseInputExt Ln = "o"
113 phaseInputExt CmmCpp = "cmm"
114 phaseInputExt Cmm = "cmmcpp"
116 phaseInputExt Ilx2Il = "ilx"
117 phaseInputExt Ilasm = "il"
120 haskellish_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s", "cmm" ]
121 haskellish_src_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr", "cmm" ]
122 cish_suffixes = [ "c", "cpp", "C", "cc", "cxx", "s", "S" ]
123 extcoreish_suffixes = [ "hcr" ]
124 haskellish_user_src_suffixes = [ "hs", "lhs" ]
126 -- Use the appropriate suffix for the system on which
127 -- the GHC-compiled code will run
128 #if mingw32_TARGET_OS || cygwin32_TARGET_OS
129 objish_suffixes = [ "o", "O", "obj", "OBJ" ]
131 objish_suffixes = [ "o" ]
134 #ifdef mingw32_TARGET_OS
135 dynlib_suffixes = ["dll", "DLL"]
136 #elif defined(darwin_TARGET_OS)
137 dynlib_suffixes = ["dylib"]
139 dynlib_suffixes = ["so"]
142 isHaskellishFilename f = getFileSuffix f `elem` haskellish_suffixes
143 isHaskellSrcFilename f = getFileSuffix f `elem` haskellish_src_suffixes
144 isCishFilename f = getFileSuffix f `elem` cish_suffixes
145 isExtCoreFilename f = getFileSuffix f `elem` extcoreish_suffixes
146 isObjectFilename f = getFileSuffix f `elem` objish_suffixes
147 isHaskellUserSrcFilename f = getFileSuffix f `elem` haskellish_user_src_suffixes
148 isDynLibFilename f = getFileSuffix f `elem` dynlib_suffixes
150 isSourceFilename :: FilePath -> Bool
152 isHaskellishFilename f ||