Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with GHC 9.2 #2503

Merged
merged 167 commits into from Jan 12, 2022
Merged

Build with GHC 9.2 #2503

merged 167 commits into from Jan 12, 2022

Conversation

pepeiborra
Copy link
Collaborator

@pepeiborra pepeiborra commented Dec 18, 2021

Build a GHC 9.2 binary via head.hackage:

cabal update --project-file=cabal-ghc921.project
cabal build --project-file cabal-ghc921.project

Branch is open to contributions - let's crowdsource this.

@pepeiborra
Copy link
Collaborator Author

pepeiborra commented Dec 18, 2021

It looks like the Compat layer no longer builds with GHC 9.2:

src/Development/IDE/GHC/Compat/Core.hs:812:3: error:
    Not in scope: ‘TcType.splitForAllTyCoVars’
    Perhaps you meant one of these:
      ‘TcType.tcSplitForAllTyVars’ (imported from GHC.Tc.Utils.TcType),
      ‘GHC.splitForAllTyCoVars’ (imported from GHC)
    Module ‘GHC.Tc.Utils.TcType’ does not export ‘splitForAllTyCoVars’.
    |
812 |   TcType.splitForAllTyCoVars
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^

There are more errors when I fix this one:

src/Development/IDE/GHC/Compat/Core.hs:75:5: error:
    Not in scope: type constructor or class ‘ModIface’
    Perhaps you meant one of these:
      ‘GHC.ModIface’ (imported from GHC),
      ‘GHC.ModIface_’ (imported from GHC)
    Perhaps you want to add ‘ModIface’ to the import list
    in the import of ‘GHC.Unit.Module.ModIface’
    (src/Development/IDE/GHC/Compat/Core.hs:538:1-57).
   |
75 |     ModIface,
   |     ^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:76:5: error:
    Not in scope: type constructor or class ‘ModIface_’
    Perhaps you meant one of these:
      ‘GHC.ModIface_’ (imported from GHC),
      ‘GHC.ModIface’ (imported from GHC)
    Perhaps you want to add ‘ModIface_’ to the import list
    in the import of ‘GHC.Unit.Module.ModIface’
    (src/Development/IDE/GHC/Compat/Core.hs:538:1-57).
   |
76 |     ModIface_(..),
   |     ^^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:100:5: error:
    Not in scope: type constructor or class ‘LexicalFixity’
    Perhaps you meant ‘GHC.LexicalFixity’ (imported from GHC)
    |
100 |     LexicalFixity(..),
    |     ^^^^^^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:102:5: error:
    Not in scope: type constructor or class ‘ModSummary’
    Perhaps you meant ‘GHC.ModSummary’ (imported from GHC)
    |
102 |     ModSummary(..),
    |     ^^^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:124:5: error:
    Not in scope: ‘Development.IDE.GHC.Compat.Core.splitForAllTyCoVars’
    Perhaps you meant one of these:
      ‘Development.IDE.GHC.Compat.Core.tcSplitForAllTyVars’ (line 816),
      ‘Development.IDE.GHC.Compat.Core.mkInfForAllTys’ (line 802),
      ‘Development.IDE.GHC.Compat.Core.dataConExTyCoVars’ (line 781)
    |
124 |     Development.IDE.GHC.Compat.Core.splitForAllTyCoVars,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:150:5: error:
    Not in scope: type constructor or class ‘HsParsedModule’
    Perhaps you meant one of these:
      ‘GHC.HsParsedModule’ (imported from GHC),
      ‘GHC.ParsedModule’ (imported from GHC)
    |
150 |     HsParsedModule(..),
    |     ^^^^^^^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:237:5: error:
    Not in scope: ‘initDynLinker’
    Perhaps you meant ‘initObjLinker’ (imported from GHC.Runtime.Interpreter)
    |
237 |     initDynLinker,
    |     ^^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:252:5: error:
    Not in scope: type constructor or class ‘Target’
    Perhaps you meant one of these:
      ‘GHC.Target’ (imported from GHC),
      ‘GHC.TargetId’ (imported from GHC)
    |
252 |     Target(..),
    |     ^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:253:5: error:
    Not in scope: type constructor or class ‘TargetId’
    Perhaps you meant one of these:
      ‘GHC.TargetId’ (imported from GHC),
      ‘GHC.Target’ (imported from GHC)
    |
253 |     TargetId(..),
    |     ^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:254:5: error:
    Not in scope: ‘mkModuleGraph’
    Perhaps you meant one of these:
      ‘GHC.mkModuleGraph’ (imported from GHC),
      ‘GHC.getModuleGraph’ (imported from GHC)
    |
254 |     mkModuleGraph,
    |     ^^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:258:5: error:
    Not in scope: type constructor or class ‘InteractiveImport’
    Perhaps you meant ‘GHC.InteractiveImport’ (imported from GHC)
    |
258 |     InteractiveImport(..),
    |     ^^^^^^^^^^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:310:5: error:
    The export item ‘module Language.Haskell.Syntax.Expr’ is not imported
    |
