GHC Trac Home
Working on GHC
Mailing Lists & IRC
All Feature Req's
Tickets I Created
Patches for review
New Feature Req
Forgot your password?
side by side
lines around each change
White space changes
11/24/12 10:54:16 (
For this to work, there is technically no need to change anything else: ghc could continue to compile for the static way by default. However, there are 2 problems that arise:
1. cabal-install would need to install libraries not only for the static way (for use by ghc), but also for the dynamic way (for use by ghci). This would double library installation times and disk usage.
2. GHCi would no longer be able to load modules compiled with `ghc -c`.
2. GHCi would no longer be able to load modules compiled with `ghc -c`. This would violate the principle of least surprise, and would make it harder to work around GHCi's limitations (such as performance, and lack of support for unboxed tuples).
Given these 2 issues, we think that if making GHCi use dynamic libraries, we should also make ghc compile the "dynamic way" by default.
== Bugs ==
||[ticket:7357 #7357 GHC.exe gives an internal error while linking vector's Monadic.hs]||no||no||no||no||'''YES'''||no||no||
== Windows ==
Currently, we don't know how to do dynamic-by-default on Windows in a satisfactory way. We can build dynamic libraries, but we don't have a way of telling them where to find their DLLs. This means that `ghc --make foo; ./foo` won't work unless we copy all the library DLLs into the current directory, which isn't very satisfactory.
We are currently working on this.
== Performance ==
There are some performance questions to consider before making a decision.
=== Performance of the dynamic way ===
Full nofib results showing the effect of switching to dynamic-by-default are available for
[http://lambda.haskell.org/~igloo/dynamic-by-default/nofib-linux-x86_64.html Linux x86_64] and
[http://lambda.haskell.org/~igloo/dynamic-by-default/nofib-linux-x86.html Linux x86]. There is also a table of the highlights below. In summary:
(We don't have Windows performance numbers as we don't have dynamic-by-default working on Windows yet).
Binary sizes are way down across the board, as we are now dynamically linking to the libraries.
OS X x86 vs x86_64
= OS X x86 vs x86_64 =
Currently, some people use the x86 version of GHC on OS X for performance reasons. It's not clear for how much longer this will be viable, as other OS X libraries start dropping x86 support.
=== Implications of the performance difference ===
If GHCi uses dynamic libraries by default, then `ghci` will need to be dynamically linked. It would make sense to therefore also have `ghc` be dynamically linked. This means that any performance difference will also affect the performance of the compiler (this is already accounted for in the "Compile Times" in the nofib results).
It would still be possible to compile programs using the "static way" by giving ghc the `-static` flag, and users would be able to configure `cabal-install` to do so by default if they wish. Then programs would be exactly the same as they are today. However, this would have the drawback that `cabal-install` would need to be configured to install libraries for the static way as well as the dynamic way, so library installation would take twice as long.
== Questions ==
In summary, we need to answer the following questions:
1. Should we enable dynamic by default on OS X x86_64?
2. Should we enable dynamic by default on OS X x86?
3. Should we enable dynamic by default on Linux x86_64?
4. Should we enable dynamic by default on Linux x86?
5. Should we enable dynamic by default on Windows x86_64?
6. Should we enable dynamic by default on Windows x86?
7. Should we enable dynamic by default on other platforms?
8. For platforms using dynamic by default, should Cabal also install static libraries by default?
For 1 and 3, the performance impact appears negligible and some bugs will be fixed, so we would suggest that the answer should be yes.