"Hello world" now only 11k using GHC with shared libs

Tuesday, 28 April 2009, by Duncan Coutts.
Filed under coding, industrial-haskell-group.

$ ./Hello.dyn 
Hello World!

$ ls -ogh Hello Hello.dyn
411K 2009-04-28 21:59 Hello
 11K 2009-04-28 21:55 Hello.dyn

On Linux x86-64 with GHC using shared libraries a "Hello World" program is now only 11k compared to 411k previously. By comparison, JHC manages 6.4k and an equivalent C program is 6.3k. (All sizes after running strip on the binary.)

As I mentioned earlier, the IHG has asked us to work on improving GHC's support for shared libraries. I've been updating the new GHC build system to support --enable-shared and I've just now managed to get the build to go through. I'll clean up my patches and send them in tomorrow. There are still a number of things to do. I've got to run the testsuite with everything built for shared libs. Clemens had this working before so I'm not expecting too many test failures. We also need to set up a GHC buildbot to use --enable-shared so that we do not get regressions.

The next task will be to test that it works to make a Haskell library that exports a C API and to use it as a plugin for some other program. Anyone got any good suggestions for a simple demo plugin? What programs have nice simple plugin APIs?