Skip to content

Optionally store hie files #8685

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

Closed
aavogt opened this issue Jan 16, 2023 · 8 comments
Closed

Optionally store hie files #8685

aavogt opened this issue Jan 16, 2023 · 8 comments

Comments

@aavogt
Copy link

aavogt commented Jan 16, 2023

I added the following to my ~/.cabal/config

program-default-options
  ghc-options: -fwrite-ide-info

But I do not end up with .hie files in ~/.cabal/store/. I think they should go beside the hi files. Maybe -hiedir needs to be set. I want this because the hoogle/haddock file share/doc/html/<packagename>.txt is missing information about instances of associated types.

cabal --version
cabal-install version 3.8.1.0
compiled using version 3.8.1.0 of the Cabal library 

ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7
@aavogt
Copy link
Author

aavogt commented Jan 17, 2023

I have success using the following:

diff --git a/Cabal/src/Distribution/Simple/GHC.hs b/Cabal/src/Distribution/Simple/GHC.hs
index c1352dbba..b82cc6372 100644
--- a/Cabal/src/Distribution/Simple/GHC.hs
+++ b/Cabal/src/Distribution/Simple/GHC.hs
@@ -1974,6 +1974,7 @@ installLib    :: Verbosity
 installLib verbosity lbi targetDir dynlibTargetDir _builtDir pkg lib clbi = do
   -- copy .hi files over:
   whenVanilla $ copyModuleFiles "hi"
+  whenVanilla $ copyModuleFiles "hie"
   whenProf    $ copyModuleFiles "p_hi"
   whenShared  $ copyModuleFiles "dyn_hi"
 
diff --git a/Cabal/src/Distribution/Simple/Program/GHC.hs b/Cabal/src/Distribution/Simple/Program/GHC.hs
index 8e7157af8..8fd264c35 100644
--- a/Cabal/src/Distribution/Simple/Program/GHC.hs
+++ b/Cabal/src/Distribution/Simple/Program/GHC.hs
@@ -677,6 +677,7 @@ renderGhcOptions comp _platform@(Platform _arch os) opts
   , concat [ ["-outputdir", dir] | dir <- flag ghcOptOutputDir ]
   , concat [ ["-odir",    dir] | dir <- flag ghcOptObjDir ]
   , concat [ ["-hidir",   dir] | dir <- flag ghcOptHiDir  ]
+  , concat [ ["-hiedir",   dir] | dir <- flag ghcOptHiDir  ]
   , concat [ ["-stubdir", dir] | dir <- flag ghcOptStubDir ]

Now when I remove -fwrite-ide-info I get an install error Error: cabal: Could not find module: Control.Monad.Trans.Instances with any suffix: ["hie"] in the search path: ["dist/build"]. So whenVanilla should be something different. It should either check for -fwrite-ide-info, the presence of hie files, or it might check for a new option that adds the -fwrite-ide-info. Let me know which way I should write the pull request.

@Mikolaj
Copy link
Member

Mikolaj commented Jan 17, 2023

This is something about IDEs, right? @jneira: could you ping some cabal devs that use IDE and so would have an opinion?

@jneira
Copy link
Member

jneira commented Jan 17, 2023

I think @fendor could have a good vision of the interaction between hie files and cabal

@andreabedini
Copy link
Collaborator

I don't think this is necessarily about IDEs. HIE files can be consumed by many other tools (e.g. policeman, calligraphy). I would find it very useful if cabal could store them (e.g. for analysing the whole application depenency graph).

@michaelpj
Copy link
Collaborator

I also wonder if this is something that should have a more "official" flag for producing the additional artifacts, much like we have profiling: True maybe we should have ide-files: True?

@nlander
Copy link
Contributor

nlander commented Jun 2, 2023

Hi all, I would like to encourage these changes to be made sooner rather than later. I am working on gotoDefinition for hls as part of Summer of Haskell and I need the hie files to be generated for the changes I will be making. How can I help this process move forward? I have tried out the changes @aavogt proposed above with similar results. I would be happy to work on a pull request, but I don't want to step on your toes, @aavogt.

@aavogt
Copy link
Author

aavogt commented Jun 2, 2023

@nlander make the pull request. I look forward to using "gotoDefinition for hls".

@nlander nlander mentioned this issue Jun 12, 2023
4 tasks
@nlander
Copy link
Contributor

nlander commented Jun 26, 2023

I believe #9019 solves this issue.

@aavogt aavogt closed this as completed Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants