Changes between Version 19 and Version 20 of DynamicByDefault


Ignore:
Timestamp:
Nov 24, 2012 6:54:16 PM (3 years ago)
Author:
igloo
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DynamicByDefault

    v19 v20  
    1010For 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:
    1111 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.
    12  2. GHCi would no longer be able to load modules compiled with `ghc -c`.
    13 
     12 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).
     13
     14Given these 2 issues, we think that if making GHCi use dynamic libraries, we should also make ghc compile the "dynamic way" by default.
    1415
    1516== Bugs ==
     
    3839||[ticket:7357 #7357 GHC.exe gives an internal error while linking vector's Monadic.hs]||no||no||no||no||'''YES'''||no||no||
    3940
     41== Windows ==
     42
     43Currently, 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.
     44
     45We are currently working on this.
     46
    4047== Performance ==
     48
     49There are some performance questions to consider before making a decision.
     50
     51=== Performance of the dynamic way ===
    4152
    4253Full nofib results showing the effect of switching to dynamic-by-default are available for
     
    4556[http://lambda.haskell.org/~igloo/dynamic-by-default/nofib-linux-x86_64.html Linux x86_64] and
    4657[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:
     58
     59(We don't have Windows performance numbers as we don't have dynamic-by-default working on Windows yet).
    4760
    4861Binary sizes are way down across the board, as we are now dynamically linking to the libraries.
     
    108121}}}
    109122
    110 == OS X x86 vs x86_64 ==
     123=== OS X x86 vs x86_64 ===
    111124
    112125Currently, 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.
     
    176189</table>
    177190}}}
     191
     192=== Implications of the performance difference ===
     193
     194If 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).
     195
     196It 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.
     197
     198== Questions ==
     199
     200In summary, we need to answer the following questions:
     201
     202 1. Should we enable dynamic by default on OS X x86_64?
     203 2. Should we enable dynamic by default on OS X x86?
     204 3. Should we enable dynamic by default on Linux x86_64?
     205 4. Should we enable dynamic by default on Linux x86?
     206 5. Should we enable dynamic by default on Windows x86_64?
     207 6. Should we enable dynamic by default on Windows x86?
     208 7. Should we enable dynamic by default on other platforms?
     209 8. For platforms using dynamic by default, should Cabal also install static libraries by default?
     210
     211For 1 and 3, the performance impact appears negligible and some bugs will be fixed, so we would suggest that the answer should be yes.