Skip to content

register fails if -fplugin=Foo is used in ghc-options: #9375

Closed
@hamishmack

Description

@hamishmack

With ghc >=9.6 --abi-hash initialises plugins and will fail if a module in -fplugin=Foo.

$ ghc-9.4.7 --abi-hash -fplugin=Foo
921dcb31e865da25523dc30d4957f9c4
$ ghc-9.6.3 --abi-hash -fplugin=Foo
<command line>: Could not find module ‘Foo’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.

This causes problems because the fix for #3633 removes the package DB from the arguments passed when calling ghc --abi-hash.

The code is here:

    vanillaArgs =
      -- Package DBs unnecessary, and break ghc-cabal. See #3633
      -- BUT, put at least the global database so that 7.4 doesn't
      -- break.
      vanillaArgs0
        { ghcOptPackageDBs = [GlobalPackageDB]
        , ghcOptPackages = mempty
        }

To reproduce this issue with cabal-install and ghc 9.6.3 in the path:

$ cat test.cabal
cabal-version:      3.4
name:               test
version:            0.1.0.0
build-type:         Simple

library
    exposed-modules:  MyLib
    build-depends:    base, polysemy, polysemy-plugin
    ghc-options:      -Wall -fplugin=Polysemy.Plugin
    hs-source-dirs:   src
    default-language: Haskell2010
$ cat src/MyLib.hs
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
$ cabal v1-install .
Resolving dependencies...
Starting     test-0.1.0.0
Building     test-0.1.0.0
Failed to install test-0.1.0.0
Build log ( /Users/hamish/.cabal-devx/logs/ghc-9.6.3/test-0.1.0.0-2vHb5qpV3rnA1Gux1WyweH.log ):
cabal: Entering directory '.'
Configuring test-0.1.0.0...
Preprocessing library for test-0.1.0.0..
Building library for test-0.1.0.0..
Installing library in /Users/hamish/.cabal-devx/lib/x86_64-osx-ghc-9.6.3/test-0.1.0.0-2vHb5qpV3rnA1Gux1WyweH
Error: cabal: '/nix/store/9drimq6n088xzlpk56hc9k6zb7a46qch-ghc-9.6.3/bin/ghc'
exited with an error:
<command line>: Could not find module ‘Polysemy.Plugin’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.

cabal: Leaving directory '.'
Error: cabal: Some packages failed to install:
test-0.1.0.0-2vHb5qpV3rnA1Gux1WyweH failed during the final install step. The
exception was:
ExitFailure 1

This problem does not seem to affect cabal v2-build, but it does break haskell.nix (input-output-hk/haskell.nix#2096).

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