@@ -24,24 +24,22 @@ codegenC ci = codegenC' (simpleDecls ci)
24 (outputFile ci)
24 (outputFile ci)
25 (outputType ci)
25 (outputType ci)
26 (includes ci)
26 (includes ci)
27− (concatMap mkObj (compileObjs ci))
27+ (compileObjs ci)
28− (concatMap mkLib (compileLibs ci) ++
28+ (map mkLib (compileLibs ci) ++
29− concatMap incdir (importDirs ci))
29+ map incdir (importDirs ci))
30− (concatMap mkFlag (compilerFlags ci))
30+ (compilerFlags ci)
31 (debugLevel ci)
31 (debugLevel ci)
33− where mkObj f = f ++ " "
34− mkLib l = "-l" ++ l ++ " "
33+ where mkLib l = "-l" ++ l
36− incdir i = "-I" ++ i ++ " "
34+ incdir i = "-I" ++ i
38codegenC' :: [(Name, SDecl)] ->
36codegenC' :: [(Name, SDecl)] ->
39 String -> -- output file name
37 String -> -- output file name
40 OutputType -> -- generate executable if True, only .o if False
38 OutputType -> -- generate executable if True, only .o if False
41 [FilePath] -> -- include files
39 [FilePath] -> -- include files
42− String -> -- extra object files
40+ [String] -> -- extra object files
43− String -> -- extra compiler flags (libraries)
41+ [String] -> -- extra compiler flags (libraries)
44− String -> -- extra compiler flags (anything)
42+ [String] -> -- extra compiler flags (anything)
45 DbgLevel ->
43 DbgLevel ->
47codegenC' defs out exec incs objs libs flags dbg
45codegenC' defs out exec incs objs libs flags dbg
@@ -64,23 +62,22 @@ codegenC' defs out exec incs objs libs flags dbg
64 comp <- getCC
62 comp <- getCC
65 libFlags <- getLibFlags
63 libFlags <- getLibFlags
66 incFlags <- getIncFlags
64 incFlags <- getIncFlags
67− let gcc = comp ++ " " ++
68− gccDbg dbg ++ " " ++
65+ let args = [gccDbg dbg] ++
69− gccFlags ++
66+ gccFlags ++
70− -- # Any flags defined here which alter the RTS API must also be added to config.mk
67+ -- # Any flags defined here which alter the RTS API must also be added to config.mk
71− " -DHAS_PTHREAD -DIDRIS_ENABLE_STATS" ++
68+ ["-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS",
72− " -I. " ++ objs ++ " -x c " ++
69+ "-I."] ++ objs ++ ["-x", "c"] ++
73− (if (exec == Executable) then "" else " -c ") ++
70+ (if (exec == Executable) then [] else ["-c"]) ++
74− " " ++ tmpn ++
71+ [tmpn] ++
75− " " ++ libFlags ++
72+ libFlags ++
76− " " ++ incFlags ++
73+ incFlags ++
77− " " ++ libs ++
74+ libs ++
78− " " ++ flags ++
75+ flags ++
79− " -o " ++ out
76+ ["-o", out]
80-- putStrLn gcc
77-- putStrLn gcc
81− exit <- system gcc
78+ exit <- rawSystem comp args
82 when (exit /= ExitSuccess) $
79 when (exit /= ExitSuccess) $
83− putStrLn ("FAILURE: " ++ gcc)
80+ putStrLn ("FAILURE: " ++ show comp ++ " " ++ show args)
85headers xs =
82headers xs =
@@ -92,7 +89,7 @@ debug _ = ""
93-- We're using signed integers now. Make sure we get consistent semantics
90-- We're using signed integers now. Make sure we get consistent semantics
94-- out of them from gcc. See e.g. http://thiemonagel.de/2010/01/signed-integer-overflow/
91-- 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"]
97gccDbg DEBUG = "-g"
94gccDbg DEBUG = "-g"
98gccDbg TRACE = "-O2"
95gccDbg TRACE = "-O2"