runPhase Cmm input_fn dflags
= do
- PipeEnv{stop_phase,src_basename} <- getPipeEnv
+ PipeEnv{src_basename} <- getPipeEnv
let hsc_lang = hscTarget dflags
let next_phase = hscNextPhase dflags HsSrcFile hsc_lang
-- way too many hacks, and I can't say I've ever used it anyway.
runPhase cc_phase input_fn dflags
- | cc_phase `eqPhase` Cc || cc_phase `eqPhase` Ccpp || cc_phase `eqPhase` HCc
+ | cc_phase `eqPhase` Cc || cc_phase `eqPhase` Ccpp || cc_phase `eqPhase` HCc || cc_phase `eqPhase` Cobjc
= do
let cc_opts = getOpts dflags opt_c
hcc = cc_phase `eqPhase` HCc
-- very weakly typed, being derived from C--.
["-fno-strict-aliasing"]
+ let gcc_lang_opt | cc_phase `eqPhase` Ccpp = "c++"
+ | cc_phase `eqPhase` Cobjc = "objective-c"
+ | otherwise = "c"
io $ SysTools.runCc dflags (
-- force the C compiler to interpret this file as C when
-- 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", if cc_phase `eqPhase` Ccpp
- then SysTools.Option "c++"
- else SysTools.Option "c"] ++
- [ SysTools.FileOption "" input_fn
+ [ SysTools.Option "-x", SysTools.Option gcc_lang_opt
+ , SysTools.FileOption "" input_fn
, SysTools.Option "-o"
, SysTools.FileOption "" output_fn
]
runPhase SplitAs _input_fn dflags
= do
- next_phase <- maybeMergeStub
+ -- we'll handle the stub_o file in this phase, so don't MergeStub,
+ -- just jump straight to StopLn afterwards.
+ let next_phase = StopLn
output_fn <- phaseOutputFilename next_phase
let base_o = dropExtension output_fn
io $ mapM_ assemble_file [1..n]
+ -- If there's a stub_o file, then we make it the n+1th split object.
+ PipeState{maybe_stub_o} <- getPipeState
+ n' <- case maybe_stub_o of
+ Nothing -> return n
+ Just stub_o -> do io $ copyFile stub_o (split_obj (n+1))
+ return (n+1)
+
-- join them into a single .o file
- io $ joinObjectFiles dflags (map split_obj [1..n]) output_fn
+ io $ joinObjectFiles dflags (map split_obj [1..n']) output_fn
return (next_phase, output_fn)