2

As the title says, i am trying to find a way to enable largefile support on a project which uses autotools. I am using the AC_SYS_LARGEFILE macro on the configure.ac file and it works fine on 64 bit Linux (by default) and 32 bit Linux. Now i ported the project so it can compile on Windows (32 bits) using mingw but sadly the AC_SYS_LARGEFILE doesn't work (for example off_t is 4 bytes while on Linux is 8 in both 32 and 64 bits and fopen/fstat isn't replaced by fopen64/fstat64).

Here is a testcase where i can reproduce one of the problems (off_t is 4 bytes):

configure.ac

AC_INIT([testcase], [1.0.0], [[email protected]])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
# Support for large files in 32bit systems
AC_SYS_LARGEFILE
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

Makefile.am

ACLOCAL_AMFLAGS=-I m4

bin_PROGRAMS=testcase
testcase_SOURCES=testcase.c
testcase_CFLAGS= -std=gnu99 -O2

testcase.c

#include "config.h"
#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("sizeof off_t: %i bytes\n", sizeof(off_t));
    return 0;
}

to compile/run the testcase i am using the following:

mkdir m4
autoreconf --install
./configure
make
./testcase

Output on 64-bit Linux (used gcc/autotools)

sizeof off_t: 8 bytes

Output on 32-bit Linux (used gcc/autotools)

sizeof off_t: 8 bytes

Output on Windows 7 32-bit (used mingw-get to prepare the environment):

sizeof off_t: 4 bytes

Any ideas about what i can add/modify in the configure script so i can get largefile support on both platforms? Is this possible using mingw/autotools?

1 Answer 1

2

Switched to the mingw-w64 project who despite the name, have a 32bit compiler who has proper largefile support. I am not sure if is a bug or a limitation of the original mingw32 project since i couldn't find a source of this problem in other projects.

Configure output with host=i686-pc-mingw32

...
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... unknown
checking for _LARGE_FILES value needed for large files... unknown
checking that generated files are newer than configure... done
...

Configure output with host=i686-w64-mingw32

...
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking that generated files are newer than configure... done
...

The 2nd one generates a 32bit executable who outputs the correct value. To put in short: the problem was in the compiler and not in autotools.

I am still interested in an answer of why the original mingw32 has this problem and if this issue is solvable.

1
  • I found it was mingw-w64 r4036 which added LFS. You can see in _mingw_off_t.h that they set their own off_t which doesn't conform to the native Windows' long (always 32-bit), but therefore does allow _FILE_OFFSET_BITS to work.
    – Josh Stone
    Commented Oct 12, 2015 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.