1 -----------------------------------------------------------------------------
2 -- $Id: DriverPhases.hs,v 1.28 2003/10/22 14:31:09 simonmar Exp $
6 -- (c) The University of Glasgow 2002
8 -----------------------------------------------------------------------------
10 #include "../includes/config.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
63 -- Partial ordering on phases: we want to know which phases will occur before
64 -- which others. This is used for sanity checking, to ensure that the
65 -- pipeline will stop at some point (see DriverPipeline.runPipeline).
67 | x `elem` haskell_pipe = y `elem` tail (dropWhile (/= x) haskell_pipe)
68 | x `elem` c_pipe = y `elem` tail (dropWhile (/= x) c_pipe)
71 haskell_pipe = [Unlit,Cpp,HsPp,Hsc,HCc,Mangle,SplitMangle,As,SplitAs,Ln]
74 -- the first compilation phase for a given file is determined
76 startPhase "lhs" = Unlit
78 startPhase "hscpp" = HsPp
79 startPhase "hspp" = Hsc
80 startPhase "hcr" = Hsc
87 startPhase "raw_s" = Mangle
91 startPhase _ = Ln -- all unknown file types
93 -- the output suffix for a given phase is uniquely determined by
94 -- the input requirements of the next phase.
95 phaseInputExt Unlit = "lhs"
96 phaseInputExt Cpp = "lpp" -- intermediate only
97 phaseInputExt HsPp = "hscpp"
98 phaseInputExt Hsc = "hspp"
99 phaseInputExt HCc = "hc"
100 phaseInputExt Cc = "c"
101 phaseInputExt Mangle = "raw_s"
102 phaseInputExt SplitMangle = "split_s" -- not really generated
103 phaseInputExt As = "s"
104 phaseInputExt SplitAs = "split_s" -- not really generated
105 phaseInputExt Ln = "o"
107 phaseInputExt Ilx2Il = "ilx"
108 phaseInputExt Ilasm = "il"
111 haskellish_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr", "hc", "raw_s" ]
112 haskellish_src_suffixes = [ "hs", "lhs", "hspp", "hscpp", "hcr"]
113 cish_suffixes = [ "c", "cpp", "C", "cc", "cxx", "s", "S" ]
114 extcoreish_suffixes = [ "hcr" ]
115 haskellish_user_src_suffixes = [ "hs", "lhs" ]
117 -- Use the appropriate suffix for the system on which
118 -- the GHC-compiled code will run
119 #if mingw32_TARGET_OS || cygwin32_TARGET_OS
120 objish_suffixes = [ "o", "O", "obj", "OBJ" ]
122 objish_suffixes = [ "o" ]
125 #ifdef mingw32_TARGET_OS
126 dynlib_suffixes = ["dll", "DLL"]
127 #elif defined(darwin_TARGET_OS)
128 dynlib_suffixes = ["dylib"]
130 dynlib_suffixes = ["so"]
133 isHaskellishFilename f = getFileSuffix f `elem` haskellish_suffixes
134 isHaskellSrcFilename f = getFileSuffix f `elem` haskellish_src_suffixes
135 isCishFilename f = getFileSuffix f `elem` cish_suffixes
136 isExtCoreFilename f = getFileSuffix f `elem` extcoreish_suffixes
137 isObjectFilename f = getFileSuffix f `elem` objish_suffixes
138 isHaskellUserSrcFilename f = getFileSuffix f `elem` haskellish_user_src_suffixes
139 isDynLibFilename f = getFileSuffix f `elem` dynlib_suffixes
141 isSourceFilename :: FilePath -> Bool
143 isHaskellishFilename f ||