[Haskell-cafe] Re: FFI and LD_PRELOAD -> segfault

Stephan Walter news at stephan.walter.name
Sun Sep 24 16:23:07 EDT 2006


On Sun, 24 Sep 2006 21:37:32 +0300, Anatoly Zaretsky wrote:

>    ghc -Wall -optl "-shared" -o libtestffi.so \
>      hsinit.c testffi.o testffi_stub.o

Ok, that is even shorter. And it seems you don't have to call
hs_add_root() or hs_exit(). At least for me it works with this hsinit.c:

  #include <HsFFI.h>
  static void __attribute__ ((constructor)) my_init(void)
  {
  	hs_init(0, 0);
  }

I put everything I've figured out so far on my wiki:
http://stephan.walter.name/Overriding_shared_libraries_with_Haskell

Warning: I'm a complete Haskell newbie, but I appreciate comments!

-Stephan



More information about the Haskell-Cafe mailing list