www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Phobos Patch - Version (X86_64) for struct_stat64 on Linux x86_64

reply Chuck Blake <cb mit.edu> writes:
Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
an awful lot of file IO.

I have a small patch that fixes it by just adding a version fork for X86_64 in
the default fallback version{} (which should perhaps be labeled Linux since
all this stat stuff is *awfully* specific and brittle).  Anyway, I tested this
with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and comparing
its output to the 'stat' utility.  This fix is so basic and logic-free that I
seriously doubt environmental considerations matter, and in any event it is an
unhandled version{}.

This doesn't completely fix file IO, but it at least gives it a running
chance.  I can std.file.read() files under 8MB, for example. :)  I posted this
on Digitalmars.D.bugs which I apparently misinterpreted as the place to report
bugs and fixes.
Dec 28 2010
next sibling parent Jason House <jason.james.house gmail.com> writes:
Chuck Blake Wrote:

 Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
 I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
 an awful lot of file IO.
 
 I have a small patch that fixes it by just adding a version fork for X86_64 in
 the default fallback version{} (which should perhaps be labeled Linux since
 all this stat stuff is *awfully* specific and brittle).  Anyway, I tested this
 with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and comparing
 its output to the 'stat' utility.  This fix is so basic and logic-free that I
 seriously doubt environmental considerations matter, and in any event it is an
 unhandled version{}.
 
 This doesn't completely fix file IO, but it at least gives it a running
 chance.  I can std.file.read() files under 8MB, for example. :)  I posted this
 on Digitalmars.D.bugs which I apparently misinterpreted as the place to report
 bugs and fixes.

The correct place is bugzilla http://d.puremagic.com/issues/
Dec 28 2010
prev sibling next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
Chuck Blake wrote:
 Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
 I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
 an awful lot of file IO.
 
 I have a small patch that fixes it by just adding a version fork for X86_64 in
 the default fallback version{} (which should perhaps be labeled Linux since
 all this stat stuff is *awfully* specific and brittle).  Anyway, I tested this
 with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and comparing
 its output to the 'stat' utility.  This fix is so basic and logic-free that I
 seriously doubt environmental considerations matter, and in any event it is an
 unhandled version{}.
 
 This doesn't completely fix file IO, but it at least gives it a running
 chance.  I can std.file.read() files under 8MB, for example. :)  I posted this
 on Digitalmars.D.bugs which I apparently misinterpreted as the place to report
 bugs and fixes.
 begin 644 stat64_x86_64.patch
 M(R!(1R!C:&%N9V5S970 <&%T8V *(R!5<V5R(&-B0&UI="YE9'4*(R!$871E

This is great. Could you simply email me the files, please?
Dec 28 2010
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Chuck Blake (cb mit.edu)'s article
 Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
 I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
 an awful lot of file IO.
 I have a small patch that fixes it by just adding a version fork for X86_64 in
 the default fallback version{} (which should perhaps be labeled Linux since
 all this stat stuff is *awfully* specific and brittle).  Anyway, I tested this
 with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and comparing
 its output to the 'stat' utility.  This fix is so basic and logic-free that I
 seriously doubt environmental considerations matter, and in any event it is an
 unhandled version{}.
 This doesn't completely fix file IO, but it at least gives it a running
 chance.  I can std.file.read() files under 8MB, for example. :)  I posted this
 on Digitalmars.D.bugs which I apparently misinterpreted as the place to report
 bugs and fixes.
  << stat64_x86_64.patch >>
  << stat.d >>

Thanks! I'll test and merge this in with my next round of commits. :) Regards Iain
Dec 29 2010
prev sibling parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Chuck Blake (cb mit.edu)'s article
 Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
 I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
 an awful lot of file IO.
 I have a small patch that fixes it by just adding a version fork for X86_64 in
 the default fallback version{} (which should perhaps be labeled Linux since
 all this stat stuff is *awfully* specific and brittle).  Anyway, I tested this
 with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and comparing
 its output to the 'stat' utility.  This fix is so basic and logic-free that I
 seriously doubt environmental considerations matter, and in any event it is an
 unhandled version{}.
 This doesn't completely fix file IO, but it at least gives it a running
 chance.  I can std.file.read() files under 8MB, for example. :)  I posted this
 on Digitalmars.D.bugs which I apparently misinterpreted as the place to report
 bugs and fixes.
  << stat64_x86_64.patch >>
  << stat.d >>

OK, I've had a proper look, is there any reason why phobos isn't using the stat_t implementation in druntime? That would fix this... Regards
Dec 30 2010
next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Iain Buclaw (ibuclaw ubuntu.com)'s article
 == Quote from Chuck Blake (cb mit.edu)'s article
 Hi.  I realize that 64-bit phobos is relatively work in progress.  I thought
 I'd contribute.  struct_stat64 is broken on Linux x86_64 which further breaks
 an awful lot of file IO.
 I have a small patch that fixes it by just adding a version fork for X86_64


 the default fallback version{} (which should perhaps be labeled Linux since
 all this stat stuff is *awfully* specific and brittle).  Anyway, I tested


 with gdc 2.051 within gcc-4.5.2, with an attached stat.d program and


 its output to the 'stat' utility.  This fix is so basic and logic-free that I
 seriously doubt environmental considerations matter, and in any event it is


 unhandled version{}.
 This doesn't completely fix file IO, but it at least gives it a running
 chance.  I can std.file.read() files under 8MB, for example. :)  I posted


 on Digitalmars.D.bugs which I apparently misinterpreted as the place to


 bugs and fixes.
  << stat64_x86_64.patch >>
  << stat.d >>


 implementation in druntime?
 That would fix this...
 Regards

The lazy fix (in my tree): diff -r 8a2198026630 d/phobos2/std/file.d --- a/d/phobos2/std/file.d Tue Dec 28 23:11:26 2010 +0000 +++ b/d/phobos2/std/file.d Thu Dec 30 13:40:42 2010 +0000 -98,6 +98,12 alias core.sys.posix.sys.stat.fstat fstat64; alias core.sys.posix.sys.stat.stat stat64; } + else version (linux) + { + alias core.sys.posix.sys.stat.stat_t struct_stat64; + alias core.sys.posix.sys.stat.fstat fstat64; + alias core.sys.posix.sys.stat.stat stat64; + } else { struct struct_stat64 // distinguish it from the stat() function Is there a bug report open for this? I'll have a look after breakfast. :) Regards
Dec 30 2010
prev sibling parent reply Sean Kelly <sean invisibleduck.org> writes:
Iain Buclaw Wrote:
 
 OK, I've had a proper look, is there any reason why phobos isn't using the
stat_t
 implementation in druntime?

No good reason. I think the 64-bit version of stat_t may be screwed up (there's a bug report for it on dsource/druntime) but I'll take care of that before the next release.
Dec 30 2010
parent Iain Buclaw <ibuclaw ubuntu.com> writes:
== Quote from Sean Kelly (sean invisibleduck.org)'s article
 Iain Buclaw Wrote:
 OK, I've had a proper look, is there any reason why phobos isn't using the


 implementation in druntime?


before the next release. You mean this one? http://d.puremagic.com/issues/show_bug.cgi?id=5206 And yes, looks like you are right. Required a little more tweaking and defining __WORDSIZE = 32 or 64 to get it correct to the C system size/alignment.
Dec 30 2010