FFI breaking with -O?

Simon Marlow simonmar@microsoft.com
Tue, 10 Sep 2002 10:34:04 +0100

> I have a variety of C interfaces which are generated with hsc2hs, in
> particular a ncurses and openssl wrapper. they work perfectly when
> compiling normally, but when i use the -O or -O2 option, I end up with
> at the least a ton of C warnings on the /tmp/ghc*.hc file and in some
> cases a fatal error. as far as i can tell they relate to some odd
> interaction with the C preprocessor and the generated haskell=20
> code. I am
> not compiling with -fvia-C but it appears to be going via C=20
> anyway. Does
> anyone have any ideas why this might be the case or a=20
> workaround for the
> problem?  Perhaps if this is the case, I can force it to not=20
> compile via
> C even when optimizing?
> 	John
> (the offending code is part of 'ginsu' my gale client implemented in
> haskell http://repetae.net/john/computer/ginsu/ )

This "shouldn't" happen, although there are occasionally good reasons
why it does.  Are you including the right header files using the
-#include option?  Can you send us some sample code to test, or should I
try the whole of ginsu?

You can force non-via-C by saying -fasm.  Put this flag *after* -O,
because -O implies -fvia-C.