haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
197 stars 50 forks source link

Hackage version of c2hs fails to build with GHC-8.8.4 or 8.10.2 #260

Closed mouse07410 closed 3 years ago

mouse07410 commented 3 years ago

Same complaint regardless of whether I try with GHC-8.10.2 or 8.8.4:

$ cabal install c2hs -w ghc-8.8.4 --overwrite-policy=always
Resolving dependencies...
Build profile: -w ghc-8.8.4 -O1
In order, the following will be built (use -v for more details):
 - c2hs-0.28.6 (exe:c2hs) (requires build)
Starting     c2hs-0.28.6 (exe:c2hs)
Building     c2hs-0.28.6 (exe:c2hs)

Failed to build exe:c2hs from c2hs-0.28.6.
Build log ( /Users/uri/.cabal/logs/ghc-8.8.4/c2hs-0.28.6-e3c8dbc5.log ):
Configuring executable 'c2hs' for c2hs-0.28.6..
Preprocessing executable 'c2hs' for c2hs-0.28.6..
Building executable 'c2hs' for c2hs-0.28.6..

src/C2HS/C/Names.hs:1:1: error:
    File name does not match module name:
    Saw: ‘Main’
    Expected: ‘C2HS.C.Names’
  |
1 | --  C->Haskell Compiler: C name analysis
  | ^

src/C2HS/C/Trav.hs:1:1: error:
    File name does not match module name:
    Saw: ‘Main’
    Expected: ‘C2HS.C.Trav’
  |
1 | --  C->Haskell Compiler: traversals of C structure tree
  | ^

src/C2HS/Gen/Header.hs:1:1: error:
    File name does not match module name:
    Saw: ‘Main’
    Expected: ‘C2HS.Gen.Header’
  |
1 | --  C->Haskell Compiler: custom header generator
  | ^
cabal: Failed to build exe:c2hs from c2hs-0.28.6. See the build log above for
details.
iko-deleted commented 3 years ago

i getting this as well, attempting to install from stackage lts-11.3

error is slightly different:


c2hs> Configuring c2hs-0.28.3...
c2hs> build
c2hs> Preprocessing executable 'c2hs' for c2hs-0.28.3..
c2hs> Building executable 'c2hs' for c2hs-0.28.3..
c2hs> 
c2hs> /tmp/stack-4cadb4e34aa0e146/c2hs-0.28.3/src/C2HS/C/Names.hs:1:1: error:
c2hs>     File name does not match module name:
c2hs>     Saw: ‘Main’
c2hs>     Expected: ‘C2HS.C.Names’
c2hs>   |
c2hs> 1 | --  C->Haskell Compiler: C name analysis
c2hs>   | ^
c2hs> ```
iko-deleted commented 3 years ago

this works perfectly fine with the version from the repo head; i assume it has already been fixed somewhere

in the meantime i got around this by adding

extra-deps:
- git: https://github.com/haskell/c2hs.git
  commit: 20d3c8dedde83af91c4ac06486bf346316e07285

to my stack.yaml

i assume there's something similar with cabal

emlautarom1 commented 3 years ago

I'm having the same issue but not directly since I'm using gi-cairo-render in a project, which fails to compile since it can't build this dependency.

Any workaround? I'm using cabal, not stack, btw.

iko-deleted commented 3 years ago

you should be able to do something similar with a cabal.project file

i think

source-repository-package
    type: git
    location: https://github.com/haskell/c2hs.git
    tag: 20d3c8dedde83af91c4ac06486bf346316e07285

would work?

emlautarom1 commented 3 years ago

you should be able to do something similar with a cabal.project file

i think

source-repository-package
    type: git
    location: https://github.com/haskell/c2hs.git
    tag: 20d3c8dedde83af91c4ac06486bf346316e07285

would work?

Indeed, this solution works.

For future reference, I'm running GHC 8.8.4, cabal-install 3.2.0, Fedora 33

mouse07410 commented 3 years ago

I think it builds with 8.10.4 now (when pulled from Hackage). Thanks!