有什么好的方法可以制作小型的 haskell 可执行文件吗?使用 ghc6,一个简单的 hello world 程序似乎约为 370kB(剥离之前为 523kB)。 C 语言的 Hello world 大约为 4kB(剥离前为 9kB)。
最佳答案
随着GHC的开发分支(有人确切知道这是在哪个版本中添加的吗?):
$ ghc -o hello hello.hs
$ strip -p --strip-unneeded --remove-section=.comment -o hello-small hello
$ du hello hello-small
700 hello
476 hello-small
为动态链接的 RTS 添加 -dynamic 标志:
$ ghc -dynamic -o hello hello.hs
$ strip -p --strip-unneeded --remove-section=.comment -o hello-small hello
$ du hello hello-small
24 hello
16 hello-small
另请参阅:http://hackage.haskell.org/trac/ghc/wiki/SharedLibraries/PlatformSupport
与C比较:
$ gcc hello.c -o hello
$ strip -p --strip-unneeded --remove-section=.comment -o hello-small hello
$ du hello hello-small
12 hello
8 hello-small
关于haskell - 制作小型 haskell 可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/699908/