haskell / haskell/haskell-language-server

c2hs + template-haskell: During interactive linking, GHCi couldn't find the following symbol

Open
#3,742 10 comments 2 reactions 0 assignees View on GitHub
status: needs info type: bug
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
3d 21h
Merged PRs (30d)
13

Description

### Your environment

Which OS do you use?
Linux (Ubuntu)

Which version of GHC do you use and how did you install it?
GHC 9.4.5 from ghcup

How is your project built (alternative: link to the project)?
A cabal project which `build-tool-depends` on c2hs

Which LSP client (editor/plugin) do you use?
VS Code+vscode-haskell

Which version of HLS do you use and how did you install it?
HLS 2.0.0.1 from ghcup

Have you configured HLS in any way (especially: a `hie.yaml` file)?
No, I am using implicit-hie.

### Steps to reproduce

I am yet to test this with a small project, but it seems like HLS, when subject to the application, cannot recognize the symbols from c2hs file.
For reference, `cabal repl` works perfectly fine.

### Expected behaviour

HLS works normally on a file with template-haskell splices, which depends on a c2hs file.

### Actual behaviour

```
haskell-language-server-9.4.5: ^^ Could not load 'zdwaylandzmhszm0zi1zi0zi0zminplacezdGraphicsziWaylandziUtilzdwaylandzzmhszzm0zzi1zzi0zzi0zzminplacezuGraphicszziWaylandzziUtilzumakeDispatcher', dependency unresolved.
```
`Graphics.Wayland.Util` is a .chs file pre-processed by c2hs.

### Debug information

```
2023-08-04T07:45:41.861221Z | Info | updateFileDiagnostics published different from new diagnostics - file diagnostics: File: /home/abastro/Documents/Projects/wayland-projects/wayland-hs/src/Graphics/Wayland/Test.hs
Hidden: no
Range: 1:1-2:1
Source: typecheck
Severity: DsError
Message:
Program error:
GHC.ByteCode.Linker: can't find label
During interactive linking, GHCi couldn't find the following symbol:
zdwaylandzmhszm0zi1zi0zi0zminplacezdGraphicsziWaylandziUtilzdwaylandzzmhszzm0zzi1zzi0zzi0zzminplacezuGraphicszziWaylandzziUtilzumakeDispatcher
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 report this as a GHC bug:
https://www.haskell.org/ghc/reportabug
```

Contributor guide

No contributing guide indexed for this repository

Research direction

First reproduce the failure in the reported Cabal project, comparing HLS on Graphics/Wayland/Test.hs with a working cabal repl session. Inspect the c2hs-generated Graphics/Wayland/Util module and the template-haskell splice that references it. Done means HLS handles the file without the unresolved interactive-linking symbol, ideally with a minimal reproducer or regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.