Haskell-language-server: Linking issue with Template Haskell that depends on C code

Created on 31 Aug 2020  路  7Comments  路  Source: haskell/haskell-language-server

On Windows, when trying to use the VSCode plugin on accelerate. HLS works as expected on other codebases.

I get the following, identical, errormessage on the Bool.hs, Either.hs, Maybe.hs and Ordering.hs files:

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

All four of these files apply the TH function mkPattern from Pattern/TH.hs on these Prelude datatypes.

As a result, it seems (looking at the verbose output in VSCode) that HLS always responds to queries in this package (hover, go to definition, etc), even unrelated to these patterns, with null or [].

ghcide blocked upstream bug template haskell related

Most helpful comment

All 7 comments

Some more details:

Apparently, this issue has to do with the TH code depending on C code, which means it must be built before compiling the TH module. It seems that HLS somehow messes up this ordering, whilst stack repl does work. Apparently Cabal has the same problem. Adding an hie.yaml did not help either.

This issue also persists using an ubuntu VM via WSL2, which further indicates it's not a Windows problem.

I also just noticed that, in the modules that don't (transitively) depend on this TH function executing (in particular, the module where the TH function is defined), hls does work!

There is no cradle in your repro. Could you please define one and test again? Test both with the Cabal and Stack cradles.

For this to work, the C object needs to be listed in the flags provided by hie-bios for the cradle

  • stack repl: works
  • cabal repl: doesn't work
  • simple cradle (both stack and cabal): don't work

where with 'simple cradle' I mean an hie.yaml file containing
cradle: stack: component: "hls-bug:lib"
or
cradle: cabal: component: "lib:hls-bug.

What flags could list the C file?

Maybe it will be fixed with TH full support: https://github.com/haskell/ghcide/pull/836

@dpvanbalen

What flags could list the C file?

The ghc flags that the component hie-bios provides to haskell-language-server, needed for load those files .
does cabal repl/stack repl work for the project? It it is so please include the log of executing haskell-language-server-wrapper --debug in the project root dir

I don't think this would work right now, I think we need to compile the foreign files like this:

https://hackage.haskell.org/package/ghc-8.10.1/docs/src/DriverPipeline.html#local-6989586621681024042

This would need an issue in ghcide

Was this page helpful?
0 / 5 - 0 ratings