commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.98k stars 842 forks source link

stack rebuilds sublibraries that are not dependencies of the specified target #6569

Closed kostmo closed 4 months ago

kostmo commented 4 months ago

Minimal testcase is here: https://github.com/kostmo/stack-sublibrary-rebuild

I am using stack version 2.15.5.

To reproduce the bug

  1. Build the executable:
    stack build bug-repro:exe:bug-repro-exe
  2. Then repeat to ensure all targets are up-to-date.
  3. Insert a newline into src2/Lib2.hs and save
  4. Re-run the above command to build the executable. Observe that files are rebuilt despite that the lib2 sublibrary is not a dependency of bug-repro-exe.

Equivalent cabal test

  1. Build the executable:
    cabal build bug-repro:exe:bug-repro-exe
  2. Then repeat to ensure all targets are up-to-date.
  3. Insert a newline into src2/Lib2.hs and save
  4. Re-run the above command to build the executable. Observe nothing is rebuilt; only "Up to date" is printed.

Potentially related issues

mpilgrem commented 4 months ago

@kostmo, thanks for reporting and for taking the time to create a minimal example.

What you are experiencing is an example of an long-standing issue/feature request known as 'component-based builds'. The most recent open issue pulling that together is:

but there is a long history before that.

In short, Stack currently approaches building in terms of 'packages (with components)' rather than 'components (of packages)'.

I am going to close this issue - not because it is unimportant but because I am seeking to consolidate matters related to component-based builds under a single 'master' issue.