Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile project that uses plugins with GHC 9.8.1 #2155

Closed
m4dc4p opened this issue Feb 2, 2024 · 7 comments
Closed

Can't compile project that uses plugins with GHC 9.8.1 #2155

m4dc4p opened this issue Feb 2, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@m4dc4p
Copy link

m4dc4p commented Feb 2, 2024

This template is a guide only, feel free add or omit sections as appropriate.

Describe the bug

haskell.nix seems unable to compile a project using the polysemy-plugin with 9.8.1, but the same project can be built with cabal (using GHC installed via ghcup).

I am using MacOS Sonoma (14.2.1).

Steps To Reproduce

The repo at https://github.com/m4dc4p/haskell-nix-9.8 reproduces the problem.

To reproduce, run nix-build. Eventually, compilation will fail with the error:

Building library for test-0.1.0.0..

<no location info>: error:
    Failed to load interface for ‘GHC.Driver.Plugins’.
no unit id matching ‘ghc-9.8.1-inplace’ was found

Using cabal build (with a GHC installed via ghcup), the library does compile.

Additional context

default.nix takes a compiler-nix-name argument, and the project does build successfully with 9.6. (nix-build --argstr compiler-nix-version ghc96 will show. that).

Output for all three types of builds are included in the repo:

  • cabal.out - Shows that cabal can build the library
  • haskell-nix-96.out - Shows that haskell.nix can build the library with GHC 9.6.
  • haskell-nix-98.out - Shows the build failure with GHC 9.8.

Note that I reproduced this bug with two plugins (first, polysemy-plugin, then breakpoint) and the build failed in both cases.

