Skip to content

Avoid linking of custom Setup scripts #7393

Open

Description

@bgamari

Describe the bug
Currently custom Setup.hs scripts are compiled and linked into an executable, which is then executed. On many platforms (e.g. Windows) this can be a considerable fraction of the overall package build time due to the high cost of linking.

Ideally we would rather use the bytecode interpreter to execute such one-off executables. I am aware of two reasons why this hasn't been done in the past:

  • the bytecode interpreter has historically supported only a subset of the Haskell language (e.g. lacking support for unboxed tuples).
  • the only convenient way to run a script using the bytecode interpreter is via runghc, which Cabal has no way of reliably locating

With the 9.2 release, GHC's bytecode interpreter will support all Haskell constructs, eliminating the first of these considerations. To eliminate the second I propose that we introduce a new --run mode to GHC. This would be similar to the existing --eval mode, but specialised the use-case of executing a script. For instance, Cabal might run run:

ghc --run Setup.hs -- configure

Thoughts?

Activity

  1. phadej commented on May 12, 2021

    @phadej
    Collaborator

    I think --run is a good idea to have in GHC.

    Whether it's worth investing time into supporting build-type: Custom is another question. With Kmett-verse (#3788) migrated away from it, are they still common in usual install plans?

  2. Mikolaj commented on May 13, 2021

    @Mikolaj
    Member

    Why not do both: add --run to GHC and then remove the need for it in cabal.

    I suppose --run is an obviously useful extension on its own and with some publicity would be picked up by other, nameless, tools.

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