Strip unreachable code/data

This commit is contained in:
Jorge Acereda 2018-05-01 23:17:54 +02:00
parent fb1cc4e1ce
commit d13fa5cfb3
3 changed files with 14 additions and 6 deletions

View File

@ -14,7 +14,7 @@ RANLIB ?=ranlib
CABAL :=cabal CABAL :=cabal
# IDRIS_ENABLE_STATS should not be set in final release # IDRIS_ENABLE_STATS should not be set in final release
# Any flags defined here which alter the RTS API must also be added to src/IRTS/CodegenC.hs # Any flags defined here which alter the RTS API must also be added to src/IRTS/CodegenC.hs
CFLAGS :=-O2 -Wall -std=c99 -D_POSIX_C_SOURCE=200809L -DHAS_PTHREAD -DIDRIS_ENABLE_STATS $(CFLAGS) CFLAGS :=-O2 -Wall -std=c99 -pipe -fdata-sections -ffunction-sections -D_POSIX_C_SOURCE=200809L -DHAS_PTHREAD -DIDRIS_ENABLE_STATS $(CFLAGS)
# CABALFLAGS := # CABALFLAGS :=
CABALFLAGS += --enable-tests CABALFLAGS += --enable-tests

View File

@ -79,18 +79,22 @@ codegenC' defs out exec incs objs libs flags exports iface dbg
libFlags <- getLibFlags libFlags <- getLibFlags
incFlags <- getIncFlags incFlags <- getIncFlags
envFlags <- getEnvFlags envFlags <- getEnvFlags
let stackFlag = if isWindows then ["-Wl,--stack,16777216"] else [] let stripFlag = if isDarwin then "-dead_strip" else "-Wl,-gc-sections"
let stackFlags = if isWindows then ["-Wl,--stack,16777216"] else []
let linkFlags = stripFlag : stackFlags
let args = gccDbg dbg ++ let args = gccDbg dbg ++
gccFlags iface ++ gccFlags iface ++
-- # Any flags defined here which alter the RTS API must also be added to config.mk -- # Any flags defined here which alter the RTS API must also be added to config.mk
["-std=c99", "-D_POSIX_C_SOURCE=200809L", "-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS", [ "-std=c99", "-pipe"
"-I."] ++ objs ++ envFlags ++ , "-fdata-sections", "-ffunction-sections"
(if (exec == Executable) then [] else ["-c"]) ++ , "-D_POSIX_C_SOURCE=200809L", "-DHAS_PTHREAD", "-DIDRIS_ENABLE_STATS"
, "-I."] ++ objs ++ envFlags ++
(if (exec == Executable) then linkFlags else ["-c"]) ++
[tmpn] ++ [tmpn] ++
(if not iface then libFlags else []) ++ (if not iface then libFlags else []) ++
incFlags ++ incFlags ++
(if not iface then libs else []) ++ (if not iface then libs else []) ++
flags ++ stackFlag ++ flags ++
["-o", out] ["-o", out]
-- putStrLn (show args) -- putStrLn (show args)
exit <- rawSystem comp args exit <- rawSystem comp args

View File

@ -10,6 +10,7 @@ module Util.System( tempfile
, withTempdir , withTempdir
, rmFile , rmFile
, catchIO , catchIO
, isDarwin
, isWindows , isWindows
, writeSource , writeSource
, writeSourceText , writeSourceText
@ -50,6 +51,9 @@ catchIO = CE.catch
isWindows :: Bool isWindows :: Bool
isWindows = os `elem` ["win32", "mingw32", "cygwin32"] isWindows = os `elem` ["win32", "mingw32", "cygwin32"]
isDarwin :: Bool
isDarwin = os == "darwin"
-- | Create a temp file with the extensiom ext (in the format ".xxx") -- | Create a temp file with the extensiom ext (in the format ".xxx")
tempfile :: String -> IO (FilePath, Handle) tempfile :: String -> IO (FilePath, Handle)
tempfile ext = do dir <- getTemporaryDirectory tempfile ext = do dir <- getTemporaryDirectory