GHC static binaries with glibc-2.12?

Simon Marlow marlowsd at
Mon Oct 11 05:11:47 EDT 2010

On 10/10/2010 05:22, Alexander Dunlap wrote:
> On Fri, Oct 8, 2010 at 12:46 AM, Simon Marlow<marlowsd at>  wrote:
>> On 08/10/2010 03:23, Alexander Dunlap wrote:
>>> I recently upgraded my Arch Linux system to glibc 2.12 and static
>>> binaries compiled with GHC 6.12.3 all fail with the message
>>> "mkTextEncoding: invalid argument (Invalid argument)". This did not
>>> happen with glibc 2.11. Has anyone else had this problem? Does anyone
>>> have any advice for debugging it?
>> Probably something to do with iconv.  Doesn't iconv need to load its codec
>> modules dynamically at runtime?
>> Cheers,
>>         Simon
> Yes, it does, but strace seems to show that the program is looking in
> the right place for the iconv libraries. Is there some way to step
> through the code of a statically-linked program? I'm not sure how to
> proceed debugging a Haskell-originated error that only occurs with
> static linking (so I can't use the GHCi debugger).

The error is almost certainly being returned by iconv(), which is called 
via this wrapper in base/cbits/iconv.c:

size_t hs_iconv(iconv_t cd,
		const char* * inbuf, size_t * inbytesleft,
		char* * outbuf, size_t * outbytesleft)
     // (void*) cast avoids a warning.  Some iconvs use (const
     // char**inbuf), other use (char **inbuf).
     return iconv(cd, (void*)inbuf, inbytesleft, outbuf, outbytesleft);

you could run the program in gdb and set a breakpoint on hs_iconv, or 
iconv itself.  Since it will be compiled without debugging information 
you'll have to poke around on the C stack yourself to find the arguments.

Alternatively get a GHC build and instrument the code in 
libraries/base/GHC/IO/Encoding/IConv.hs to see what's going on.


More information about the Glasgow-haskell-users mailing list