haskell / haskell/cabal

Way `--enable-library-bytecode` is not honoured by `repl`

Open
#11,981 4 comments 0 reactions 0 assignees View on GitHub
attention: pr-welcome bytecode-artefacts cabal-install: cmd/repl type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**

On cabal HEAD (4f927a126311ecfcb9193b021d8e0e41c7917be0), the way modifier `--enable-library-bytecode` has no impact when run with `repl`

**To Reproduce**

```sh
$ cabal init --lib -n --no-comments
$ cabal repl -w ghc-10.1 --enable-library-bytecode
Warning: Parsing the index cache failed (Data.Binary.Get.runGet at position
Build profile: -w ghc-10.1.20260530 -O1
In order, the following will be built (use -v for more details):
- bytecode-repo-0.1.0.0 (interactive) (lib) (first run)
Configuring library for bytecode-repo-0.1.0.0...
Preprocessing library for bytecode-repo-0.1.0.0...
GHCi, version 10.1.20260530: https://www.haskell.org/ghc/ :? for help
Using language edition: Haskell2010
[1 of 1] Compiling MyLib ( src/MyLib.hs, interpreted )[bytecode-repo-0.1.0.0-inplace]
Ok, one module loaded.
ghci> :q
Leaving GHCi.
```

Calling it twice in a row doesn't work either.

To produce the `.gbc` files, you first need to build the project:

```sh
$ cabal build -w ghc-10.1 --enable-library-bytecode
Build profile: -w ghc-10.1.20260530 -O1
In order, the following will be built (use -v for more details):
- bytecode-repo-0.1.0.0 (lib) (configuration changed)
Configuring library for bytecode-repo-0.1.0.0...
Preprocessing library for bytecode-repo-0.1.0.0...
Building library for bytecode-repo-0.1.0.0...
[1 of 1] Compiling MyLib ( src/MyLib.hs, dist-newstyle/build/x86_64-linux/ghc-10.1.20260530/bytecode-repo-0.1.0.0/build/MyLib.o, dist-newstyle/build/x86_64-linux/ghc-10.1.20260530/bytecode-repo-0.1.0.0/build/MyLib.dyn_o, dist-newstyle/build/x86_64-linux/ghc-10.1.20260530/bytecode-repo-0.1.0.0/build/MyLib.gbc )
```

**Expected behavior**

Calling `cabal repl --enable-library-bytecode` should, in my opinion, generate `.gbc` files. Calling `cabal repl --enable-library-bytecode` twice in a row, the second call should be much faster.

**System information**
- Operating system
- `cabal`, `ghc` versions

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the behavior with the reported cabal init, cabal build, and cabal repl commands, comparing the build and repl handling of --enable-library-bytecode. Trace the cabal repl entry point and the option's build configuration, then verify that repl generates .gbc files and reuses them on a second invocation.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.