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

Incorrect behaviour of GHC when driven by hie-bios compiled by haskell.nix #553

Closed
expipiplus1 opened this issue Apr 19, 2020 · 5 comments
Closed

Comments

@expipiplus1
Copy link
Contributor

If I compile hie-bios with haskell.nix, when it checks a file which runs reify 'id in a TH splice, the call to reify returns garbage results. A different, incorrect type for id every time (all alpha renamed forall a. b -> c).

Repro case here:

https://github.com/expipiplus1/hie-reload-example/tree/reify

Original issue here haskell/haskell-ide-engine#1744

@angerman
Copy link
Collaborator

angerman commented May 1, 2020

This is indeed quite odd and the first thing I was thinking about was our reduced set of reinstallable libs, but as can be seen in the reproduction example, they have been set back to the stock set of ghc packages. Building ghc should be almost identical, though we do have some patches that upstream Nixpkgs does not have. I somehow doubt that just by building it via components this change would happen.

@expipiplus1
Copy link
Contributor Author

Could it be that using the stock set is causing this?

Couple of notes:

  • This doesn't seem to happen when just running GHC, I can only observe this when running through hie-bios (I haven't tried any other programs using the GHC API, I imagine that it would manifest there too and that this isn't actually hie-bios's fault)
  • This isn't an abstract issue, it does affect code on Hackage, my specific broken library is autoapply however I guess that any TH which depends on type information will not work here.

@expipiplus1
Copy link
Contributor Author

How possible would it be to compile ghc via haskell.nix without any of the extra patches? if only to run the repro case.

@angerman
Copy link
Collaborator

@expipiplus1 depends on the compiler you want but should be relatively straight forward.

The patches are defined here:

