Avoid linking of custom Setup scripts
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
Currently custom `Setup.hs` scripts are compiled and linked into an executable, which is then executed. On many platforms (e.g. Windows) this can be a considerable fraction of the overall package build time due to the high cost of linking.
Ideally we would rather use the bytecode interpreter to execute such one-off executables. I am aware of two reasons why this hasn't been done in the past:
* the bytecode interpreter has historically supported only a subset of the Haskell language (e.g. lacking support for unboxed tuples).
* the only convenient way to run a script using the bytecode interpreter is via `runghc`, which `Cabal` has no way of reliably locating
With the 9.2 release, GHC's bytecode interpreter will support all Haskell constructs, eliminating the first of these considerations. To eliminate the second I [propose](https://gitlab.haskell.org/ghc/ghc/-/issues/18011) that we introduce a new `--run` mode to GHC. This would be similar to the existing `--eval` mode, but specialised the use-case of executing a script. For instance, `Cabal` might run run:
```
ghc --run Setup.hs -- configure
```
Thoughts?
Contributor guide
Research direction
Start by tracing how Cabal compiles, links, and executes a custom Setup.hs script, then review the proposed GHC --run mode and the existing runghc and --eval approaches. Done should avoid linking one-off Setup scripts while preserving configure and other Setup.hs command behavior across supported platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100