Bug #2588

Forced definition of stati64 and _stati64 under MinGW

Added by Luis Lavena about 5 years ago. Updated almost 4 years ago.

[ruby-core:27516]
Status:Closed
Priority:Normal
Assignee:-
ruby -v:ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mingw32] Backport:

Description

=begin
Appears that stati64 and _stati64 definition is being forced for non-MS compilers:

#if defined(BORLANDC)
#define stati64(path, st) rb_w32_stati64(path, st)
#elif !defined(MSC_VER) || RT_VER < 80
#define stati64 _stati64
#define _stati64(path, st) rb_w32_stati64(path, st)
#else
#define stati64 _stat64
#define _stat64(path, st) rb
w32_stati64(path, st)
#define _fstati64 _fstat64
#endif

Generating the following error during compilation:

In file included from ../include/ruby/defines.h:205:0,
from ../include/ruby/ruby.h:73,
from ../include/ruby.h:32,
from ../main.c:13:
../include/ruby/win32.h:182:0: warning: "stati64" redefined
c:/msys/system64/lib/gcc/../../x86_64-w64-mingw32/include/sys/stat.h:71:0: note: this is the location of the previous definition
../include/ruby/win32.h:181:17: warning: 'struct stati64' declared inside parameter list
../include/ruby/win32.h:181:17: warning: its scope is only this definition or declaration, which is probably not what you want
gcc -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -I. -I.ext/include/x86
64-mingw32 -I../include -I.. -DRUBY_EXPORT -o dln.o -c ../dln.c
In file included from ../include/ruby/defines.h:205:0,
from ../include/ruby/ruby.h:73,
from ../dln.c:13:
../include/ruby/win32.h:182:0: warning: "
stati64" redefined
c:/msys/system64/lib/gcc/../../x86_64-w64-mingw32/include/sys/stat.h:71:0: note: this is the location of the previous definition
../include/ruby/win32.h:181:17: warning: 'struct stati64' declared inside parameter list
../include/ruby/win32.h:181:17: warning: its scope is only this definition or declaration, which is probably not what you want
In file included from ../include/ruby/defines.h:205:0,
from ../include/ruby/ruby.h:73,
from ../dln.c:13:
../include/ruby/win32.h: In function 'dln
find_1':
../dln.c:1551:17: error: storage size of 'st' isn't known
make: *** [dln.o] Error 1

Seems that latest MinGW defines stati64 properly in sys/stat.h, according to this MSDN article:

http://msdn.microsoft.com/en-us/library/14h5k7ff(VS.71).aspx

The following is the output of compiled GCC code for 32 and 64 bits:

Luis@KEORE ~/Desktop
$ gcc -m32 crt_stat.c -o crt_stat32.exe

Luis@KEORE ~/Desktop
$ gcc crt_stat.c -o crt_stat64.exe

Luis@KEORE ~/Desktop
$ crt_stat32.exe
File size : 698
Drive : C:
Time modified : Sun Jan 10 06:19:17 2010

Luis@KEORE ~/Desktop
$ crt_stat64.exe
File size : 698
Drive : C:
Time modified : Sun Jan 10 06:19:17 2010

Which indicates the problem is not the function, but maybe some incompatibility with Ruby itself?

Please, if possible, let me know any other detail to understand this implementation so I can provide a patch for it.

Thank you.
=end

History

#1 Updated by Luis Lavena over 4 years ago

=begin
Hello,

Any status update on this? _stati64 is still defined and is not allowing x64 MinGW compilers successfully build Ruby.

As the MSDN article example shows, newer version of GCC (> 3.4.5) already define _stati64.

Thank you for your time.
=end

#2 Updated by Nobuyoshi Nakada over 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r28811.
Luis, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

#3 Updated by Luis Lavena over 4 years ago

=begin
Can this be backported to ruby_1_9_2? Thank you.
=end

Also available in: Atom PDF