ghc-patches = version: let
# Returns true iff this derivation's version is strictly older than ver.
versionLessThan = ver: builtins.compareVersions ver version == 1;
# Returns true iff this derivation's verion is greater than or equal to ver.
versionAtLeast = ver: !versionLessThan ver;
from = start: final.lib.optional (versionAtLeast start);
fromUntil = start: end: final.lib.optional (versionAtLeast start && versionLessThan end);
until = end: final.lib.optional (versionLessThan end);
always = final.lib.optional true;
# Try to avoid reordering the patches unless a patch is added or changed that
# will be applied to most versions of the GHC anyway (reordering the patches
# results in rebuilds of GHC and reduces sharing in /nix/store).
in fromUntil "8.4.4" "8.6" ./patches/ghc/ghc-8.4.4-reinstallable-lib-ghc.patch
++ until "8.6" ./patches/ghc/iserv-move-8.4.1.patch # 6fbe5f274ba84181f5db50901639ae382ef68c4b -- merged; ghc-8.6.1
++ until "8.6" ./patches/ghc/hsc2hs-8.4.2.patch
++ until "8.6" ./patches/ghc/various-8.4.2.patch
++ until "8.6" ./patches/ghc/lowercase-8.4.2.patch
++ until "8.6" ./patches/ghc/cabal-exe-ext-8.4.2.patch
++ until "8.6" ./patches/ghc/ghc-8.4.3-Cabal2201-SMP-test-fix.patch
++ until "8.6" ./patches/ghc/outputtable-assert-8.4.patch
++ fromUntil "8.6" "8.6.4" ./patches/ghc/MR148--T16104-GhcPlugins.patch
++ until "8.6.4" ./patches/ghc/MR95--ghc-pkg-deadlock-fix.patch
++ fromUntil "8.4" "8.6" ./patches/ghc/iserv-autoconf-8.4.1.patch # (same as below, but based on 8.4)
++ fromUntil "8.6" "8.8" ./patches/ghc/iserv-autoconf-8.6.1.patch # 8f9f52d8e421ce544d5437a93117545d52d0eabd -- merged; ghc-8.8.1
++ fromUntil "8.4" "8.6" ./patches/ghc/iserv-cleanup-8.8.1-prepare-8.4.1.patch # (prepare for below; see patch for details)
++ until "8.10" ./patches/ghc/iserv-cleanup-8.8.1.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/250 -- merged; ghc-8.10.1
++ fromUntil "8.4" "8.6" ./patches/ghc/iserv-cleanup-8.8.1-revert-8.4.1.patch # (revert prepare)
++ fromUntil "8.2" "8.8" ./patches/ghc/MR545--ghc-pkg-databases.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/545 -- merged; ghc-8.8.1
++ fromUntil "8.6" "8.8" ./patches/ghc/outputtable-assert-8.6.patch
++ fromUntil "8.6.4" "8.8" ./patches/ghc/ghc-8.6.4-reenable-th-qq-in-stage1.patch
++ until "8.8" ./patches/ghc/0001-Stop-the-linker-panic.patch # https://phabricator.haskell.org/D5012 -- merged; ghc-8.8.1
++ until "8.8" ./patches/ghc/ghc-8.4.3-Cabal2201-allow-test-wrapper.patch # https://github.com/haskell/cabal/pulls/5995 -- merged; cabal-3.0.0 (ghc-8.8.1)
++ until "8.8" ./patches/ghc/ghc-8.4.3-Cabal2201-response-file-support.patch # https://github.com/haskell/cabal/pulls/5996 -- merged; cabal-3.0.0 (ghc-8.8.1)
++ until "8.8" ./patches/ghc/ghc-8.6-Cabal-fix-datadir.patch # https://github.com/haskell/cabal/issues/5862
++ until "8.8" ./patches/ghc/MR196--ghc-pkg-shut-up.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/196 -- merged; ghc-8.8.1
++ from "8.6" ./patches/ghc/mistuke-ghc-err_clean_up_error_handler-8ab1a89af89848f1713e6849f189de66c0ed7898.diff # this is part of Phyx- revamped io-manager.
++ always ./patches/ghc/ghc-add-keepCAFs-to-rts.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/950 -- open
++ always ./patches/ghc/lowercase-8.6.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/949 -- merged; ghc-8.8.1
++ always ./patches/ghc/dll-loader-8.4.2.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/949 -- open
++ always ./patches/ghc/ghc-8.4.3-Cabal2201-no-hackage-tests.patch # ?
++ always ./patches/ghc/MR948--32bit-cross-th.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/948 -- open
++ from "8.8" ./patches/ghc/cabal-host.patch # https://github.com/haskell/cabal/issues/5887
++ fromUntil "8.6.4" "8.8" ./patches/ghc/ghc-8.6.4-prim-no-arm-atomics.patch
++ fromUntil "8.6.4" "8.8" ./patches/ghc/global-offset-table.patch
++ fromUntil "8.6.4" "8.8" ./patches/ghc/global-offset-table-2.patch
++ always ./patches/ghc/respect-ar-path.patch
++ until "8.12" ./patches/ghc/MR2537-use-one-shot-kqueue-on-macos.patch
++ final.lib.optional (version == "8.6.3") ./patches/ghc/T16057--ghci-doa-on-windows.patch
++ final.lib.optional (version == "8.6.3") ./patches/ghc/ghc-8.6.3-reinstallable-lib-ghc.patch
++ final.lib.optional (version == "8.6.4") ./patches/ghc/ghc-8.6.4-reinstallable-lib-ghc.patch
++ final.lib.optional (version == "8.6.5") ./patches/ghc/ghc-8.6.5-reinstallable-lib-ghc.patch
++ final.lib.optional (version == "8.6.5") ./patches/ghc/ghc-8.6.5-atomic-arm-arch.patch
++ final.lib.optional (version == "8.6.5") ./patches/ghc/MR3214-writable-rel-ro-data.patch
++ final.lib.optional (version == "8.8.1") ./patches/ghc/ghc-8.8.1-reinstallable-lib-ghc.patch
++ fromUntil "8.8.2" "8.9" ./patches/ghc/ghc-8.8.2-reinstallable-lib-ghc.patch
++ final.lib.optional (version == "8.6.4") ./patches/ghc/ghc-8.6.4-better-plusSimplCountErrors.patch
++ final.lib.optional (versionAtLeast "8.6.4" && final.stdenv.isDarwin) ./patches/ghc/ghc-macOS-loadArchive-fix.patch
++ final.lib.optional (versionAtLeast "8.4.4" && final.stdenv.isDarwin) ./patches/ghc/ghc-darwin-gcc-version-fix.patch
;

and below that you'll find the compilers. So you could just drop the ghc-patches attribute. For example here:

ghc-patches = ghc-patches "8.6.5"
++ [ D5123-patch haddock-900-patch ];

@michaelpj
Copy link
Collaborator

I suspect this is fairly stale, do reopen if it still happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants