[Template-haskell] Re: Calling foreign functions in a splice doesn't work
Andre Pang
ozone@algorithm.com.au
Tue, 13 May 2003 14:46:26 +1000
On Tuesday, May 13, 2003, at 01:14 AM, Andr=E9 Pang wrote:
> I suspect the compilation isn't working because the 'myDouble' symbol=20=
> in c_double.o isn't being loaded _at splice time_ into the list of=20
> symbols that GHC knows about -- which is also why the exception=20
> occurs. I've tried all sorts of kludges to convince GHC to load the=20=
> symbol from the foreign object file, like doing "ar rcs libcdouble.a=20=
> c_double.o" and then putting -L. -lcdouble on the commandline, passing=20=
> additional linker/compiler flags with -optl and -optc, etc, and none=20=
> of them have worked so far.
>
> This was tested with GHC on Mac OS X built from CVS 9 March 2003; my=20=
> apologies for a fairly out-of-date GHC build, but I'm having trouble=20=
> building the recent GHCs on Mac OS X. Can somebody verify that this=20=
> also occurs on Linux with a recent build of GHC, and hopefully fix it=20=
> or give me a clue on where to start looking for the bug?
I just built a GHC from a few hours ago (and updated the types for=20
Templates.hs so that it outputs an ExpQ instead of Expr), and it=20
exhibits the same "can't find symbol" bug, although it doesn't throw an=20=
exception now:
14:42 ~/th/ffi-bug %=20
/usr/local/packages/fptools.2003.05.13/bin/ghc-5.05 -fglasgow-exts=20
--make SplicerFFI.hs
Chasing modules from: SplicerFFI.hs
Compiling TemplatesFFI ( TemplatesFFI.hs, ./TemplatesFFI.o )
Compiling Main ( SplicerFFI.hs, ./SplicerFFI.o )
Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package haskell-src ... linking ... done.
TemplatesFFI.o: unknown symbol `_myDouble'
14:42[1] ~/th/ffi-bug %
I tried replacing with the "--make" option with "-c c_double.o" and the=20=
result's the same. So I guess this hasn't been fixed yet in the HEAD=20
branch -- maybe there's a small chance it'll work on Linux?
--=20
% Andre Pang : just.your.average.bounty.hunter=