obelisk icon indicating copy to clipboard operation
obelisk copied to clipboard

Support ghci options like -fobject-code and -fno-code

Open 3noch opened this issue 4 years ago • 5 comments

-fobject-code is necessary if you want to use unboxed sums in your code.

3noch avatar Jul 17 '19 13:07 3noch

Resolved by #529

ali-abrar avatar Oct 03 '19 02:10 ali-abrar

It seems this is not working, here is the code to test on skeleton project The ob run will fail

# LANGUAGE UnboxedSums #-}
module Common.Api where

commonStuff :: String
commonStuff = "Here is a string defined in Common.Api"
  where 
   testval :: (# Int | Bool #)

and in common.cabal

  ghc-options: -Wall -fobject-code
common/src/Common/Api.hs:9:4: warning: [-Wunused-local-binds]
    Defined but not used: ‘testval’
  |
9 |    testval = (# | True #)
  |    ^^^^^^^
Error: bytecode compiler can't handle unboxed tuples and sums.
  Possibly due to foreign import/export decls in source.
  Workaround: use -fobject-code, or compile this module to .o separately.

dfordivam avatar Jun 21 '20 11:06 dfordivam

well the reason I want to use the -fobject-code is to make ghci faster, and I hope that will also work once this is fixed.

dfordivam avatar Jun 21 '20 11:06 dfordivam

My guess is the issue is that -fobject-code needs to be used for the entire GHCi session, and so the stuff that would set package flags just on those modules is too smart.

Ericson2314 avatar Jun 21 '20 23:06 Ericson2314

The options -fobject-code and -fno-code are intended for the GHCi session only, as they are not relevant for the native compilation.

So adding them to the .cabal file sounds like a bad idea. ob run should provide a separate mechanism to specifying these.

dfordivam avatar Jun 22 '20 03:06 dfordivam