@@ -80,7 +80,7 @@ codegenC' defs out exec incs objs libs flags exports iface dbg
8080 incFlags <- getIncFlags
8181 envFlags <- getEnvFlags
8282 let stackFlag = if isWindows then ["-Wl,--stack,16777216"] else []
83− let args = [gccDbg dbg] ++
83+ let args = gccDbg dbg ++
8484 gccFlags iface ++
8585 -- # Any flags defined here which alter the RTS API must also be added to config.mk
8686 ["-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS",
@@ -112,9 +112,12 @@ debug _ = ""
112112gccFlags i = if i then ["-fwrapv"]
113113 else ["-fwrapv", "-fno-strict-overflow"]
114114
115−gccDbg DEBUG = "-g"
116−gccDbg TRACE = "-O2"
117−gccDbg _ = "-O2"
115+gccDbg DEBUG = ["-g"]
116+-- clang optimises sibling calls in O1, but gcc doesn't
117+-- on the other hand, O1 compiles significantly faster in clang without
118+-- any noticeable performance hit.
119+gccDbg TRACE = ["-O1", "-foptimize-sibling-calls"]
120+gccDbg _ = ["-O1", "-foptimize-sibling-calls"]
118121
119122cname :: Name -> String
120123cname n = "_idris_" ++ concatMap cchar (showCG n)