https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103604

--- Comment #12 from YunQiang Su <syq at debian dot org> ---
(In reply to YunQiang Su from comment #11)
> (In reply to Iain Buclaw from comment #10)
> > (In reply to YunQiang Su from comment #6)
> > > 
> > > This patch can solve this problem: of course, we need to back port it to
> > > gcc-10/gcc-11 also.
> > > 
> > > The problem is due to that: 
> > >     N32 and N64 uses different "struct stat"
> > >     In the older version, __USE_FILE_OFFSET64 may be not defined for N64
> > >          while now, it is defined.
> > Is this patch backwards compatible though?  Perhaps the value of
> > `__USE_FILE_OFFSET64` should instead be fixed to match that of the target.
> 
> ohhh. you are right. I misunderstand this problem.

There are no previous version at all..., since all of them are broken.

And __USE_FILE_OFFSET64 for D is always defined (at least since it is introduce
into gcc).

So *stat64* function call should always be used, and stat.d has a wrong
version.

So the patch should be:

Index: gcc-12-12-20211211/src/libphobos/libdruntime/core/sys/posix/sys/stat.d
===================================================================
--- gcc-12-12-20211211.orig/src/libphobos/libdruntime/core/sys/posix/sys/stat.d
+++ gcc-12-12-20211211/src/libphobos/libdruntime/core/sys/posix/sys/stat.d
@@ -368,7 +368,7 @@ version (CRuntime_Glibc)
             }
             else
             {
-                c_long[3]   st_pad2;
+                uint[3]     st_pad2;
                 c_long      st_size;
             }
             static if (__USE_MISC || __USE_XOPEN2K8)
@@ -402,7 +402,7 @@ version (CRuntime_Glibc)
             {
                 c_long  st_blocks;
             }
-            c_long[14]  st_pad5;
+            uint[14]    st_pad5;
         }
     }
     else version (PPC)



This is the gdb ptype /o outputs:
type = struct core.sys.posix.sys.stat.stat_t {
    ulong st_dev;
    int st_pad1[3];
    ulong st_ino;
    uint st_mode;
    ulong st_nlink;
    uint st_uid;
    uint st_gid;
    ulong st_rdev;
    long st_pad2[3];
    long st_size;
    long st_atime;
    ulong st_atimensec;
    long st_mtime;
    ulong st_mtimensec;
    long st_ctime;
    ulong st_ctimensec;
    long st_blksize;
    uint st_pad4;
    long st_blocks;
    long st_pad5[14];
}



/* offset    |  size */  type = struct stat {
/*    0      |     8 */    __dev_t st_dev;
/*    8      |    12 */    int st_pad1[3];
/* XXX  4-byte hole  */
/*   24      |     8 */    __ino64_t st_ino;
/*   32      |     4 */    __mode_t st_mode;
/* XXX  4-byte hole  */
/*   40      |     8 */    __nlink_t st_nlink;
/*   48      |     4 */    __uid_t st_uid;
/*   52      |     4 */    __gid_t st_gid;
/*   56      |     8 */    __dev_t st_rdev;
/*   64      |    12 */    unsigned int st_pad2[3];
/* XXX  4-byte hole  */
/*   80      |     8 */    __off64_t st_size;
/*   88      |    16 */    struct timespec {
/*   88      |     8 */        __time_t tv_sec;
/*   96      |     8 */        __syscall_slong_t tv_nsec;

                               /* total size (bytes):   16 */
                           } st_atim;
/*  104      |    16 */    struct timespec {
/*  104      |     8 */        __time_t tv_sec;
/*  112      |     8 */        __syscall_slong_t tv_nsec;

                               /* total size (bytes):   16 */
                           } st_mtim;
/*  120      |    16 */    struct timespec {
/*  120      |     8 */        __time_t tv_sec;
/*  128      |     8 */        __syscall_slong_t tv_nsec;

                               /* total size (bytes):   16 */
                           } st_ctim;
/*  136      |     8 */    __blksize_t st_blksize;
/*  144      |     4 */    unsigned int st_pad4;
/* XXX  4-byte hole  */
/*  152      |     8 */    __blkcnt64_t st_blocks;
/*  160      |    56 */    int st_pad5[14];

                           /* total size (bytes):  216 */
                         }

Reply via email to