Eliminate `stg_stackDecode` and implement stack decoding via iterator based decoder
Closes #24013 (closed)
The stack decoding logic in ghc-heap is more sophisticated than the one
currently employed in CloneStack. We want to use the stack decoding
implementation from ghc-heap in base.
We cannot simply depend on ghc-heap in base due do bootstrapping
issues.
Thus, we move the code that is necessary to implement stack decoding to
ghc-internal. This is the right location, as we don't want to add a
new API to base.
Moving the stack decoding logic and re-exposing it in ghc-heap is insufficient, though, as we have a dependency cycle between.
- ghc-heap depends on stage1:ghc-internal
- stage0:ghc depends on stage0:ghc-heap
To fix this, we remove ghc-heap from the set of stage0 dependencies.
This is not entirely straight-forward, as a couple of boot dependencies,
such as ghci depend on ghc-heap.
Luckily, the boot compiler of GHC is now >=9.10, so we can migrate ghci
to use ghc-internal instead of ghc-heap, which already exports the
relevant modules.
However, we cannot 100% remove ghc's dependency on ghc-heap, since
when we compile stage0:ghc, stage1:ghc-internal is not yet
available.
Thus, when we compile with the boot-compiler, we still depend on an
older version of ghc-heap, and only use the modules from ghc-internal,
if the ghc-internal version is recent enough.