@@ -79,18 +79,22 @@ codegenC' defs out exec incs objs libs flags exports iface dbg
7979 libFlags <- getLibFlags
8080 incFlags <- getIncFlags
8181 envFlags <- getEnvFlags
82− let stackFlag = if isWindows then ["-Wl,--stack,16777216"] else []
82+ let stripFlag = if isDarwin then "-dead_strip" else "-Wl,-gc-sections"
83+ let stackFlags = if isWindows then ["-Wl,--stack,16777216"] else []
84+ let linkFlags = stripFlag : stackFlags
8385 let args = gccDbg dbg ++
8486 gccFlags iface ++
8587 -- # Any flags defined here which alter the RTS API must also be added to config.mk
86− ["-std=c99", "-D_POSIX_C_SOURCE=200809L", "-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS",
87− "-I."] ++ objs ++ envFlags ++
88− (if (exec == Executable) then [] else ["-c"]) ++
88+ [ "-std=c99", "-pipe"
89+ , "-fdata-sections", "-ffunction-sections"
90+ , "-D_POSIX_C_SOURCE=200809L", "-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS"
91+ , "-I."] ++ objs ++ envFlags ++
92+ (if (exec == Executable) then linkFlags else ["-c"]) ++
8993 [tmpn] ++
9094 (if not iface then libFlags else []) ++
9195 incFlags ++
9296 (if not iface then libs else []) ++
93− flags ++ stackFlag ++
97+ flags ++
9498 ["-o", out]
9599-- putStrLn (show args)
96100 exit <- rawSystem comp args