Skip to content
This repository was archived by the owner on Jan 2, 2021. It is now read-only.

Fix "expectJust getLinkDeps" error - #212

Closed
jinwoo wants to merge 2 commits into
haskell:masterfrom
jinwoo:linker
Closed

jinwoo wants to merge 2 commits into
haskell:masterfrom
jinwoo:linker

Conversation

@jinwoo

@jinwoo jinwoo commented Nov 27, 2019

Copy link
Copy Markdown
Contributor

The linker crashes because the hm_linkable field of HomeModInfo is
empty. Fill it with correct data.

Fixes https://github.com/digital-asset/ghcide/issues/25.

@cocreature

Copy link
Copy Markdown
Collaborator

Awesome thanks a lot! Can we get some test for this?

@jinwoo

jinwoo commented Nov 27, 2019

Copy link
Copy Markdown
Contributor Author

Sorry I don't have a simple repro and so am not sure how to test this.

@jinwoo

jinwoo commented Nov 27, 2019

Copy link
Copy Markdown
Contributor Author

Both our case and the repro mentioned in https://github.com/digital-asset/ghcide/issues/25 involve GeneralizedNewtypeDeriving and TemplateHaskell, and I tried to create a simple repro using them. But no, I couldn't.

@cocreature

Copy link
Copy Markdown
Collaborator

If there’s no easy way to reproduce this, I’m happy to go without a testcase for now. Looking at the docs of Linkable they state INVARIANT: A valid linkable always has at least one Unlinked item. If this list is empty, the Linkable represents a fake linkable, which is generated in HscNothing mode to avoid recompiling modules.. We seem to be using an empty list here which might be fine since we aren’t doing code generation but it isn’t quite clear to me. Do you know more about this and can help me understand this?

The linker crashes because the hm_linkable field of HomeModInfo is
empty. Fill it with correct data.

Fixes https://github.com/digital-asset/ghcide/issues/25.
@jinwoo

jinwoo commented Nov 27, 2019

Copy link
Copy Markdown
Contributor Author

I'm not really an expert in GHC internals and, as you said, I assumed an empty list is ok because we're not generating code here. I added a comment there.

@ndmitchell

Copy link
Copy Markdown
Collaborator

https://github.com/digital-asset/ghcide/issues/25#issuecomment-530289283 has a minimal reproducible example, and you commented on that ticket that you have a fix for it? If so, could that minimal example become the test? Even if it can't (the dependency on external packages is annoying) could you test that this patch fixes it?

@jinwoo

jinwoo commented Nov 28, 2019

Copy link
Copy Markdown
Contributor Author

I finally succeeded to create a test case. Let me clean it up and upload soon.

@jinwoo

jinwoo commented Nov 28, 2019

Copy link
Copy Markdown
Contributor Author

Added a test, which fails with "expectJust getLinkDeps" without the fix.

But with the fix, I'm getting a different error and I'm not sure how to fix that. Probably it is a separate issue. This same patch did fix our internal code.

@jinwoo

jinwoo commented Nov 28, 2019

Copy link
Copy Markdown
Contributor Author

I also tried from the command-line the repro case in https://github.com/digital-asset/ghcide/issues/25#issuecomment-530289283, and I'm getting a new build error there too as below. Maybe that's because I'm passing an empty list as the linkableUnlinked field of Linkable.

  Program error:
  ByteCodeLink.lookupCE
  During interactive linking, GHCi couldn't find the following symbol:
  Settings_settings_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]

@jinwoo

jinwoo commented Nov 28, 2019

Copy link
Copy Markdown
Contributor Author

I tried filling the linkableUnlinked field as GHC does in https://github.com/ghc/ghc/blob/master/compiler/main/DriverPipeline.hs#L219. But because ghcide doesn't generate .o files, I get errors like Settings.o: getModificationTime:getFileStatus: does not exist (No such file or directory).

I'm not sure whether this new problem always happens with this "fix". If not, the fix would be worth it, but I don't have a good way to prove that.

@merijn

merijn commented Nov 28, 2019

Copy link
Copy Markdown

This does fix the original error, but I run into the ByteCodeLink.lookupCE now too.

@merijn

merijn commented Nov 28, 2019

Copy link
Copy Markdown

I've seen similar errors from ghci in the past, which at the time needed -fobject-code to resolve. On the other hand, ghci seems to be able to load these modules just fine without -fobject-code...

@jinwoo

jinwoo commented Nov 28, 2019

Copy link
Copy Markdown
Contributor Author

@jinwoo

jinwoo commented Dec 2, 2019

Copy link
Copy Markdown
Contributor Author

I'm going to revert this change. This seems to only fix the first symptom. I think the proper fix should be done together with https://github.com/digital-asset/ghcide/issues/34; by generating bytecode for things that are used by Template Haskell, and passing the bytecode as part of the Linkable.

@jinwoo jinwoo closed this Dec 2, 2019
serras added a commit to serras/ghcide that referenced this pull request Dec 6, 2019
@serras serras mentioned this pull request Dec 6, 2019
moritzkiefer-da pushed a commit that referenced this pull request Dec 10, 2019
* First attempt at TH support

* Update TcModuleResult when generating core

* Be a bit more cautious when asking for bytecode

* Check need for bytecode not only in source file itself, also in global information

* Add a test (based on #212)

* Fix test (thanks, @jinwoo)

* Split GenerateCore and GenerateByteCode
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* First attempt at TH support

* Update TcModuleResult when generating core

* Be a bit more cautious when asking for bytecode

* Check need for bytecode not only in source file itself, also in global information

* Add a test (based on haskell/ghcide#212)

* Fix test (thanks, @jinwoo)

* Split GenerateCore and GenerateByteCode
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* First attempt at TH support

* Update TcModuleResult when generating core

* Be a bit more cautious when asking for bytecode

* Check need for bytecode not only in source file itself, also in global information

* Add a test (based on haskell/ghcide#212)

* Fix test (thanks, @jinwoo)

* Split GenerateCore and GenerateByteCode
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
* First attempt at TH support

* Update TcModuleResult when generating core

* Be a bit more cautious when asking for bytecode

* Check need for bytecode not only in source file itself, also in global information

* Add a test (based on haskell/ghcide#212)

* Fix test (thanks, @jinwoo)

* Split GenerateCore and GenerateByteCode
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error "expectJust getLinkDeps"

4 participants