[Haskell-cafe] Build base with stack
Edward Z. Yang
ezyang at mit.edu
Sat Dec 31 02:28:02 UTC 2016
Excerpts from Brandon Allbery's message of 2016-12-30 19:45:46 -0500:
> On Fri, Dec 30, 2016 at 7:37 PM, Robin Palotai <palotai.robin at gmail.com>
> wrote:
> >
> > Do you know a way to force a rebuild of base with stack? I don't want to
> > modify it, just want to feed it through a customized ghc pipeline.
> >
>
> base is part of ghc and must be built along with ghc. It cannot be built
> separately from ghc, regardless of tooling, if you want it to actually work.
>
> (If you want to see some examples of why it is this way, play around with
> RebindableSyntax a bit, paying attention to the ways in which it breaks if
> you do the wrong thing. You can also get some idea of it from the behavior
> of type roles. In short: ghc must know the precise identity *at machine
> level*, not just source, of various key types in base. It can only do this
> by ghc and base being built together so that various types' machine level
> representations can be wired into ghc as they are built.)
Although it is true that GHC is closely tied to the particularities
of base, you CAN swap out base, as long as the new version of base has
all of the wired in entities that GHC expects to see. (This must be
the case, because we build stage 1 GHC before we build base.)
To answer OP's question, I don't know how to do it with Stack but I've
rebuilt base with cabal-install new-build with a little patch. First you have to
modify cabal-install/Distribution/Solver/Modular/Solver.hs,
changing the invocation of P.requireInstalled so that "base" isn't
on the list; this lets cabal-install decide that it can rebuild base.
Then, in your cabal.project, add:
packages: path/to/base
constraints: base +integer-gmp
(The integer-gmp flag is manual so you need to make sure you toggle
it yourself.) Then cabal new-build will build it, and other packages
will make use of it.
Good luck!
Edward
More information about the Haskell-Cafe
mailing list