这是添加在?):
$ 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屋!