[Haskell-cafe] [Haskell] Linker flags for foreign export.

Jason Dusek jason.dusek at gmail.com
Sun Mar 13 23:02:34 CET 2011


  I have managed to get both static and dynamic to work on
  Ubuntu; and I've set aside a repo on Github to collect notes
  on this stuff as I work out building on various systems.

    https://github.com/solidsnack/hso

  I need rpath for the dynamic-dynamic case on Ubuntu:

    ghc -shared -dynamic -o libfoo.dynamic-dynamic.so \
        Foo.o Foo_stub.o fooinit.o \
        -L/usr/lib/ghc-6.12.1 \
        -optl-Wl,-rpath,/usr/lib/ghc-6.12.1 \
        -lHSrts-ghc6.12.1

  The linker options in both cases could be derived
  automagically from ghc-pkg, I think.

  I've set aside dynamic-static for now (not sure what use it
  would be). It turns out there is a simpler way to write
  Foo_init:

    extern void __stginit_Foo(void);
    static void Foo_init (void) __attribute__ ((constructor));
    void Foo_init (void) {
      int argc = 1;
      char *arg = "";
      char **argv = &arg;
      hs_init(&argc, &argv);
      hs_add_root(__stginit_Foo);
    }

  Is there any case in which the empty string would be unsafe?

--
Jason Dusek
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments



More information about the Haskell-Cafe mailing list