You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to synthesise one ticket that describes all the TH work. My understanding of the current state is:
If you have TH or ANN pragmas, and they all refer to code that is imported by packages or in this module, it works.
If you refer to other modules in this package it breaks, perhaps with haskell/ghcide#25.
The solution is likely to make sure we have compiled the dependencies to bytecode and send them at the linker before type checking a module that uses TH or ANN.
However, we don't have tests for the current state, and it works by luck rather than deliberately.
Reacted by Joshua Booth, Ollie Charles, Steven MacCoun, Domen Kožar, Akshay Mankar, Zsolt Szende, Emily, Henri Maurer, T. Hopia and Flavio Corpa
I've noticed a huge slowdown when TH is enabled. After some searching I've noticed the folks at hie-engine ran into what looks like the same issue (HIE github issue), which was fixed in Infinisil/all-hies
by dynamically linking HIE (infinisil/all-hies#3). That PR says dynamic linking may not be necessary in for ghc versions with a fix to this GHC issue.
Hi, anyone is in a position to estimate how much work this would entail? Since my team started using ghcide we can’t imagine going back to the stone age ever. You guys did an amazing job! On our end TH support seems to be the last big issue that’s in the way of full adoption.
Reacted by Henri Maurer, Merijn Verstraaten, Domen Kožar, Matthew Hoare, Steven MacCoun, Mitchell Dalvi Rosen, T. Hopia, Alexis King and Flavio Corpa
Figure out which modules require TH, nice and easy.
For those that do, first build all the dependencies to object code (moderate amount of work, probably < 100 lines, fits fairly well with the graph approach).
Then send that object code to the linker (dunno how hard this is, might have problems with state management).
So probably not obviously hard, but I'd almost be surprised if something didn't get in your way.
I have started working on the issue at serras/ghcide@90c784b in a quite crude way, asking to compile all dependencies even if the file does not use Template Haskell.
Now I get errors which look the ones in haskell/ghcide#212, even though now I am loading some bytecode:
File: ./src/B.hs
Range: 1:0-100001:0
Source: typecheck
Severity: DsError
Message:
Program error:
ByteCodeLink.lookupCE
During interactive linking, GHCi couldn't find the following symbol:
A_a_closure
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session. Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
[email protected]
Is there any way I can check which rules are firing? At least I can be sure that the bytecode for A.hs is generated before continuing my investigation.
Reacted by Merijn Verstraaten, Flavio Corpa, Diego Alonso and Steven MacCoun
I was testing out this PR and run into similar errors about a missing _closure despite said close being in the relevant library being loaded when I inspect it via nm. Is there a way I can see the ghci configuration ghcide is using to load things?
Yeah, I'm seeing similar errors, and I have some suspicions but I'm not really sure enough how to debug ghcide to investigate further. Essentially, I seem to have both a static library (missing some symbols) and a dynamic library (not missing said symbols) in my dist-newstyle and ghcide seems to try to use the static one, but I'm not really sure why.
We don’t do anything explicit atm wtr to linking external libraries in our code. I was hoping that this just magically works™ if we setup the GHC API with the right flags but it looks like we need to figure out the right incantation.
I've been trying to find the right incantation with explicit -l/-L flags in hie.yaml, but so far no luck, but I've also going about it a bit blind since I don't actually know how ghcide sets up it's GHC session
Ghcide uses hie-bios to set up its session, which essentially dumps command line flags into a GHC session. If flags work in ghci, my experience is it usually works in ghcide too.
ghci seems perfectly happy to work with just .ghc.environment, but I'm seeing all sorts of weird missing symbol errors in ghcide that I can't quite explain. I don't mind digging a bit deeper trying to debug them, but I'm rather unsure/clueless on where to start.
@merijn yeah, .ghc.environment is entirely ignored by everything else, so you'll have to replicate that on the command line. FWIW, I turn off the GHC environment files because they cause lots of confusing behaviour with tools working differently in different places.
I was under the impression that ghcide used them to find dependencies? Because that seems to work fine in most of my simple-ish projects. I do have a hie.yaml to resolve the look source paths, but I'm always a bit mystified what else has to go in there.
@merijn nope, ghcide doesn't look at those files at all. It only uses cabal/stack as configured by hie-bios. In many cases cabal/stack will know the same information as those environment files.
Ah, so maybe that's where things go wrong, because in other projects I haven't had to use a hie.yaml to set things up! I'll start fiddling with hie-bios
Activity
cocreature commentedon Sep 11, 2019
I have also seen some issue around async exceptions and TH which seemed to make GHC very unhappy (I don’t recall the precise error message).
DavidEichmann commentedon Sep 12, 2019
I've noticed a huge slowdown when TH is enabled. After some searching I've noticed the folks at hie-engine ran into what looks like the same issue (HIE github issue), which was fixed in Infinisil/all-hies
by dynamically linking HIE (infinisil/all-hies#3). That PR says dynamic linking may not be necessary in for ghc versions with a fix to this GHC issue.
pwm commentedon Oct 4, 2019
Hi, anyone is in a position to estimate how much work this would entail? Since my team started using ghcide we can’t imagine going back to the stone age ever. You guys did an amazing job! On our end TH support seems to be the last big issue that’s in the way of full adoption.
ndmitchell commentedon Oct 4, 2019
My guess is you need to:
So probably not obviously hard, but I'd almost be surprised if something didn't get in your way.
domenkozar commentedon Dec 2, 2019
@DavidEichmann in case you were using ghcide-nix, that has been fixed now.
serras commentedon Dec 4, 2019
I would like to tackle this issue, since out team uses TH in quite some places.
Is there any further information that I can read to work on this?
ndmitchell commentedon Dec 4, 2019
None that I'm aware of @serras - but best of luck!
serras commentedon Dec 5, 2019
This seems to be related https://gitlab.haskell.org/ghc/ghc/issues/8025, at least it ends up with the same error as haskell/ghcide#212
serras commentedon Dec 5, 2019
I have started working on the issue at serras/ghcide@90c784b in a quite crude way, asking to compile all dependencies even if the file does not use Template Haskell.
Now I get errors which look the ones in haskell/ghcide#212, even though now I am loading some bytecode:
Is there any way I can check which rules are firing? At least I can be sure that the bytecode for
A.hsis generated before continuing my investigation.cocreature commentedon Dec 6, 2019
You can use shake profiling to figure out the rules, see https://github.com/digital-asset/ghcide/blob/master/src/Development/IDE/Types/Options.hs#L44 (I think this is not exposed via the CLI so you’ll have to set it in the code somewhere) but that’s more useful for benchmarking than for debugging imho. I would probably just use some printf statements in the rules.
merijn commentedon Dec 10, 2019
I was testing out this PR and run into similar errors about a missing _closure despite said close being in the relevant library being loaded when I inspect it via
nm. Is there a way I can see the ghci configuration ghcide is using to load things?domenkozar commentedon Dec 11, 2019
I'm seeing the following using these changes:
https://github.com/hercules-ci/hercules-ci-agent
merijn commentedon Dec 11, 2019
Yeah, I'm seeing similar errors, and I have some suspicions but I'm not really sure enough how to debug ghcide to investigate further. Essentially, I seem to have both a static library (missing some symbols) and a dynamic library (not missing said symbols) in my
dist-newstyleand ghcide seems to try to use the static one, but I'm not really sure why.merijn commentedon Dec 11, 2019
I'm trying to trick it into loading the dynamic library to see if that works, but that's not working :\
cocreature commentedon Dec 11, 2019
We don’t do anything explicit atm wtr to linking external libraries in our code. I was hoping that this just magically works™ if we setup the GHC API with the right flags but it looks like we need to figure out the right incantation.
merijn commentedon Dec 11, 2019
I've been trying to find the right incantation with explicit
-l/-Lflags inhie.yaml, but so far no luck, but I've also going about it a bit blind since I don't actually know how ghcide sets up it's GHC sessionndmitchell commentedon Dec 12, 2019
Ghcide uses hie-bios to set up its session, which essentially dumps command line flags into a GHC session. If flags work in ghci, my experience is it usually works in ghcide too.
merijn commentedon Dec 12, 2019
@ndmitchell I wish :)
ghci seems perfectly happy to work with just
.ghc.environment, but I'm seeing all sorts of weird missing symbol errors in ghcide that I can't quite explain. I don't mind digging a bit deeper trying to debug them, but I'm rather unsure/clueless on where to start.serras commentedon Dec 12, 2019
@merijn you can have a look at
hie-biosdocumentation and try to turn your current.ghc.environmentconfiguration into ahie.yamlfile.ndmitchell commentedon Dec 12, 2019
@merijn yeah,
.ghc.environmentis entirely ignored by everything else, so you'll have to replicate that on the command line. FWIW, I turn off the GHC environment files because they cause lots of confusing behaviour with tools working differently in different places.merijn commentedon Dec 12, 2019
I was under the impression that ghcide used them to find dependencies? Because that seems to work fine in most of my simple-ish projects. I do have a hie.yaml to resolve the look source paths, but I'm always a bit mystified what else has to go in there.
ndmitchell commentedon Dec 13, 2019
@merijn nope,
ghcidedoesn't look at those files at all. It only usescabal/stackas configured by hie-bios. In many cases cabal/stack will know the same information as those environment files.merijn commentedon Dec 13, 2019
Ah, so maybe that's where things go wrong, because in other projects I haven't had to use a hie.yaml to set things up! I'll start fiddling with
hie-bioscocreature commentedon Dec 13, 2019
As far as I know, we do pick up
.ghc.environmentfiles. The GHC API behaves like GHC itself in that it picks them up implicitly by default.ndmitchell commentedon Dec 13, 2019
API's being influenced by random environment files scares me. The more I see about these environment files, the less I like them!