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

Finding a Compiler Plugin with --ghc-options=" -package=compilerplugin #3768

Closed
tkvogt opened this issue Jan 13, 2018 · 2 comments
Closed

Finding a Compiler Plugin with --ghc-options=" -package=compilerplugin #3768

tkvogt opened this issue Jan 13, 2018 · 2 comments

Comments

@tkvogt
Copy link

tkvogt commented Jan 13, 2018

My goal is to to run a compiler plugin over all packages in a snapshot. This usecase is probably very rare, but the solution I used so far with just cabal could only compile half of stackage (quite disappointing).

Before using stack I made a new sandbox with cabal, compiled the plugin in this sandbox, made a backup of this sandbox (to safe time). Then the sandbox was recreated for each package, that was compiled with the plugin.

I wonder how to do something similar with stack. Maybe install the plugin in the snapshot (to avoid recompilation)?
My tests also show that ghc can only find packages that are in its global database (which is maybe a bug). I am willing to look into all this and write a pull request.

This part of a shake script runs but doesn't work:

    putNormal "\nBuild ghc-core-graph (the compiler plugin)"
    () <- cmd Shell (Cwd ("be" </> "ghc-core-graph")) ("stack clean")
    () <- cmd Shell (Cwd ("be" </> "ghc-core-graph")) ("stack setup")
    () <- cmd Shell (Cwd ("be" </> "ghc-core-graph")) ("stack build")

    forP (zip [0..] packages) (\(i, package) -> do
      Exit c <- cmd Shell (Cwd ("be" </> "ghc-core-graph"))
       ("stack build "++ package ++" --verbose --ghc-options=\" -package=ghc-core-graph -fplugin=GhcPlugins.Optimind\"")
@mgsloan
Copy link
Contributor

mgsloan commented Jan 15, 2018

The docs for ghc-options / apply-ghc-options may be helpful - https://docs.haskellstack.org/en/stable/yaml_configuration/#ghc-options . You probably want to have a stack.yaml with something like

ghc-options:
  "$everything": -package=ghc-core-graph -fplugin=GhcPlugins.Optimind

Note that this won't rebuild stuff in the global db (things like base). I don't know of a good way to force a rebuild of baser other than asking for a different version than what's in the global DB that came with the compiler. Note that this will mean any package that transitively depends on ghc as a library won't be able to be used.

This will hopefully be resolved with implicit snapshots (#1265 , reopened in #3330). Until that's implemented, you will need to make sure that nothing has been built yet in the snapshot you're using. One way to do that is to do compiler: ghc-8.2.1 and rely entirely on extra-deps instead of using snapshots.

In lieu of extra-deps we could consider having some option that promotes everything to the local DB. This way, deleting the local DB could force a full rebuild.

@mgsloan mgsloan added this to the Support milestone Jan 15, 2018
@mpilgrem
Copy link
Member

mpilgrem commented Apr 1, 2024

I am going to close this issue given the passage of time.

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

3 participants