runAs, runLink, -- [Option] -> IO ()
runMkDLL,
runWindres,
+ runLlvmOpt,
+ runLlvmLlc,
touch, -- String -> String -> IO ()
copy,
; let installed :: FilePath -> FilePath
installed file = top_dir </> file
installed_mingw_bin file = top_dir </> ".." </> "mingw" </> "bin" </> file
+ installed_perl_bin file = top_dir </> ".." </> "perl" </> file
; let pkgconfig_path = installed "package.conf.d"
ghc_usage_msg_path = installed "ghc-usage.txt"
| isWindowsHost = installed_mingw_bin "gcc"
| otherwise = cGCC
perl_path
- | isWindowsHost = installed cGHC_PERL
+ | isWindowsHost = installed_perl_bin cGHC_PERL
| otherwise = cGHC_PERL
-- 'touch' is a GHC util for Windows
touch_path
; let as_prog = gcc_prog
ld_prog = gcc_prog
+ -- figure out llvm location. (TODO: Acutally implement).
+ ; let lc_prog = "llc"
+ lo_prog = "opt"
+
; return dflags1{
ghcUsagePath = ghc_usage_msg_path,
ghciUsagePath = ghci_usage_msg_path,
pgm_dll = (mkdll_prog,mkdll_args),
pgm_T = touch_path,
pgm_sysman = top_dir ++ "/ghc/rts/parallel/SysMan",
- pgm_windres = windres_path
+ pgm_windres = windres_path,
+ pgm_lo = (lo_prog,[]),
+ pgm_lc = (lc_prog,[])
-- Hans: this isn't right in general, but you can
-- elaborate it in the same way as the others
}
mb_env <- getGccEnv args1
runSomethingFiltered dflags id "Assembler" p args1 mb_env
+runLlvmOpt :: DynFlags -> [Option] -> IO ()
+runLlvmOpt dflags args = do
+ let (p,args0) = pgm_lo dflags
+ runSomething dflags "LLVM Optimiser" p (args0++args)
+
+runLlvmLlc :: DynFlags -> [Option] -> IO ()
+runLlvmLlc dflags args = do
+ let (p,args0) = pgm_lc dflags
+ runSomething dflags "LLVM Compiler" p (args0++args)
+
runLink :: DynFlags -> [Option] -> IO ()
runLink dflags args = do
let (p,args0) = pgm_l dflags
runWindres :: DynFlags -> [Option] -> IO ()
runWindres dflags args = do
- let (_gcc,gcc_args) = pgm_c dflags
- windres = pgm_windres dflags
+ let (gcc, gcc_args) = pgm_c dflags
+ windres = pgm_windres dflags
+ quote x = "\"" ++ x ++ "\""
+ args' = -- If windres.exe and gcc.exe are in a directory containing
+ -- spaces then windres fails to run gcc. We therefore need
+ -- to tell it what command to use...
+ Option ("--preprocessor=" ++
+ unwords (map quote (gcc :
+ map showOpt gcc_args ++
+ ["-E", "-xc", "-DRC_INVOKED"])))
+ -- ...but if we do that then if windres calls popen then
+ -- it can't understand the quoting, so we have to use
+ -- --use-temp-file so that it interprets it correctly.
+ -- See #1828.
+ : Option "--use-temp-file"
+ : args
mb_env <- getGccEnv gcc_args
- runSomethingFiltered dflags id "Windres" windres args mb_env
+ runSomethingFiltered dflags id "Windres" windres args' mb_env
touch :: DynFlags -> String -> String -> IO ()
touch dflags purpose arg =
newTempName dflags extn
= do d <- getTempDir dflags
x <- getProcessID
- findTempName (d ++ "/ghc" ++ show x ++ "_") 0
+ findTempName (d </> "ghc" ++ show x ++ "_") 0
where
findTempName :: FilePath -> Integer -> IO FilePath
findTempName prefix x
case lookupFM mapping tmp_dir of
Nothing ->
do x <- getProcessID
- let prefix = tmp_dir ++ "/ghc" ++ show x ++ "_"
+ let prefix = tmp_dir </> "ghc" ++ show x ++ "_"
let
mkTempDir :: Integer -> IO FilePath
mkTempDir x