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

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

问题描述

有没有什么好的方法来制作小型的haskell可执行文件?使用ghc6,一个简单的hello world程序似乎达到了约370kB(在strip之前为523kB)。

这是添加在?):

  $ 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-小
24 hello
16 hello-small

参见: >



与C进行比较:

  $ gcc hello.c -o你好
$ str ip -p --strip-unneeded --remove-section = .comment -o hello-small hello
$ du hello hello-small
12 hello
8 hello-small


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).

解决方案

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

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

See also: http://hackage.haskell.org/trac/ghc/wiki/SharedLibraries/PlatformSupport

For comparison with 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天全站免登陆