on master help sign in
Strip unreachable code/data
d13fa5cJorge Acereda
config.mk+1−1
@@ -14,7 +14,7 @@ RANLIB ?=ranlib
14CABAL :=cabal
14CABAL :=cabal
15# IDRIS_ENABLE_STATS should not be set in final release
15# IDRIS_ENABLE_STATS should not be set in final release
16# Any flags defined here which alter the RTS API must also be added to src/IRTS/CodegenC.hs
16# Any flags defined here which alter the RTS API must also be added to src/IRTS/CodegenC.hs
17−CFLAGS :=-O2 -Wall -std=c99 -D_POSIX_C_SOURCE=200809L -DHAS_PTHREAD -DIDRIS_ENABLE_STATS $(CFLAGS)
17+CFLAGS :=-O2 -Wall -std=c99 -pipe -fdata-sections -ffunction-sections -D_POSIX_C_SOURCE=200809L -DHAS_PTHREAD -DIDRIS_ENABLE_STATS $(CFLAGS)
18
18
19# CABALFLAGS :=
19# CABALFLAGS :=
20CABALFLAGS += --enable-tests
20CABALFLAGS += --enable-tests
src/IRTS/CodegenC.hs+9−5
@@ -79,18 +79,22 @@ codegenC' defs out exec incs objs libs flags exports iface dbg
79 libFlags <- getLibFlags
79 libFlags <- getLibFlags
80 incFlags <- getIncFlags
80 incFlags <- getIncFlags
81 envFlags <- getEnvFlags
81 envFlags <- getEnvFlags
82+ let stripFlag = if isDarwin then "-dead_strip" else "-Wl,-gc-sections"
82− let stackFlag = if isWindows then ["-Wl,--stack,16777216"] else []
83+ let stackFlags = if isWindows then ["-Wl,--stack,16777216"] else []
84+ let linkFlags = stripFlag : stackFlags
83 let args = gccDbg dbg ++
85 let args = gccDbg dbg ++
84 gccFlags iface ++
86 gccFlags iface ++
85 -- # Any flags defined here which alter the RTS API must also be added to config.mk
87 -- # Any flags defined here which alter the RTS API must also be added to config.mk
88+ [ "-std=c99", "-pipe"
89+ , "-fdata-sections", "-ffunction-sections"
86− ["-std=c99", "-D_POSIX_C_SOURCE=200809L", "-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS",
90+ , "-D_POSIX_C_SOURCE=200809L", "-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS"
87− "-I."] ++ objs ++ envFlags ++
91+ , "-I."] ++ objs ++ envFlags ++
88− (if (exec == Executable) then [] else ["-c"]) ++
92+ (if (exec == Executable) then linkFlags else ["-c"]) ++
89 [tmpn] ++
93 [tmpn] ++
90 (if not iface then libFlags else []) ++
94 (if not iface then libFlags else []) ++
91 incFlags ++
95 incFlags ++
92 (if not iface then libs else []) ++
96 (if not iface then libs else []) ++
93− flags ++ stackFlag ++
97+ flags ++
94 ["-o", out]
98 ["-o", out]
95-- putStrLn (show args)
99-- putStrLn (show args)
96 exit <- rawSystem comp args
100 exit <- rawSystem comp args
src/Util/System.hs+4
@@ -10,6 +10,7 @@ module Util.System( tempfile
10 , withTempdir
10 , withTempdir
11 , rmFile
11 , rmFile
12 , catchIO
12 , catchIO
13+ , isDarwin
13 , isWindows
14 , isWindows
14 , writeSource
15 , writeSource
15 , writeSourceText
16 , writeSourceText
@@ -50,6 +51,9 @@ catchIO = CE.catch
50isWindows :: Bool
51isWindows :: Bool
51isWindows = os `elem` ["win32", "mingw32", "cygwin32"]
52isWindows = os `elem` ["win32", "mingw32", "cygwin32"]
52
53
54+isDarwin :: Bool
55+isDarwin = os == "darwin"
56+
53-- | Create a temp file with the extensiom ext (in the format ".xxx")
57-- | Create a temp file with the extensiom ext (in the format ".xxx")
54tempfile :: String -> IO (FilePath, Handle)
58tempfile :: String -> IO (FilePath, Handle)
55tempfile ext = do dir <- getTemporaryDirectory
59tempfile ext = do dir <- getTemporaryDirectory