@@ -24,24 +24,22 @@ codegenC ci = codegenC' (simpleDecls ci)
2424 (outputFile ci)
2525 (outputType ci)
2626 (includes ci)
27− (concatMap mkObj (compileObjs ci))
28− (concatMap mkLib (compileLibs ci) ++
29− concatMap incdir (importDirs ci))
30− (concatMap mkFlag (compilerFlags ci))
27+ (compileObjs ci)
28+ (map mkLib (compileLibs ci) ++
29+ map incdir (importDirs ci))
30+ (compilerFlags ci)
3131 (debugLevel ci)
3232
33− where mkObj f = f ++ " "
34− mkLib l = "-l" ++ l ++ " "
35− mkFlag l = l ++ " "
36− incdir i = "-I" ++ i ++ " "
33+ where mkLib l = "-l" ++ l
34+ incdir i = "-I" ++ i
3735
3836codegenC' :: [(Name, SDecl)] ->
3937 String -> -- output file name
4038 OutputType -> -- generate executable if True, only .o if False
4139 [FilePath] -> -- include files
42− String -> -- extra object files
43− String -> -- extra compiler flags (libraries)
44− String -> -- extra compiler flags (anything)
40+ [String] -> -- extra object files
41+ [String] -> -- extra compiler flags (libraries)
42+ [String] -> -- extra compiler flags (anything)
4543 DbgLevel ->
4644 IO ()
4745codegenC' defs out exec incs objs libs flags dbg
@@ -64,23 +62,22 @@ codegenC' defs out exec incs objs libs flags dbg
6462 comp <- getCC
6563 libFlags <- getLibFlags
6664 incFlags <- getIncFlags
67− let gcc = comp ++ " " ++
68− gccDbg dbg ++ " " ++
69− gccFlags ++
70− -- # Any flags defined here which alter the RTS API must also be added to config.mk
71− " -DHAS_PTHREAD -DIDRIS_ENABLE_STATS" ++
72− " -I. " ++ objs ++ " -x c " ++
73− (if (exec == Executable) then "" else " -c ") ++
74− " " ++ tmpn ++
75− " " ++ libFlags ++
76− " " ++ incFlags ++
77− " " ++ libs ++
78− " " ++ flags ++
79− " -o " ++ out
65+ let args = [gccDbg dbg] ++
66+ gccFlags ++
67+ -- # Any flags defined here which alter the RTS API must also be added to config.mk
68+ ["-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS",
69+ "-I."] ++ objs ++ ["-x", "c"] ++
70+ (if (exec == Executable) then [] else ["-c"]) ++
71+ [tmpn] ++
72+ libFlags ++
73+ incFlags ++
74+ libs ++
75+ flags ++
76+ ["-o", out]
8077-- putStrLn gcc
81− exit <- system gcc
78+ exit <- rawSystem comp args
8279 when (exit /= ExitSuccess) $
83− putStrLn ("FAILURE: " ++ gcc)
80+ putStrLn ("FAILURE: " ++ show comp ++ " " ++ show args)
8481
8582headers xs =
8683 concatMap
@@ -92,7 +89,7 @@ debug _ = ""
9289
9390-- We're using signed integers now. Make sure we get consistent semantics
9491-- out of them from gcc. See e.g. http://thiemonagel.de/2010/01/signed-integer-overflow/
95−gccFlags = " -fwrapv -fno-strict-overflow"
92+gccFlags = ["-fwrapv", "-fno-strict-overflow"]
9693
9794gccDbg DEBUG = "-g"
9895gccDbg TRACE = "-O2"