GHC can't build C program that uses exported Haskell function
GHC 7.4.1 RC2 can't build foreign export example on Mac OS X and Windows. (I used first version of main().)
$ ghc Foo.hs -c
$ ghc Foo.o import.c -o exportHaskell
import.c: In function ‘main’:
import.c:17:0:
warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘HsInt’
import.c:17:0:
warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘HsInt’
ld: duplicate symbol _main in /var/folders/zs/bsr11y_x3d76ssg4bl_kx7nm0000gn/T/ghc61891_0/ghc61891_0.o and import.o for architecture x86_64
collect2: ld returned 1 exit status
I can build this program with (Haskell Platform 2011.4.0.0's) GHC 7.0.4 and 7.2.2. So, I don't know why GHC 7.4.1 RC 2 can't build program.
$ ghc-7.0.4 Foo.hs -c
$ ghc-7.0.4 Foo.o import.c Foo_stub.c -o exportHaskell
import.c: In function ‘main’:
import.c:17:0:
warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘HsInt’
import.c:17:0:
warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘HsInt’
ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame
$ ./exportHaskell
2500
2500
2500
2500
2500
$ ghc-7.2.2 Foo.hs -c
$ ghc-7.2.2 Foo.o import.c -o exportHaskell
import.c: In function ‘main’:
import.c:17:0:
warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘HsInt’
import.c:17:0:
warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘HsInt’
ld: warning: could not create compact unwind for .LFB3: non-standard register 5 being saved in prolog
ld: warning: text reloc in _main to cstring
(snip)
ld: warning: text reloc in _cOp_str to _stg_ap_pppppp_info
$ ./exportHaskell
2500
2500
2500
2500
2500
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.1-rc2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (FFI) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | shelarcy@gmail.com |
Operating system | |
Architecture |