310 |     module Language.Haskell.Syntax.Expr,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:335:5: error:
    Conflicting exports for ‘pprFamInst’:
       ‘module GHC.Core.FamInstEnv’ exports ‘GHC.Core.FamInstEnv.pprFamInst’
         imported from ‘GHC.Core.FamInstEnv’ at src/Development/IDE/GHC/Compat/Core.hs:429:1-36
       ‘module GHC.Types.TyThing.Ppr’ exports ‘GHC.Types.TyThing.Ppr.pprFamInst’
         imported from ‘GHC.Types.TyThing.Ppr’ at src/Development/IDE/GHC/Compat/Core.hs:514:1-38
    |
335 |     module GHC.Types.TyThing.Ppr,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/Development/IDE/GHC/Compat/Core.hs:390:5: error:
    The export item ‘module GHC.Hs’ is not imported
    |
390 |     module GHC.Hs,
    |     ^^^^^^^^^^^^^

/cc @fendor

@fendor
Copy link
Collaborator

fendor commented Dec 18, 2021

It is easily possible that some imports are incomplete, that was left on the todo list. Not all, but at least most of these imports were added when GHC 9.0 support was added to the plugins. Which was at the very end of my "sprint". However, adding (or hiding appropriately) the imports should suffice for most of these errors. Additionally, iirc, the module GHC.Hs import was added to avoid listing every possible identifier on the export-list, literally just before the MR got merged.

There is at least one big issue left: https://github.com/haskell/haskell-language-server/blob/master/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs#L156
I didn't manage to implement the function mkPrintUnqualifiedDefault with GHC 9.2. mkPrintUnqualified wants a UnitEnv now, and I can't summon it out of the ether. The call-sites of mkPrintUnqualifiedDefault do not allow to trivially get the UnitEnv.

@pepeiborra
Copy link
Collaborator Author

If you (or anyone else) is up for helping with this PR, the branch is open to all contributors

@alanz

This comment has been minimized.

@wz1000
Copy link
Collaborator

wz1000 commented Dec 20, 2021

My last commit stubs out the getDocumentation function (which re-implements -haddock using exactprint annotations), I've never really been a fan of it anyway. GHC's haddock parsing + stale data should be good enough in the vast majority of cases. I think we should get rid of that function anyway. Thoughts?

@pepeiborra
Copy link
Collaborator Author

My last commit stubs out the getDocumentation function (which re-implements -haddock using exactprint annotations), I've never really been a fan of it anyway. GHC's haddock parsing + stale data should be good enough in the vast majority of cases. I think we should get rid of that function anyway. Thoughts?

I'm not a big fan either, but we still use it in a couple of places.
Stubbing it out in 9.2 is fine.
Ideally we would replace all the callsites with getDocumentationTryGhc and delete it.

@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Dec 20, 2021

Nota bene: As getDocumentation is discussed & GHC-s way is mentioned as preferred - the work on getDocumentationTryGhc & getDocumentationsTryGhc is in #2349 #2371.

@pepeiborra

This comment has been minimized.

wz1000 and others added 2 commits December 21, 2021 03:29
The Exactprint module compiles, but code actions are the next focus.
@Anton-Latukha
Copy link
Collaborator

Anton-Latukha commented Jan 9, 2022

Issues that are left in the thread do not mandate the blockage of the GHC 9.2 support.

Let us go forward.

Since I took part in Ops situations left. When the code merges into the mainline - I would take this thread & open the reports on them.


File after the merge:

#2503 (comment)

#2503 (comment)

Already opened:

#2574

#2568


Also went through the thread & folded some resolved things. So the thread now is more reviewable.

@pepeiborra
Copy link
Collaborator Author

The proverbial green light is about to shine. Shall we land this in time for a January HLS Release?

@jneira
Copy link
Member

jneira commented Jan 10, 2022

yeah, I would include it, maybe with a note about being still experimental?i is it being used on ghc itself by some ghc dev, @wz1000 @mpickering?

@mpickering
Copy link
Contributor

yeah, I would include it, maybe with a note about being still experimental?i is it being used on ghc itself by some ghc dev, @wz1000 @mpickering?

I was using an older version of this branch whilst working on a particular GHC branch but not since the testsuite passed. That version had some bugs to do with imports but Zubin said they were due to ghc-exactprint problems which I believe are now fixed.

@georgefst
Copy link
Collaborator

Shall we land this in time for a January HLS Release?

If we do (which would be great!), it would be nice to make sure #2579 gets merged.

@@ -146,7 +146,7 @@ jobs:

run: cabal test wrapper-test --test-options="$TEST_OPTS --rerun-log-file .tasty-rerun-log-wrapper" || cabal test wrapper-test --test-options="$TEST_OPTS --rerun-log-file .tasty-rerun-log-wrapper" || cabal test wrapper-test --test-options="$TEST_OPTS --rerun-log-file .tasty-rerun-log-wrapper"

- if: matrix.test && matrix.ghc != '9.0.1' && matrix.ghc != '9.2.1'
- if: matrix.test && matrix.ghc != '9.2.1'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @jneira I conservatively merged to allow 9.0.1 since we fixed it on master but not allow 9.2.1, but maybe fixing it for 9.0.1 also fixed it for 9.2.1. Not sure, we should try after this is merged perhaps.

Copy link
Collaborator

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If nobody objects, I'll merge this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet