[GHC] #5825: GHC can't build C program that uses exported Haskell function

GHC cvs-ghc at haskell.org
Sun Jan 29 17:04:35 CET 2012


#5825: GHC can't build  C program that uses exported Haskell function
------------------------------+---------------------------------------------
 Reporter:  shelarcy          |          Owner:                  
     Type:  bug               |         Status:  new             
 Priority:  normal            |      Component:  Compiler (FFI)  
  Version:  7.4.1-rc2         |       Keywords:                  
       Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
  Failure:  None/Unknown      |       Testcase:                  
Blockedby:                    |       Blocking:                  
  Related:                    |  
------------------------------+---------------------------------------------
 GHC 7.4.1 RC2 can't build foreign export example on Mac OS X and Windows.
 (I used first version of main().)

  * http://www.haskell.org/ghc/dist/stable/docs/html/users_guide/ffi-
 ghc.html#foreign-export-ghc

 {{{
 $ 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
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5825>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list