haskell / haskell/cabal

Confused cabal about when to invoke the build-tool (regression)

Open
#10,909 1 comment 0 reactions 0 assignees View on GitHub
cabal-install: cmd/build re: build-tool type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

This concerns build tools like e.g. `happy`.
Cabal used to ignore a `A.hs` when a `A.y` was next to it and just use the `dist.../A.hs` it created from `A.y` by invoking `happy`.
This is no longer the case, now a local `A.hs` takes prio over the one generated in `dist ...`. See
- #10060

During working on the Agda parser, I found that some changes to the `.y` file did not seem to be picked up by `cabal build`. I also sometimes invoked `happy` in the source tree to get the `.hs` and `.info` files to inspect.
I tracked down the following scenario.
1. Have some project generating a happy parser from `A.y` and do a `cabal run`.
2. Generate the `A.hs` locally and do a `cabal run`.
3. Modify the `A.y` and do a `cabal run`. Cabal will regenerate the `dist.../A.hs` but link the binary against the local `A.hs` (which is unmodified), so the changes in `A.y` aren't actualised.
4. Remove the local `A.hs` and do a `cabal run`. Cabal reports `Nothing to do`, so the changes in `A.y` are still not actualized.

The last step shows that Cabal got into a bad state. The build contract is violated: `A.y` is changed but the compiled binary not.

Contributor guide

Open the contributing guide

Research direction

Reproduce the sequence in the issue with a Happy-generated A.y/A.hs pair, using cabal run after each step. Start by tracing Cabal's generated-source selection and dependency tracking; done means changing A.y regenerates the parser and causes the binary to rebuild even after a local A.hs was created and removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.