Introduce build profiles
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
Currently, the `Cabal` library keeps track of whether a package is built with or without optimisations, which avoids optimised and unoptimised builds overwriting eachother's build artifacts. This allows for a reasonable development workflow that interleaves quick unoptimised builds while iterating with occasional slower optimised builds.
However, this is very fragile, as it doesn't cover things like profiling (see #6873) or interpreter-specific options (#3565).
I suggest introducing build profiles, like [Cargo build profiles](https://doc.rust-lang.org/cargo/reference/profiles.html). One would invoke `cabal-install` with a command like
```
> cabal build --profile=dev
```
One core principle of this feature is that it would be a concept that only `cabal-install` knows about. Based on the selected profile, `cabal-install` would pass the appropriate flags to the `Cabal` library (e.g. setting the `distDir`) to avoid builds trampling over eachother. This would have many advantages:
- There would be a single source of truth for where the artifacts live, decided by `cabal-install`. Cabal just puts things where it is told. This makes it easier for tools such as `stack`, as they wouldn't need to know internal details about where `Cabal` places build artifacts.
- The idea plainly makes sense as a per-project concept, not a per-package concept.
Like the `Cargo` feature, it would allow bundling options, e.g. a `development` profile could include additional `+debug` flags to various libraries to enable assertions etc.
Introducing build profiles would also provide a way to change the defaults. Users that do not use build profiles are in "legacy mode" and get a warning about it.
Contributor guide
Research direction
Start by tracing the cabal-install build command and the Cabal library's handling of distDir and optimization state. Compare the proposed --profile=dev flow with the linked Cargo build profiles and review the profiling and interpreter-specific concerns in #6873 and #3565. Done would require an agreed profile design, profile selection, artifact separation, bundled options, and the legacy-mode warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100