Skip to content

Commit

Permalink
Ghc 9.0.1 support for ghcide (#1649)
Browse files Browse the repository at this point in the history
* hie-compat: Add basic support for ghc-9.0.1

A tiny step towards #297

* hie-compat: Remove dependency on ghc-api-compat

* hie-compat: Add more backwards compatability

* Import a bunch of upstream ghc9 fixes

* cabal.project: allow-newer: *:*

The lazy solution to making things compile

* Add more upstream fixes

* Bump patch of ghc-check

* ghcide: Add basic support for GHC-9.0.1

I tried to limit the use of CPP to the Compat module as much as possible
by re-exporting the new functions under the old names,
but there is still plenty of pragmas all over the code.

I'm using ghc-api-compat so the imports doesn't need to be changed as much.

* ghcide: Fix backwards compatability with ghc-8.8.4

* ghc9-ghcide: Fix some more issues that caused runtime errors

* Restore initDynLinker for older versions of ghc

It was probably important for something

* Fix ghc-8.6.5 compatability

* Fix completion test failures for ghc9

With this example:
f asdfgh = asd

it would suggest to complete `asd` into `asd_arNC`,
which seems to be a name it generated because of
deferred-out-of-scope-variables

* Ghc-check now supports ghc-9.0.1

* Retrie now supports ghc-9.0.1

But it's not on hackage yet.

* Restore retrie orphans

* tests: Ghc9 shows [Char] as String by default

This seems like an improvement, so just update the test-suite

* tests: Ghc9 shows TH-errors after the dollar sign

Instead of including it like older versions did

$(foo)
  ~~~~
  some TH error/warning

* Fix two more test failures

- GHC9 uses a more lenient haddock parser
- TH2.17 has polymorphic Q monad with a type class

* ghc9: Fix "Remove redundant imports" code action

In ghc9, only the specific unused function is highlighted,
instead of the whole line.

* ghcide-tests: Show errors where they are caused

instead of deep inside some generic helper function

* Only use nub on SrcSpan for ghc>=9

* Remove more CPP pragmas

* Remove a bit more CPP

This could almost be handled by ghc-api-compat,
but if it was imported from TyCoPpr, it doesn't work with
ghc < 8.10

* Update stack files to support new versions

* Use the version of retire on hackage

The new version is now released

* Don't use allow-newer: *:*

* ghcide-tests: Enable test no longer broken in ghc9

* Update hiedb version for ghcide

* Adjust for a minor change in test output for ghc9

* Fix benchmark test for ghc9

Cabal-3.2 is not buildable on ghc9, but 3.4 is builable on older ghc.

* Mark minor issues as broken for ghc9

Ghc9 highlights both the constructor and the other fields

Maybe this should just be accepted and not seen as broken?

* haddock-comments-plugin: Ghc9 support

* hls-eval-plugin: Partial ghc9 support

* WIP: hls-eval-plugin: Partial ghc9 support

* hls-explicit-imports-plugin: Add ghc9 support

Now ignores any imports with Unhelpful locations,
since we can't make a map of SrcLoc

* hls-retrie-plugin: Add ghc9 support

* hls-hlint-plugin: Add ghc9 support

* Fix backwards compatability of hlint plugin

* Fix stack builds

(Broken by previous hlint fixes)

* Disable tests when their required plugins are disabled

Not all plugins are supported on ghc9 yet, but we
still want to run the tests for the supported parts

* ghc9: Fix module name plugin

* Add a stack file and run tests for ghc9 in ci

* Add missing packages to ghc-9 stack

* Resolve rebase issues

Maybe it's better to create merge commits instead?

* Allow newer for more packages so cabal stops complaining

These aren't really working, but since they are dependencies
of packages in the `packages:` section
the resolver won't allow us to build anything without this, even if
those plugins are disabled.

* Replace MIN_GHC_API_VERSION with MIN_VERSION_ghc

* Revert incorrect change to hlint code

* Remove remaining traces of GHC_LIB flag

* Add back ghc 9 to github workflow

* Revert "Add back ghc 9 to github workflow"

This reverts commit c465a1e.

* hie-compat: Add basic support for ghc-9.0.1

A tiny step towards #297

* hie-compat: Remove dependency on ghc-api-compat

* hie-compat: Add more backwards compatability

* Disable CI for ghc9

* Use newer version of apply-refact

* Don't needlessly duplicate code from ghc

* hie-compat: Reexport the original version of HieBin

* Don't include broken "allow-newer"s

* FIx stack build for ghc9

* Fix warning from imperfect merge commit

* Don't needlessly duplicate code from ghc

* hie-compat: Reexport the original version of HieBin

* Add missing ghc-api-compat

* Fix ghc9 build for ModuleName

* Add more conditionals on flags for tests

* Add a separate cabal.project file for ghc9

As far as I know, this is the only way to disable the packages who's
dependencies doesn't compile in GHC9 yet.

* Fix and re-enable CI for GHC9

* Remove accidental non-breaking space

* Fix CI build for ghc9

Since we are changing the flags for haskell-language-server,
which CI renames to hls,
we need to use the shortened name in those flags as well

* Run tests for ghc9 in CI

* Minor CI changes

* Use proper values when enriching hie

* Don't try to test hls-refine-imports-plugin on ghc9

* Update comment about ghc9 crashing on initDynLinker

* setSessionDynamicFlags to prevent ghc9  from crashing

The only way to set the dynamic linker is with the function `setSessionDynFlags`
so we call it with the result from `getSessionDynFlags` to give it a
(hopefully sensible) argument.

See also this commit:
https://gitlab.haskell.org/ghc/ghc/commit/18757cab04c5c5c48eaceea19469d4811c5d0371

* Revert "setSessionDynamicFlags to prevent ghc9  from crashing"

This reverts commit 4065ac8.
That change made the "ghcide.cradle.muli" tests fail.

* Simplify logic in hls-hlint-plugin.cabal

* Add comment on OldRealSrcSpan

* Remove source overrides for non-ghc9 builds in cabal.project

* Remove commented out code

Co-authored-by: Pepe Iborra <pepeiborra@me.com>

* Remove resolved question from comment

"This code is only concerned with extracting argument names, so I don't see how multiplicity would be relevant here"
#1649 (comment)

* ghc9: Update to latest version of LSP per

* cabal-ghc901.project: Remove commented out code

* Update the lsp commit hash for stack as well

* Use a version of lsp without haskell/lsp#326

That patch was causing test failures, but the issues
should be fixed for real at some point, so that patch can be incluede

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
Co-authored-by: Pepe Iborra <pepeiborra@me.com>
  • Loading branch information
3 people committed Jun 6, 2021
1 parent 41bf8b8 commit 0b3bb10
Show file tree
Hide file tree
Showing 60 changed files with 1,353 additions and 260 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ jobs:
- STACK_FILE: "stack-8.10.4.yaml"
<<: *defaults

ghc-9.0.1:
environment:
- STACK_FILE: "stack-9.0.1.yaml"
<<: *defaults

ghc-default:
environment:
- STACK_FILE: "stack.yaml"
Expand All @@ -121,4 +126,5 @@ workflows:
- ghc-8.10.2
- ghc-8.10.3
- ghc-8.10.4
- ghc-9.0.1
- ghc-default
30 changes: 19 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ jobs:
strategy:
fail-fast: true
matrix:
ghc: ["8.10.4", "8.10.3", "8.10.2", "8.8.4", "8.8.3", "8.8.2", "8.6.5", "8.6.4"]
ghc: ["9.0.1", "8.10.4", "8.10.3", "8.10.2", "8.8.4", "8.8.3", "8.8.2", "8.6.5", "8.6.4"]
os: [ubuntu-latest, macOS-latest]
include:
# only test supported ghc major versions
- os: ubuntu-latest
ghc: '9.0.1'
test: true
- os: ubuntu-latest
ghc: '8.10.4'
test: true
Expand Down Expand Up @@ -70,7 +73,7 @@ jobs:
uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: "3.2"
cabal-version: "3.4"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: ./fmt.sh
Expand All @@ -88,6 +91,11 @@ jobs:
echo "CABAL_STORE_DIR=~/.cabal/store" >> $GITHUB_ENV
echo "CABAL_PKGS_DIR=~/.cabal/packages" >> $GITHUB_ENV
# Needs to be before Cache Cabal so the cache can detect changes to the modified cabal.project file
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.ghc == '9.0.1' }}
name: Use modified cabal.project for ghc9
run: cp cabal-ghc901.project cabal.project

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Cache Cabal
uses: actions/cache@v2
Expand All @@ -112,7 +120,7 @@ jobs:
run: |
sed -i.bak -e 's/haskell-language-server/hls/g' \
-e 's/haskell_language_server/hls/g' \
haskell-language-server.cabal
haskell-language-server.cabal cabal.project
sed -i.bak -e 's/Paths_haskell_language_server/Paths_hls/g' \
src/**/*.hs exe/*.hs
Expand Down Expand Up @@ -146,38 +154,38 @@ jobs:
# instances to be spun up for the poor github actions runner to handle
run: cabal test wrapper-test --test-options="-j1" || cabal test wrapper-test --test-options="-j1" || cabal test wrapper-test --test-options="-j1"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }}
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
name: Test hls-brittany-plugin
run: cabal test hls-brittany-plugin --test-options="-j1 --rerun-update" || cabal test hls-brittany-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-brittany-plugin --test-options="-j1 --rerun"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }}
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
name: Test hls-class-plugin
run: cabal test hls-class-plugin --test-options="-j1 --rerun-update" || cabal test hls-class-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-class-plugin --test-options="-j1 --rerun"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }}
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
name: Test hls-eval-plugin
run: cabal test hls-eval-plugin --test-options="-j1 --rerun-update" || cabal test hls-eval-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-eval-plugin --test-options="-j1 --rerun"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }}
name: Test hls-haddock-comments-plugin
run: cabal test hls-haddock-comments-plugin --test-options="-j1 --rerun-update" || cabal test hls-haddock-comments-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-haddock-comments-plugin --test-options="-j1 --rerun"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }}
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
name: Test hls-splice-plugin
run: cabal test hls-splice-plugin --test-options="-j1 --rerun-update" || cabal test hls-splice-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-splice-plugin --test-options="-j1 --rerun"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }}
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
name: Test hls-stylish-haskell-plugin
run: cabal test hls-stylish-haskell-plugin --test-options="-j1 --rerun-update" || cabal test hls-stylish-haskell-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-stylish-haskell-plugin --test-options="-j1 --rerun"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }}
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
name: Test hls-fourmolu-plugin
run: cabal test hls-fourmolu-plugin --test-options="-j1 --rerun-update" || cabal test hls-fourmolu-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-fourmolu-plugin --test-options="-j1 --rerun"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }}
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
name: Test hls-tactics-plugin test suite
run: cabal test hls-tactics-plugin --test-options="-j1 --rerun-update" || cabal test hls-tactics-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-tactics-plugin --test-options="-j1 --rerun"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test }}
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test && matrix.ghc != '9.0.1' }}
name: Test hls-refine-imports-plugin test suite
run: cabal test hls-refine-imports-plugin --test-options="-j1 --rerun-update" || cabal test hls-refine-imports-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-refine-imports-plugin --test-options="-j1 --rerun"
153 changes: 153 additions & 0 deletions cabal-ghc901.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
packages:
./
./hie-compat
./shake-bench
./hls-graph
./ghcide
./hls-plugin-api
./hls-test-utils
-- ./plugins/hls-tactics-plugin
-- ./plugins/hls-brittany-plugin
-- ./plugins/hls-stylish-haskell-plugin
-- ./plugins/hls-fourmolu-plugin
./plugins/hls-class-plugin
./plugins/hls-eval-plugin
./plugins/hls-explicit-imports-plugin
./plugins/hls-refine-imports-plugin
./plugins/hls-hlint-plugin
./plugins/hls-retrie-plugin
./plugins/hls-haddock-comments-plugin
-- ./plugins/hls-splice-plugin
./plugins/hls-floskell-plugin
./plugins/hls-pragmas-plugin
./plugins/hls-module-name-plugin
-- ./plugins/hls-ormolu-plugin
tests: true

package *
ghc-options: -haddock
test-show-details: direct

source-repository-package
type: git
location: https://github.com/jwaldmann/blaze-textual.git
tag: d8ee6cf80e27f9619d621c936bb4bda4b99a183f
-- https://github.com/jwaldmann/blaze-textual/commit/d8ee6cf80e27f9619d621c936bb4bda4b99a183f
-- https://github.com/bos/blaze-textual/issues/13

source-repository-package
type: git
location: https://github.com/mithrandi/czipwith.git
tag: b6245884ae83e00dd2b5261762549b37390179f8
-- https://github.com/lspitzner/czipwith/pull/2


source-repository-package
type: git
location: https://github.com/jneira/hie-bios/
tag: 9b1445ab5efcabfad54043fc9b8e50e9d8c5bbf3
-- https://github.com/mpickering/hie-bios/pull/285

source-repository-package
type: git
location: https://github.com/hsyl20/ghc-api-compat
tag: 6178d75772c7d923918dfffa0b1f503dfb36d0a6

source-repository-package
type: git
location: https://github.com/anka-213/th-extras
tag: 57a97b4df128eb7b360e8ab9c5759392de8d1659
-- https://github.com/mokus0/th-extras/pull/8
-- https://github.com/mokus0/th-extras/issues/7

source-repository-package
type: git
location: https://github.com/anka-213/dependent-sum
tag: 8cf4c7fbc3bfa2be475a17bb7c94a1e1e9a830b5
subdir: dependent-sum-template
-- https://github.com/obsidiansystems/dependent-sum/pull/57

source-repository-package
type: git
location: https://github.com/anka-213/HieDb
tag: a3f7521f6c5af1b977040cce09c8f7354f8984eb
-- https://github.com/wz1000/HieDb/pull/31

source-repository-package
type: git
location: https://github.com/anka-213/lsp
tag: tag-ghc-9.0.1-without-pr-326
subdir: lsp-types
subdir: lsp
subdir: lsp-test
-- https://github.com/haskell/lsp/pull/312

source-repository-package
type: git
location: https://github.com/diagrams/active
tag: ca23431a8dfa013992f9164ccc882a3277361f17
-- https://github.com/diagrams/active/pull/36

write-ghc-environment-files: never

index-state: 2021-05-21T05:01:41Z

constraints:
-- Diagrams doesn't support optparse-applicative >= 0.16 yet
optparse-applicative < 0.16
-- These plugins doesn't work on GHC9 yet
, haskell-language-server -brittany -class -eval -fourmolu -modulename -ormolu -splice -stylishhaskell -tactic -refineImports


allow-newer:
-- -- Broken on ghc9, but let's pretend it's not so we can build the other things
-- brittany:base,
-- brittany:ghc,
-- brittany:ghc-boot-th,
-- butcher:base,
-- fourmolu:ghc-lib-parser,
-- ormolu:ghc-lib-parser,
-- stylish-haskell:ghc-lib-parser,
-- stylish-haskell:Cabal,
-- multistate:base,
-- ghc-source-gen:ghc,

active:base,
assoc:base,
cryptohash-md5:base,
cryptohash-sha1:base,
constraints-extras:template-haskell,
data-tree-print:base,
deepseq:base,
dependent-sum:some,
dependent-sum:constraints,
diagrams-contrib:base,
diagrams-contrib:lens,
diagrams-contrib:random,
diagrams-core:base,
diagrams-core:lens,
diagrams-lib:base,
diagrams-lib:lens,
diagrams-postscript:base,
diagrams-postscript:lens,
diagrams-svg:base,
diagrams-svg:lens,
dual-tree:base,
-- Does this make any sense?
entropy:Cabal,
force-layout:base,
force-layout:lens,
floskell:ghc-prim,
floskell:base,
hashable:base,
hslogger:base,
monoid-extras:base,
newtype-generics:base,
parallel:base,
regex-base:base,
regex-tdfa:base,
statestack:base,
svg-builder:base,
these:base,
time-compat:base

55 changes: 43 additions & 12 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,47 @@ write-ghc-environment-files: never

index-state: 2021-05-21T05:01:41Z

constraints:
-- Diagrams doesn't support optparse-applicative >= 0.16 yet
optparse-applicative < 0.16

allow-newer:
active:base,
data-tree-print:base,
diagrams-contrib:base,
diagrams-core:base,
diagrams-lib:base,
diagrams-postscript:base,
diagrams-svg:base,
dual-tree:base,
force-layout:base,
monoid-extras:base,
statestack:base,
svg-builder:base
active:base,
assoc:base,
cryptohash-md5:base,
cryptohash-sha1:base,
constraints-extras:template-haskell,
data-tree-print:base,
deepseq:base,
dependent-sum:some,
dependent-sum:constraints,
diagrams-contrib:base,
diagrams-contrib:lens,
diagrams-contrib:random,
diagrams-core:base,
diagrams-core:lens,
diagrams-lib:base,
diagrams-lib:lens,
diagrams-postscript:base,
diagrams-postscript:lens,
diagrams-svg:base,
diagrams-svg:lens,
dual-tree:base,
-- Does this make any sense?
entropy:Cabal,
force-layout:base,
force-layout:lens,
floskell:ghc-prim,
floskell:base,
hashable:base,
hslogger:base,
monoid-extras:base,
newtype-generics:base,
parallel:base,
regex-base:base,
regex-tdfa:base,
statestack:base,
svg-builder:base,
these:base,
time-compat:base

2 changes: 1 addition & 1 deletion ghcide/bench/lib/Experiments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ configP =
<*> option auto (long "timeout" <> value 60 <> help "timeout for waiting for a ghcide response")
<*> ( GetPackage <$> strOption (long "example-package-name" <> value "Cabal")
<*> (some moduleOption <|> pure ["Distribution/Simple.hs"])
<*> option versionP (long "example-package-version" <> value (makeVersion [3,2,0,0]))
<*> option versionP (long "example-package-version" <> value (makeVersion [3,4,0,0]))
<|>
UsePackage <$> strOption (long "example-path")
<*> some moduleOption
Expand Down
7 changes: 4 additions & 3 deletions ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description:
A library for building Haskell IDE's on top of the GHC API.
homepage: https://github.com/haskell/haskell-language-server/tree/master/ghcide#readme
bug-reports: https://github.com/haskell/haskell-language-server/issues
tested-with: GHC == 8.6.4 || == 8.6.5 || == 8.8.2 || == 8.8.3 || == 8.8.4 || == 8.10.2 || == 8.10.3 || == 8.10.4
tested-with: GHC == 8.6.4 || == 8.6.5 || == 8.8.2 || == 8.8.3 || == 8.8.4 || == 8.10.2 || == 8.10.3 || == 8.10.4 || == 9.0.1
extra-source-files: README.md CHANGELOG.md
test/data/**/*.project
test/data/**/*.cabal
Expand Down Expand Up @@ -59,7 +59,7 @@ library
hie-compat ^>= 0.1.0.0,
hls-plugin-api ^>= 1.1.0.0,
lens,
hiedb == 0.3.0.1,
hiedb == 0.3.0.*,
lsp-types == 1.2.*,
lsp == 1.2.*,
mtl,
Expand Down Expand Up @@ -95,8 +95,9 @@ library
ghc-boot-th,
ghc-boot,
ghc >= 8.6,
ghc-check >=0.5.0.1,
ghc-check >=0.5.0.4,
ghc-paths,
ghc-api-compat,
cryptohash-sha1 >=0.11.100 && <0.12,
hie-bios >= 0.7.1 && < 0.8.0,
implicit-hie-cradle >= 0.3.0.2 && < 0.4,
Expand Down

0 comments on commit 0b3bb10

Please sign in to comment.