haskell / haskell/cabal

Better support for plugins

Open
#7,685 0 comments 0 reactions 0 assignees View on GitHub
re: ghc-plugins
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

To configure a plugin one has to use `ghc-options`. This can be specified per component, e.g. see [this example](https://github.com/coot/ghc-tags-plugin#-cabal) . The drawback of this is that `cabal` is passing these options not only when it compiles modules belonging to the package but it also runs:
```
/home/coot/.ghcup/bin/ghc \
-hide-all-packages \
-c /tmp/128418-0.c \
-o /tmp/128418-1.o -hide-all-packages \
'-plugin-package-id=ghc-tags-plugin-0.3.0.0-942a314601ea96d34f4332b9073d43cbdc47a8c68d4c8460bbac48721b5448d4' \
'-fplugin=Plugin.GhcTags' \
'-fplugin-opt=Plugin.GhcTags:../tags' \
-fno-ignore-asserts
```

This command fails with an expected error:
```
: cannot satisfy -plugin-package-id ghc-tags-plugin-0.3.0.0-942a314601ea96d34f4332b9073d43cbdc47a8c68d4c8460bbac48721b5448d4
(use -v for more information)
/home/coot/.ghcup/bin/ghc returned ExitFailure 1
```

The workaround is to also pass `-package-db` option. This option is not required when `cabal` actually compiles a package, and seems a bit strange at first, but makes sense when starts to analyse where it comes from.

`cabal-install` should either curate the options that it passes to `ghc` when it compiles the temporary `.c` file, or better it should have a proper way to configure plugins. Ideally, it would be a package level configuration as well as a global option, which would allow to configure a plugin globally and allow to set plugin options per package, or allow to configure different plugins for different packages.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.