Skip to content

[RFC] Plugin dependencies #2965

Open
Open

Description

@ezyang

Pursuant to https://ghc.haskell.org/trac/ghc/ticket/11244, it would be preferable for users to stop putting plugin dependencies in build-depends and a new field.

I propose to introduce a new field, plugin-depends, which has the same format as build-depends, but adds dependencies on plugins. Packages specified here:

  1. Do not get put in the depends in the installed package info (so they don't get linked in when you build an executable),
  2. Are passed to GHC 8.0 as -plugin-package-id (with -hide-all-plugin-packages), which forces GHC to only use them to determine scoping of plugin modules, e.g. -fplugin ModName). Previous versions of GHC, they get passed in as normal -package-id flags for backwards compatibility

Activity

  1. 23Skidoo commented on Dec 19, 2015

    @23Skidoo
    Member

    +1, sounds sensible.

    /cc @dcoutts

  2. ezyang commented on Dec 19, 2015

    @ezyang
    ContributorAuthor

    OK, one minor complication here: if a user put a plugin dependency in build-depends, we want this to keep working. But this will stop working if Cabal unconditionally passes -hide-all-plugin-packages to GHC 8.0 or later. Perhaps use of -hide-all-plugin-packages should be toggleable, or maybe based on the version of Cabal dependency declared? (So, if a user requires a recent enough version of Cabal, then we assume that they correctly used ghc-plugins)

  3. 23Skidoo commented on Dec 19, 2015

    @23Skidoo
    Member

    or maybe based on the version of Cabal dependency declared? (So, if a user requires a recent enough version of Cabal, then we assume that they correctly used ghc-plugins)

    I think that's better than adding yet another obscure switch. We'll need a version check for ghc-plugins anyway. We can also hardcode the list of known GHC plugins released on Hackage and warn if a GHC plugin is found in build-depends.

  4. ezyang commented on Mar 31, 2016

    @ezyang
    ContributorAuthor

    I previously claimed that plugin-depends should be implemented similarly to build-tools. But I looked more carefully at build-tools and actually, these are not handled at all by the solver (#220). So build-tools is not a good way of implementing this.

    Instead, we need plugin-depends to be MERGED with build-depends when we are doing dependency solving; from the dependency solver's perspective, there's no distinction between these two fields. (Actually, if we wanted to be a bit more clever, each plugin dependency should be treated like a setup dependency, since it's OK if a plugin uses foo-0.1 but the main library uses foo-0.2: they won't actually interact.)

    Arguably, this field would also be applicable to build-tools: you would specify what executables you depend on build-tools and specify the packages that provide them in plugin-depends (or maybe tool-depends, because we want a more general name). However, it is a bit awful user experience to require users to type in both build-tools: alex; tool-depends: alex so maybe a tool dependency on a package with executables should IMPLY the build-tools on that executable. (One could conceivably have a package which has multiple executables, and you only want to build-tools on one, but that seems awfully remote.)

  5. cartazio commented on Apr 25, 2016

    @cartazio
    Contributor

    i presume this is a cabal > 1.24 feature? :)

  6. 23Skidoo commented on Apr 25, 2016

    @23Skidoo
    Member

    @cartazio Yes, it won't be in 1.24.

  7. tseenshe commented on Oct 21, 2019

    @tseenshe
    Contributor

    I would like to note that this feature request would be very useful to me as a tooling author, see https://gitlab.com/tseenshe/hsinspect

  8. phadej commented on Oct 21, 2019

    @phadej
    Collaborator

    OK, one minor complication here: if a user put a plugin dependency in ...

    This can (and should) be guarded by cabal-version: no problems here.

  9. michaelpj commented on Apr 1, 2020

    @michaelpj
    Collaborator

    It seems to me that rather than plugin-depends we would be better off with native-build-depends. The idea of "native" dependencies is common to many other systems, and it naturally includes build-tools (and arguably setup-depends).

  10. phadej commented on Apr 1, 2020

    @phadej
    Collaborator

    @michaelpj GHC has -plugin-package-id argument, thus plugin-depends. build-tool-depends and plugin-depends are different enough, former are executables, latter are libraries.

  11. michaelpj commented on Apr 1, 2020

    @michaelpj
    Collaborator

    GHC has -plugin-package-id argument, thus plugin-depends

    IMO GHC should also have a separate -native-package-db, but that's another kettle of fish.

  12. phadej commented on Apr 1, 2020

    @phadej
    Collaborator

    @michaelpj yes. I agree with that. And cross-compiler simply should, there is no other way to them even work. I have no idea how you can, or can you at all, use any plugins with cross compiler currently.


    And if template haskell step would ever be separated, then a separate package db & dependencies for that too.

  13. michaelpj commented on Apr 1, 2020

    @michaelpj
    Collaborator

    I have no idea how you can, or can you at all, use any plugins with cross compiler currently.

    I think @angerman has made this work with some hackery, but conceptually plugins make sense as native library dependencies: they're compiled for the host, so can be linked against the (host) GHC.

  14. cdsmith commented on Sep 7, 2021

    @cdsmith

    What is the ghc-plugins referenced in this discussion? I cannot find any mention of it in current Cabal docs. Was it a plan that was abandoned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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