haskell - 制作小型 haskell 可执行文件?

标签 haskell linker ghc static-linking

有什么好的方法可以制作小型的 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/

相关文章:

c++ - Eclipse中的Boost链接错误

haskell:在 haskell 平台 2013 2.0.0 中使用 writer monad 时,没有 (Monoid Int) 的实例

c - 为什么有时需要为 C 链接列出两次库,这是可以避免的吗?

haskell - 内部模块的跨模块内联

haskell - 如何获得离线 Haskell 调试跟踪?

Haskell:如何使用 haskeline 并在同一程序中写入文件

Haskell:按类型过滤异构列表

haskell - 在不使用列表的情况下内嵌长字符串

performance - 从 Haskell 中的 monadic 流中榨取更多性能

c++ - 将链接器选项添加到 Eclipse CDT Autotools 项目