相关疑难解决方法(0)

为什么Haskell/GHC可执行文件在文件大小中如此之大?

可能重复:
用GHC编译成小二进制的小Haskell程序

最近我注意到Haskell可执行文件有多大.下面的所有内容都是-O2在Linux 上用GHC 7.4.1编译的.

  1. Hello World(main = putStrLn "Hello World!")超过800 KiB.strip在它上面运行会将文件大小减少到500 KiB; 甚至添加-dynamic到编译中也没有多大帮助,让我在400 KiB附近删除了一个可剥离的可执行文件.

  2. 编译涉及Parsec的非常原始的示例产生1.7 MiB文件.

    -- File: test.hs
    import qualified Text.ParserCombinators.Parsec as P
    import Data.Either (either)
    
    -- Parses a string of type "x y" to the tuple (x,y).
    testParser :: P.Parser (Char, Char)
    testParser = do
        a <- P.anyChar
        P.char ' '
        b <- P.anyChar
        return (a, b)
    
    -- Parse, print result.
    str = "1 2"
    main = print $ …
    Run Code Online (Sandbox Code Playgroud)

haskell compilation ghc

16
推荐指数
2
解决办法
4464
查看次数

标签 统计

compilation ×1

ghc ×1

haskell ×1