haskell / haskell/cabal

Remove external setup method for non-Custom build type

Open
#2,889 7 comments 0 reactions 0 assignees View on GitHub
cabal-install: other
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

Currently the SetupWrapper module has quite a lot of complexity due to supporting the 'externalSetupMethod' for the case of BuildType Simple/Configure/Make. In particular it has a setup exe cache that is only used in this case.

We can simplify this. Here's the current logic:

```
determineSetupMethod options buildType'
| buildType' == Custom = externalSetupMethod
| not (cabalVersion `withinRange`
useCabalVersion options) = externalSetupMethod
| isJust (useLoggingHandle options)
-- Forcing is done to use an external process e.g. due to parallel
-- build concerns.
|| forceExternalSetupMethod options = selfExecSetupMethod
| otherwise = internalSetupMethod
```

If we call these cases 1-4, my claim is that case 2 is just not necessary. In practice there is no sensible reason for it to happen and so no need to support it. The only case in which we need the externalSetupMethod is for custom Setup.hs, and it doesn't need any setup exe cache.

Why do we have case 2? There's two reasons, one historical and one unnecessary. The historical reason is that there used not to be a case 3, and so case 2 was needed for that. That is, we didn't used to have the 'selfExecSetupMethod' where cabal invokes itself to act as the 'Setup.hs' CLI, so we often had to compile a perfectly ordinary 'Setup.hs' scripts with various versions of the Cabal lib that we could find lying around. So that's the historical reason.

The other reason is that the 'useCabalVersion options' thing. But where does this come from and what values can it take? Internally within the Cabal code we only ever pass in minimum bounds for 'useCabalVersion'. So that never excludes the "current" version of Cabal that cabal-install was built with. The only external source for this is a command line flag `--cabal-lib-version` which is more or less just a debugging or workaround flag. We don't actually need it and it should not hold us back from making things simpler and more robust. For example, we could have it only apply to 'Custom' build type.

So, the task here is to abolish case 2 above. Get rid of 'useCabalVersion' or at least restrict its used to 'build-type: Custom'. And then get rid of the setup exe cache, since it's no longer needed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.