-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Link error when modifying TH #830
Comments
I can reproduce this before the object code PR too. |
This, as well as haskell/ghcide#672 are caused by us not calling This is further complicated by https://gitlab.haskell.org/ghc/ghc/-/issues/16525 , which means that unloading object code is disabled in I have a work in progress fix/workaround here I think merely calling I won't have any time to play around with this for about a week. If anyone wants to pick this up, please feel free to do so. |
If anyone is going to pick this up, here are the things missing from that branch:
|
Unfortunately, GHC #16525 can happen to pretty much anyone as it has to do with the structure of the heap. Currently the GC fails to trace CAF references properly when determining whether it can unload. For this reason we have disabled it. Forcing unloading is likely to eventually result in a crash. I have fixed this in !3842. |
We'll have to go back to bytecode at least in 8.8, 8.10 and possibly 9.0. |
One option is to use bytecode for files of interest and object code for everything else. However, someone has to verify that symbols defined in bytecode shadow symbols defined in object code for this to work (for when a non FOI becomes a FOI). GHCi handles the scenario in the test case just fine with |
What happens when a FOI that used to be a non FOI becomes a non FOI again? |
I don't know, someone has to figure out the semantics of mixing bytecode and object code, either by reading the source or implementing it. I tried writing unique object code filepaths for each version of the document and discovered that this won't work. Instead of one Linkable shadowing the other, we get |
Another option I was discussing with @bgamari was distributing binaries of ghcide/hls built against GHC 8.*.* with !3842 applied. Since the patch doesn't affect code generation, it should be able to read package dbs of the original GHC just fine. Cons are making ghcide/hls development/building from source harder (or maybe not, development binaries just won't work very well with TH). |
Another discussion with @bgamari reveals that GHCi is probably using the dynamic system linker, not the RTS linker. When we load object files dynamically with the system linker, the likely behavior is that the newest object wins and shadows all the previous ones (which is what we want). We can do the same in ghcide as a workaround. |
To make ghcide use the system linker we would need to build it with That's easy enough for local builds but I suspect it will complicate the distribution of binaries in HLS. Also, I don't think the system linker supports any form of unloading. /cc @bgamari @simonmar |
Bytecode itself can be serialised.
I haven't thought hard about where the right place in this pipeline would be to persist bytecode. |
|
Does the note below not apply or is it out of date ?
|
It will not apply after ghc!3842 is merged but this hasn't happened yet. In light of the fact that unloading being disabled seems to break ghcide I am somewhat inclined to expedite this process. |
Ok so ghc!3842 makes that note obsolete but won't be available until 9.2. What about the backport in https://github.com/facebook/fbghc/commits/ghc-8.8.3-facebook ? |
It's not so much a backport as another, slightly broken, version of the same thing. I started from that patch, refactored it, and fixed various GC bugs that it triggered. |
Going over the source, as long as the ByteCode symbols are in the ClosureEnv in the PersistentLinkerState, they will shadow symbols defined in object code. Calling |
Thinking some more, that scheme wouldn't work. Every non-FOI depending on a
FOI would need to use bytecode too.
…On Fri, 9 Oct, 2020, 01:41 Ben Gamari, ***@***.***> wrote:
Ok so ghc!3842 makes that note obsolete but won't be available until 9.2.
What about the backport in
https://github.com/facebook/fbghc/commits/ghc-8.8.3-facebook ?
It's not so much a backport as another, slightly broken, version of the
same thing. I started from that patch, refactored it, and fixed various GC
bugs that it triggered.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://github.com/haskell/ghcide/issues/854#issuecomment-705797101>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABEW5UXEMI4UBCZZEFMJLCDSJYMHBANCNFSM4SHSZ4OQ>
.
|
The error goes away if we use All the other tests seem to pass. |
I can make the plugin tests pass by unsetting @bgamari can anything go wrong if we mix together the internal and external interpreters in the same session? |
@wz1000 Can we expect the external interpreter to put up with ghcide calling it concurrently and abruptly cancelling computations? I suspect we'd need one external interpreter per normalised filepath but I don't know if that's possible |
@pepeiborra No idea, it seems to work fine when I'm using it in vscode. Perhaps we can mask exceptions when running TH using |
When modifying TH, it is easy to run into linker errors:
Test here: haskell/ghcide#853
The text was updated successfully, but these errors were encountered: