Skip to content

Relocatable build tree#12145

Open
LaurentRDC wants to merge 2 commits into
haskell:masterfrom
LaurentRDC:relocatable-build-tree
Open

Relocatable build tree#12145
LaurentRDC wants to merge 2 commits into
haskell:masterfrom
LaurentRDC:relocatable-build-tree

Conversation

@LaurentRDC

@LaurentRDC LaurentRDC commented Jul 22, 2026

Copy link
Copy Markdown

This PR re-purposes the --enable-relocatable flag to make all paths in the build tree relative to the build tree root. This means that the build tree (e.g. dist-newtyle) can be copied wholesale elsewhere (for example, to a git worktree) and promptly be re-used by cabal without re-building.

This behavior can be triggered with cabal build --enable-relocatable, or the project-level configuration option relocatable: True.

Some notes:

  • --enable-relocatable changes plan.json to relativize paths. It's not clear if that's too much of a breaking change.

  • --enable-relocatable is not the default; it is opt-in.

  • --enable-relocatable is backwards compatible, in a sense: older versions of cabal will see a stale build tree, and rebuild, instead of erroring out.

  • --enable-relocatable is only needed for the initial build: the following does not trigger a rebuild:

    $ cabal build --enable-relocatable
    $ cp -R ./dist-newstyle ../some-worktree
    $ cd ../some-worktree
    $ cabal build
    < Up to date >

Fixes #12137

@LaurentRDC
LaurentRDC force-pushed the relocatable-build-tree branch 6 times, most recently from 1fed733 to 7f4f8fa Compare July 23, 2026 14:45
@LaurentRDC
LaurentRDC force-pushed the relocatable-build-tree branch from 7f4f8fa to a64cab1 Compare July 23, 2026 15:38
@LaurentRDC
LaurentRDC marked this pull request as ready for review July 23, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relocatable build tree

2 participants