ghc-mod icon indicating copy to clipboard operation
ghc-mod copied to clipboard

Support object code generation as this is required for some (new) language extentions

Open jacobstanley opened this issue 9 years ago • 7 comments

If I try to use TemplateHaskell and StaticPointers in the same project the I get the following error:

The static form is not supported in interpreted mode.
Please use -fobject-code

There are other tickets that document this situation pretty well, unfortunately using -g -O0 or -g -fobject-code does not work in this situation :(

jacobstanley avatar Jun 01 '15 08:06 jacobstanley

We should probably detect all the relevant combinations of language flags and turn on object code generation for those that need it, like we do with NoLink/LinkInMemory and TH already. Though we'll have to be careful with where we put the output files since right now we just get the directories cabal uses through cabal-helper. I'm not sure if it's a good idea to overwrite those output files since that might interfere with cabal build working properly if something goes wrong in ghc-mod, which would be very surprising to the user.

DanielG avatar Jun 01 '15 15:06 DanielG

What's the status on this? Is there a known workaround?

dspies-leapyear avatar Apr 14 '17 22:04 dspies-leapyear

Not yet but I think it would be very easy to fix. The code for checking if we need to enable byte-code generation is here (https://github.com/DanielG/ghc-mod/blob/master/core/Language/Haskell/GhcMod/Target.hs#L495). I think fixing this would basically amount to adding || StaticPointers `xopt` df. I'd be happy to accept a PR that does this.

DanielG avatar Apr 14 '17 23:04 DanielG

I just now tried that and it didn't work. I even tried setting:

needsHscInterpreted = const True

and it still says

The static form is not supported in interpreted mode.Please use -fobject-code.

dspies-leapyear avatar Apr 15 '17 00:04 dspies-leapyear

Oh, I had it backwards. It works when I change it to const False

dspies-leapyear avatar Apr 15 '17 00:04 dspies-leapyear

Hmm OK. So that means it works with -fno-code (HscNothing) mode but not with HscInterpreted. That's going to cause problems when any of the other things that need HscInterpreted are also enabled in a module :/

DanielG avatar Apr 15 '17 00:04 DanielG

I wonder though, does StaticPoints even work in ghci? If it throws up with HscInterpreted it ought to not so in that case one could argue the underlying issue really is a GHC problem.

DanielG avatar Apr 15 '17 00:04 DanielG