制作小型haskell可执行文件? [英] Making small haskell executables?

查看:35
本文介绍了制作小型haskell可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么好的方法可以制作小型的 haskell 可执行文件吗?使用 ghc6,一个简单的 hello world 程序似乎达到了大约 370kB(剥离前为 523kB).C 中的 Hello world 大约为 4kB(剥离前为 9kB).

Are there any good ways to make small haskell executables? With ghc6 a simple hello world program seems to come to about 370kB (523kB before strip). Hello world in C is about 4kB (9kB before strip).

推荐答案

用GHC的开发分支(有谁知道具体是在哪个版本添加的?):

With the development branch of GHC (anyone know exactly which version this was added in?):

$ 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 标志:

Add the -dynamic flag for a dynamically linked RTS:

$ 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可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