patrickt / pony

A source-to-source transformer for C99, written in Haskell.
Other
5 stars 0 forks source link

Executables are comically large #63

Open patrickt opened 12 years ago

patrickt commented 12 years ago

Currently all of the examples compile down to 5.5 MB executables. This is silly.

I'm not really sure how dynamically-linked libraries work in Haskell-land, but it behooves us to figure this out.

akhirsch commented 12 years ago

http://www.haskell.org/ghc/docs/7.0.3/html/users_guide/using-shared-libs.html

This is how to do it, according to haskell.org. Sadly, only Linux is fully supported, with partial support for windows. That means mac is sol, I'm afraid, unless someone else can find a way around it.

akhirsch commented 12 years ago

Specifically, it looks like what we have to do is to turn the libraries that we want to have as shared libraries into packages (or maybe just one, the "Pony" library). Then, we compile that with 2 flags the "shared" flag and the "dynamic" flag. The first turns the library into a shared library, and the second dynamically links against Base and some other libraries. The dynamic flag is optional, but it makes for a very large dynamic library. However, the dynamic flag is not supported on Windows. Then, we need to write all of the examples to use packages. Compiling with the dynamic flag means that GHC assumes that if a variable or function comes from a different package, it comes from a shared library. Thus, we have shared libraries.

I think that we already have much of what we're doing set up as packages. That means that doing shared libraries shouldn't be that hard. The question is more of one on when we want to spend the time and energy doing so. I think it would be better to wait until we can turn the examples into standalone examples using the pony library, then we can work on getting those dynamically linked.