Bug #2588

Forced definition of stati64 and _stati64 under MinGW

Added by luislavena (Luis Lavena) over 2 years ago. Updated about 1 year ago.

[ruby-core:27516]
Status:Closed Start date:01/10/2010
Priority:Normal Due date:
Assignee:- % Done:

100%

Category:build
Target version:2.0.0
ruby -v:ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mingw32]

Description

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

<pre><code>
#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
</code></pre>

Generating the following error during compilation:

<pre>
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
</pre>

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.

Associated revisions

Revision 28811
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

* include/ruby/win32.h: latest x86_64 mingw defines stati64. [ruby-core:27516]

History

Updated by luislavena (Luis Lavena) almost 2 years ago

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.

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
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.

Updated by luislavena (Luis Lavena) almost 2 years ago

Can this be backported to ruby_1_9_2? Thank you.

Also available in: Atom PDF