An earlier bug (#2096) mentioned this behavior only occurred when using -fplugin in the cabal file, but here it happens even when using OPTIONS_GHC in the source file.

Here is the content of haskell-nix-98.out in case it helps:

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/pjv9dmysj98hv7y8psr8qs0ki3i83v42-source-root-lib-test
source root is source-root-lib-test
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
Configure flags:
--prefix=/nix/store/xp4dx3sy524fh68lip4fxakz10qmhb8z-test-lib-test-0.1.0.0 lib:test --package-db=clear --package-db=/private/tmp/nix-build-test-lib-test-0.1.0.0.drv-3/tmp.UQbj0NdDDd/lib/ghc-9.8.1/lib/package.conf.d --exact-configuration --dependency=breakpoint=breakpoint-0.1.3.0-47vtNTUqfrv2CUBzz1Y9DC --dependency=ansi-terminal=ansi-terminal-1.0.2-2BqNc65ocHa9MjQf0YNPwR --dependency=ansi-terminal-types=ansi-terminal-types-0.11.5-2a2fmPlNFqF1DlTktOKqnN --dependency=colour=colour-2.3.6-EA4HrM2YyXcEiOsPwT8hJY --dependency=colour=colour-2.3.6-EA4HrM2YyXcEiOsPwT8hJY --dependency=containers=containers-0.6.8-BF5T8j1nt6wFZ2QObZv3OP --dependency=ghc=ghc-9.8.1-92mlnX6DBeJCuIXDEq7pgN --dependency=binary=binary-0.8.9.1-9lCdVEP65H5GTZZtoj7Tga --dependency=bytestring=bytestring-0.12.0.2-5uFzxwiI635Kl8cAv8M0vo --dependency=bytestring=bytestring-0.12.0.2-5uFzxwiI635Kl8cAv8M0vo --dependency=directory=directory-1.3.8.1-BVz0G5efthg8T3yjMBXBrk --dependency=filepath=filepath-1.4.100.4-6CCwe3vrrs2K41ASxAJsYs --dependency=exceptions=exceptions-0.10.7-6pSXCzitm7KEMaXpXZ8zM4 --dependency=mtl=mtl-2.3.1-5knlLISMTSUCeMFmP1LKid --dependency=transformers=transformers-0.6.1.0-DNBHcTfMygjJfIziyxxmzg --dependency=stm=stm-2.5.2.1-6NnRD0WpVKDIiCABQcKiUW --dependency=time=time-1.12.2-4Pf2fTyj17B8XjSRNW4gXI --dependency=unix=unix-2.8.3.0-D4EMilNHDHdFN0ynrY6Fmy --dependency=ghc-boot=ghc-boot-9.8.1-LxLxDg5bNMI5j8QoYWIcg2 --dependency=ghc-heap=ghc-heap-9.8.1-7ZcuGr1at912RxNBhhw7Nq --dependency=ghci=ghci-9.8.1-HNirO0XD90u1CRFZKmU7TY --dependency=hpc=hpc-0.7.0.0-69ZiMuwkkStFNXCeE43VKh --dependency=process=process-1.6.18.0-3wCtVntuQMTDeQG6XWooHM --dependency=semaphore-compat=semaphore-compat-1.0.0-5yEZCV2GhvhACQGXRwZE5l --dependency=haskeline=haskeline-0.8.2.1-54508oHY2uu90IyJi6xT2o --dependency=terminfo=terminfo-0.4.1.6-4sH8hE3ZS9uCJHJP0XXvFk --dependency=pretty-simple=pretty-simple-4.1.2.0-3HJW6icd2LJDR7Oj5dus4M --dependency=prettyprinter-ansi-terminal=prettyprinter-ansi-terminal-1.1.3-FDk6eETZMifDXWxkkr0b0f --dependency=prettyprinter=prettyprinter-1.7.1-3qpod2QeSZuW8EdJO2ntt --dependency=text=text-2.1-8CrHUcaV7TWDMTpHjOxz6D --dependency=text=text-2.1-8CrHUcaV7TWDMTpHjOxz6D --dependency=array=array-0.5.6.0-inplace --dependency=base=base-4.19.0.0-inplace --dependency=deepseq=deepseq-1.5.0.0-inplace --dependency=ghc-bignum=ghc-bignum-1.3-inplace --dependency=ghc-boot-th=ghc-boot-th-9.8.1-inplace --dependency=ghc-prim=ghc-prim-0.11.0-inplace --dependency=integer-gmp=integer-gmp-1.1-inplace --dependency=pretty=pretty-1.1.3.6-inplace --dependency=rts=rts-1.0.2 --dependency=system-cxx-std-lib=system-cxx-std-lib-1.0 --dependency=template-haskell=template-haskell-2.21.0.0-inplace --with-ghc=ghc --with-ghc-pkg=ghc-pkg --with-hsc2hs=hsc2hs --with-gcc=cc --with-ar=ar --with-strip=strip --with-ld=ld --disable-executable-stripping --disable-library-stripping --disable-library-profiling --disable-profiling --enable-static --enable-shared --disable-executable-dynamic --disable-coverage --enable-library-for-ghci --datadir=/nix/store/av1hm26caykzhqxy4h66vlzl2szj3wby-test-lib-test-0.1.0.0-data/share/ghc-9.8.1 
Configuring library for test-0.1.0.0..
@nix { "action": "setPhase", "phase": "buildPhase" }
building
Preprocessing library for test-0.1.0.0..
Building library for test-0.1.0.0..

�[;1m<no location info>: �[;1m�[31merror�[0m�[0m�[;1m:�[0m�[0m�[;1m
    Failed to load interface for ‘GHC.Driver.Plugins’.
no unit id matching ‘ghc-9.8.1-inplace’ was found�[0m�[0m
@m4dc4p m4dc4p added the bug Something isn't working label Feb 2, 2024
@m4dc4p
Copy link
Author

m4dc4p commented Feb 6, 2024

@hamishmack Any thoughts? Seems like a systemic issue with 9.8.1 and plugins when using haskell.nix. There is a test saying "TODO: Remove once polysemy works with ghc. 9.8.1" but I think that was a mistake and the test fails due to a bug in haskell.nix somewhere.

@m4dc4p
Copy link
Author

m4dc4p commented Feb 6, 2024

I added set -x to some build steps so I could see what was executing. The error happens after executing Setup build:

++ /nix/store/qwgq564kfl0rap2ym1bg0snrq62mi97n-default-Setup-setup/bin/Setup build lib:test -j4 --ghc-option=-fPIC --gcc-option=-fPIC
Preprocessing library for test-0.1.0.0..
Building library for test-0.1.0.0..

<no location info>: error:
    Failed to load interface for ‘GHC.Driver.Plugins’.
no unit id matching ‘ghc-9.8.1-inplace’ was found

I wasn't able to re-create at the CLI (going to the builder directory and running that command produced nonsense) but seems like there should be more flags passed?

@hamishmack
Copy link
Collaborator

hamishmack commented Feb 8, 2024

Seems like a systemic issue with 9.8.1 and plugins when using haskell.nix. There is a test saying "TODO: Remove once polysemy works with ghc. 9.8.1" but I think that was a mistake and the test fails due to a bug in haskell.nix somewhere.

It was not a mistake, but polysemy should be compatible now.

I've added #2158. Hydra results will be here.

@hamishmack
Copy link
Collaborator

The master branch is currently behind on hydra, it may be a while before we can get to ifdLevel 3 (where tests are run) on that PR.

@m4dc4p
Copy link
Author

m4dc4p commented Feb 8, 2024

🤔 If that test passes in CI, I'm going to be very confused. It would not pass for me locally.

I pulled your PR, commented out all the tests but "plugin" and ran tests.sh ghc981 nix-build. That plugin test failed for me (M2).

@hamishmack
Copy link
Collaborator

It looks like ghc 9.8.1 changed the boot packages to be -inplace. I think the solver sees this when generating the plan and this is breaking the reinstallableLibGhc setting in haskell.nix.

If you need a work around you may be able to reinstallableLibGhc = false, I got it working in #2158. It needed this fix though.

@m4dc4p
Copy link
Author

m4dc4p commented Feb 9, 2024

I applied those fixes (and pushed to my demo repo) and can confirm my tests now pass under 9.6.4 and 9.8.1. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants