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

Multiple issues compiling llvm with ghc 7.8.2 #75

Open
chauser opened this issue May 24, 2014 · 1 comment
Open

Multiple issues compiling llvm with ghc 7.8.2 #75

chauser opened this issue May 24, 2014 · 1 comment

Comments

@chauser
Copy link

chauser commented May 24, 2014

I was working on another package that required use of ghc 7.8 features but also depended on llvm. In attempting to compile llvm I ran into several issues. The experience may be helpful to others. Taking things in the order that they occurred:

llvm-base

LLVM/ST.hs:535:15:
    Could not deduce (MonadMG m0)
      arising from the ambiguity check for ‘runCodeGen’
    from the context (Monad (m c s), MonadMG m)
      bound by the type signature for
                 runCodeGen :: (Monad (m c s), MonadMG m) =>
                               STValue c s -> CodeGen c s a -> ModuleGen c s a
      at LLVM/ST.hs:(535,15)-(536,61)
    The type variable ‘m0’ is ambiguous
    In the ambiguity check for:
      forall c s a (m :: * -> * -> * -> *).
      (Monad (m c s), MonadMG m) =>
      STValue c s -> CodeGen c s a -> ModuleGen c s a
    To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
    In the type signature for ‘runCodeGen’:
      runCodeGen :: (Monad (m c s), MonadMG m) =>
                    STValue c s -> CodeGen c s a -> ModuleGen c s a

Following the suggestion to enable the AllowAmbiguousTypes extension allowed successful compilation and installation of llvm-base.

type-level

llvm depends on type-level. The type-level package will not compile with ghc 7.8.2 due to stricter checking of coverage in instance declarations. The problem is exemplified by:

src/Data/TypeLevel/Num/Ops.hs:90:10:                                                                                                                                          
    Illegal instance declaration for ‘Succ' (x, x) (x, x) D0 D0 True’                                                                                                         
      The liberal coverage condition fails in class ‘Succ'’                                                                                                                   
        for functional dependency: ‘yh yl yz -> xh xl’                                                                                                                        
      Reason: lhs types ‘D0’, ‘D0’, ‘True’                                                                                                                                    
        do not jointly determine rhs types ‘(x, x)’, ‘(x, x)’                                                                                                                 
    In the instance declaration for ‘Succ' (x, x) (x, x) D0 D0 True’     

Similar Illegal instance errors occur on lines 254, 255, 256, 266, and 336 of Ops.hs. As a workaround, built a version of Ops.hs that simply did not have these instances declared -- it is not clear to me how to really fix the problem. llvm seems not to depend on any of these instances, but it is certainly not a general solution. I'll file a separate issue report for type-level, but if you just want to get llvm working, the workaround appears to be sufficient. Ops.h also requires the AllowAmbiguousTypes extension to be enabled.

llvm itself

llvm also has illegal instance problems:

LLVM/Util/Arithmetic.hs:250:10:
    Illegal instance declaration for
      ‘ArithFunction (CodeGenFunction r a) (CodeGenFunction r ())’
      The liberal coverage condition fails in class ‘ArithFunction’
        for functional dependency: ‘b -> a’
      Reason: lhs type ‘CodeGenFunction r ()’
        does not determine rhs type ‘CodeGenFunction r a’
    In the instance declaration for
      ‘ArithFunction (CodeGenFunction r a) (CodeGenFunction r ())’

Again non knowing what else to do, I simply removed the problematic instance declarations -- on lines 250, 253, 280 and 286 of Arithmetic.hs. My use of LLVM did not require any of them, but once again it's only a workaround and not a fix.

@cartazio
Copy link
Collaborator

@chauser all of the active llvm-hs devs are using llvm-general and related tooling for their haskell based LLVM activities now.

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

No branches or pull requests

2 participants