GHCi can't see 'atexit', can't load module

(I left this in cafe, but I think it is actually ghc related.) I just checked it seems not to be possible to load any module in GHCi that uses FFI to wrap the standard C function 'atexit'. When trying that, we get a message saying the symbol 'atexit' can't be found. (This is not a problem when building an executable with ghc, though.) It's easy to reproduce the problem. Just try something like this: ----- module XXX where import Foreign import Foreign.C foreign import ccall atexit :: FunPtr (IO ()) -> IO CInt ----- Load it in ghci (after ':set -XForeignFunctionInterface' to get FFI) and you will get the error. If we replace the line below for the above we don't get any error message: foreign import ccall exit :: CInt -> IO () Here, we just replaced 'atexit' by 'exit', which, according to 'nm' tool, is at the same 'libc' library that 'atexit' belongs to. Thanks, Maurício

I just checked it seems not to be possible to load any module in GHCi that uses FFI to wrap the standard C function 'atexit'. (...)
A simple workaround is to just compile the module. (...)
If I build a package (using cabal etc.) and try to load such package with 'ghci -package name' the problem persists. But, of course, there are many workarounds. Since I don't see this problem with other functions, and I see no reason for this to happen, I imagine this is a small bug. If it's not, I'll just remove 'atexit' from packages I have on hackage. Thanks, Maurício

On Tue, Aug 25, 2009 at 11:20:17PM -0300, Maurício CA wrote:
I just checked it seems not to be possible to load any module in GHCi that uses FFI to wrap the standard C function 'atexit'. When trying that, we get a message saying the symbol 'atexit' can't be found. (This is not a problem when building an executable with ghc, though.)
It looks like the problem is that atexit is defined in the static library /usr/lib/libc_nonshared.a. I think you'll have to make a C wrapper for it in your package. Thanks Ian
participants (2)
-
Ian Lynagh
-
Maurício CA