haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.71k stars 368 forks source link

ABI mismatches of GHC bindists #2865

Open hasufell opened 2 years ago

hasufell commented 2 years ago

GHC 9.0.2 on linux and 9.2.2 on windows had missing profiling libs so @mpickering was so kind to supply me with fixed bindists.

These were added to ghcup: https://github.com/haskell/ghcup-metadata/commit/88696a0cc5ebb8fe5b15662f6a840be7c1cdd699

Since profiling seems to affect the ABI, this caused a number of issues:

The latter being that stack with GHC 9.0.2 doesn't work with HLS, because they still use the old bindist without profiling libs, causing ABI mismatch in our wrapper script: https://github.com/haskell/haskell-language-server/blob/6742c205c8386a2898d3a8baa830ecc75713845d/bindist/wrapper.in#L77

This begs the question on how to deal with such diverging ABI. I see a couple of potential solutions:

  1. coordinate bindist updates with stack team
  2. have hls-wrapper binary pick the correct ABI (in addition to correct GHC version) and ship multiple hls binaries, such as haskell-language-server-<ghcver>-<abihash>
  3. somehow integrate better with stack and require users to use ghcup for GHC installation (see https://github.com/commercialhaskell/stack/pull/5585)
  4. make compiling from source more robust, so that e.g. the VSCode extension could compile HLS from source on ABI mismatch instead of giving up

Also note that there may be other cases where ghcup and stack bindists diverge, e.g. because they have different platform detection logic.

hasufell commented 2 years ago

Also note that fixing ABI stability seems to be impossible according to @bgamari due to cross module optimization of GHC, so we're left with fixing this through distribution.

cdepillabout commented 2 years ago

A few other somewhat-related issues that @hasufell pointed me to on Matrix for anyone else interested in this:

hasufell commented 2 years ago

The stack PR with ghc installation hooks was merged... so we should be able to guide users on how to install GHC through ghcup via stack in the future to avoid these types of issues again: https://github.com/commercialhaskell/stack/pull/5585

thisisrandy commented 2 years ago

I'm in the early stages of learning haskell and ran into this issue on my first attempt at creating a project. I asked about it on SO and was eventually pointed to this issue. While I understand the problem well enough, I don't understand the solution, if indeed the GHC installation hooks PR is that. Would you mind laying it out for a newbie with only a vague sense of the haskell toolchain or pointing to existing docs that do just that? I get that your PR was just merged and as such isn't in the latest stack release, and I'm not sure building stack myself is a great idea at this point in my learning exercise, but maybe you could answer assuming the PR has been released or however you think is most appropriate.

hasufell commented 2 years ago

@thisisrandy see https://github.com/haskell/vscode-haskell#ghc-abis-dont-match