With my beginner mind, I’m thinking we could get a good compromise between speed and size if we forbid cross-library inlining. All inlining to be contained inside a library and no code-leaks to other libraries or executables. I’ve looked a bit for it and it seems to me that cabal/ghc doesn’t have that build option.
The big gain of containing inlining inside library borders is we’ll get true shared libraries. And a hackage binary repo, maybe?
(Much) smaller sizes (less inlining), simplified processes (less compilation, more abstract dependencies), but slower speeds… who knows how slow…?
Cross-library inlining is essential for libraries like parsec, vector, and lens, because they define combinators that should optimize when composed together.
Is there any hope that installing bindists becomes simply unpacking them, without any make to run? This seems to be possible for other toolchains (with less history…)
I have a number of GHC versions on disk (‘official’ versions, installed by Stack) and I drew a graph of their ‘size on disk’ by release date (below). Something odd seems to have happened with GHC 9.10.1 (I deleted it and reinstalled it, so I am pretty sure it is not a mistake on my part):
A MicroHs package with the compiler and base is about 1M. Installed it might be about 3M. This includes sources.
But you pay the price for that in performance, the generated code is about 10 times slower than code from ghc.
On the other hand, the compiler itself is about 10x faster than ghc.
It is and has been for years. As far back as 8.4.4. The ios cross compilers I built back then were just that, unpack and run. Here is a bindist.zip from a recent ghc HEAD checkout. (Credit to @hsyl20).
I’ll use ubuntu as an example here
docker run -it ubuntu bash
and then inside the container (we’ll need curl, gcc, and unzip):
./bin/ghc --interactive
GHCi, version 9.13: https://www.haskell.org/ghc/ :? for help
ghci>
Now there are some caveats about making GHC a bit more resilient to system, and in-flight changes. Unzip and run has been possible for years. (Yes, there are some caveats and technicalities where this can fall apart; and it requires some system features which are not necessarily available on every operating system).
This as well as other changes to GHC bindists is something my team and I are exploring and hope to upstream to GHC eventually.
Have you ever looked what is in debian ghc package ? Most of size are *.hi and *.dyn_hi files. Which are needed when you link anything from base and libraries distributed with ghc.
Same as -devel packages for c/c++ libraries etc. Its debian decision to distribute this file in one package. For example fedora and opensuse have this files in separated subpackages for base and libraries … and you can install only what you really need.