Removal of #include <HsFFI.h> from template-hsc.h breaks largefile support on 32bit Linux
john at repetae.net
Fri Feb 17 23:51:35 CET 2012
On Fri, Feb 17, 2012 at 2:12 PM, Simon Marlow <marlowsd at gmail.com> wrote:
> On 17/02/12 19:36, John Meacham wrote:
>> It isn't local to a file though because it changes the ABI, for instance
>> void foo(off_t *x);
>> it will blow up if called from a file with a differently sized off_t.
> But we're talking about Haskell code here, not C code. There's no way for
> something to "blow up", the typechecker will catch any discrepancies.
> Perhaps I don't understand what problem you're thinking of - can you give
> more detail?
Someone writes a C function that returns an off_t * that is foreign
imported by a haskell
program using Ptr COff, the haskell program then writes to the output
pointer with the COff
Storable instance. However the imported function was compiled without
64 bit off_t's so it
only allocated 32 bits to be written into so some other memory gets
overwritten with garbage.
64 bit off_t's change the ABI of called C functions
much like passing -m32 or -mrtd does so should be considered a
all-or-nothing sort of thing. In
particular, when ghc compiles C code, it should make sure it does it
with the same ABI flags
as the rest of the thing being compiled.
environment as the rest of the code.
More information about the Glasgow-haskell-users