Skip to content

Cabal repl and cabal build/run conflict over .o object files if ghci has -fobject-code set #3565

@Thra11

Description

@Thra11

Not sure if this is really a cabal issue or a ghci issue, so apologies if it's not a cabal issue.

Using a cabal sandbox, if ~/.ghci contains :set -fobject-code, then both cabal repl and cabal compile haskell sources into .o files located in the same place e.g. dist/build/Package/Module.o. However, despite sharing the file locations, they do not appear to link/load objects built by the other process. Instead, switching from one to the other results in recompiling all the .o files, even if the source file hasn't changed and doesn't depend on a file that has changed.

Just using cabal repl will only recompile the modules affected by changes if you do e.g. :r.
Just using cabal build will likewise only recompile as necessary.
However, switching from one to the other will recompile all modules.

I came across this issue because I was trying to use cabal repl for experimentation as I wrote my code, and cabal run (which effectively performs a cabal build) to run my application.

Disabling -fobject-code in ghci is possible as a workaround, but it's not ideal.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions