Bug 13292 - Binutils uses "struct stat" instead of "#include <sys/stat.h>"
Summary: Binutils uses "struct stat" instead of "#include <sys/stat.h>"
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-13 14:38 UTC by Pau Garcia i Quiles
Modified: 2011-10-24 11:26 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Fix (458 bytes, application/octet-stream)
2011-10-13 14:38 UTC, Pau Garcia i Quiles
Details
Fix (patch bfd-in.h) (481 bytes, patch)
2011-10-20 10:07 UTC, Pau Garcia i Quiles
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pau Garcia i Quiles 2011-10-13 14:38:40 UTC
Created attachment 5984 [details]
Fix

mingw-w64 recently implemented support for large files using _FILE_OFFSET_BITS=64.

Binutils uses "struct stat" instead of "#include <sys/stat.h>", which makes it fail to compile with mingw-w64 trunk.

The attached patch fixes the issue.
Comment 1 Alen Skondro 2011-10-19 17:44:21 UTC
(In reply to comment #0)
> Created attachment 5984 [details]
> Fix
> 
> mingw-w64 recently implemented support for large files using
> _FILE_OFFSET_BITS=64.
> 
> Binutils uses "struct stat" instead of "#include <sys/stat.h>", which makes it
> fail to compile with mingw-w64 trunk.
> 
> The attached patch fixes the issue.

I think you shouldn't edit bfd/bfd-in2.h since it is auto generated.
The bfd-in.h is the file you want to patch, I guess.

The patch doesn't seem to solve the problem for me.

Do you have the issue bfd/archive.c?
Comment 2 Pau Garcia i Quiles 2011-10-20 10:06:32 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > Created attachment 5984 [details]
> > Fix
> > 
> > mingw-w64 recently implemented support for large files using
> > _FILE_OFFSET_BITS=64.
> > 
> > Binutils uses "struct stat" instead of "#include <sys/stat.h>", which makes it
> > fail to compile with mingw-w64 trunk.
> > 
> > The attached patch fixes the issue.
> 
> I think you shouldn't edit bfd/bfd-in2.h since it is auto generated.
> The bfd-in.h is the file you want to patch, I guess.

You are right. I'm attaching a new patch against bfd/bfd-in.h (which is essentially the same).


> The patch doesn't seem to solve the problem for me.

What is the problem you are experiencing now? What compiler are you trying?


> Do you have the issue bfd/archive.c?

Sorry, I don't understand :-?
Comment 3 Pau Garcia i Quiles 2011-10-20 10:07:43 UTC
Created attachment 6020 [details]
Fix (patch bfd-in.h)
Comment 4 Alen Skondro 2011-10-20 12:02:39 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > (In reply to comment #0)
> > > Created attachment 5984 [details]
> > > Fix
> > > 
> > > mingw-w64 recently implemented support for large files using
> > > _FILE_OFFSET_BITS=64.
> > > 
> > > Binutils uses "struct stat" instead of "#include <sys/stat.h>", which makes it
> > > fail to compile with mingw-w64 trunk.
> > > 
> > > The attached patch fixes the issue.
> > 
> > I think you shouldn't edit bfd/bfd-in2.h since it is auto generated.
> > The bfd-in.h is the file you want to patch, I guess.
> 
> You are right. I'm attaching a new patch against bfd/bfd-in.h (which is
> essentially the same).
> 
> 
> > The patch doesn't seem to solve the problem for me.
> 
> What is the problem you are experiencing now? What compiler are you trying?

I'm using gcc 4.7 (trunk).

../../../binutils/bfd/archive.c: In function 'bfd_ar_hdr_from_filesystem':
../../../binutils/bfd/archive.c:1841:7: error: passing argument 1 of 'time' from incompatible pointer type [-Werror]
In file included from j:\cross-gcc\bin\../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/include/sys/time.h:10:0,
                 from ../../../binutils/bfd/sysdep.h:64,
                 from ../../../binutils/bfd/archive.c:130:
j:\cross-gcc\bin\../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/include/time.h:241:29: note: expected 'time_t *' but argument is of type '__time64_t *'
cc1.exe: all warnings being treated as errors


> 
> 
> > Do you have the issue bfd/archive.c?
> 
> Sorry, I don't understand :-?

Sorry, I wanted to ask if you also experienced the compile error in bfd/archive.c or somewhere else?
Comment 5 Pau Garcia i Quiles 2011-10-20 12:29:30 UTC
(In reply to comment #4)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > (In reply to comment #0)
> > > > Created attachment 5984 [details]
> > > > Fix
> > > > 
> > > > mingw-w64 recently implemented support for large files using
> > > > _FILE_OFFSET_BITS=64.
> > > > 
> > > > Binutils uses "struct stat" instead of "#include <sys/stat.h>", which makes it
> > > > fail to compile with mingw-w64 trunk.
> > > > 
> > > > The attached patch fixes the issue.
> > > 
> > > I think you shouldn't edit bfd/bfd-in2.h since it is auto generated.
> > > The bfd-in.h is the file you want to patch, I guess.
> > 
> > You are right. I'm attaching a new patch against bfd/bfd-in.h (which is
> > essentially the same).
> > 
> > 
> > > The patch doesn't seem to solve the problem for me.
> > 
> > What is the problem you are experiencing now? What compiler are you trying?
> 
> I'm using gcc 4.7 (trunk).
> 
> ../../../binutils/bfd/archive.c: In function 'bfd_ar_hdr_from_filesystem':
> ../../../binutils/bfd/archive.c:1841:7: error: passing argument 1 of 'time'
> from incompatible pointer type [-Werror]
> In file included from
> j:\cross-gcc\bin\../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/include/sys/time.h:10:0,
>                  from ../../../binutils/bfd/sysdep.h:64,
>                  from ../../../binutils/bfd/archive.c:130:
> j:\cross-gcc\bin\../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/include/time.h:241:29:
> note: expected 'time_t *' but argument is of type '__time64_t *'
> cc1.exe: all warnings being treated as errors

I see.

I am compiling a cross binutils CVS with gcc 4.6.1 on Linux. No, I am not seeing that problem.

> 
> > 
> > 
> > > Do you have the issue bfd/archive.c?
> > 
> > Sorry, I don't understand :-?
> 
> Sorry, I wanted to ask if you also experienced the compile error in
> bfd/archive.c or somewhere else?

No, I do not have that problem.
Comment 6 Pau Garcia i Quiles 2011-10-22 15:08:30 UTC
(In reply to comment #4)

> > What is the problem you are experiencing now? What compiler are you trying?
> 
> I'm using gcc 4.7 (trunk).
> 
> ../../../binutils/bfd/archive.c: In function 'bfd_ar_hdr_from_filesystem':
> ../../../binutils/bfd/archive.c:1841:7: error: passing argument 1 of 'time'
> from incompatible pointer type [-Werror]
> In file included from
> j:\cross-gcc\bin\../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/include/sys/time.h:10:0,
>                  from ../../../binutils/bfd/sysdep.h:64,
>                  from ../../../binutils/bfd/archive.c:130:
> j:\cross-gcc\bin\../lib/gcc/i686-w64-mingw32/4.7.0/../../../../i686-w64-mingw32/include/time.h:241:29:
> note: expected 'time_t *' but argument is of type '__time64_t *'
> cc1.exe: all warnings being treated as errors
> 
> 
> > 
> > 
> > > Do you have the issue bfd/archive.c?
> > 
> > Sorry, I don't understand :-?
> 
> Sorry, I wanted to ask if you also experienced the compile error in
> bfd/archive.c or somewhere else?

I'm seeing that problem when compiling the 32-bit version.

Compiling the 64-bit version works fine.

However, you should open a new bug for that. It's unrelated to this.
Comment 7 Pau Garcia i Quiles 2011-10-22 18:43:08 UTC
(In reply to comment #6)

> > Sorry, I wanted to ask if you also experienced the compile error in
> > bfd/archive.c or somewhere else?
> 
> I'm seeing that problem when compiling the 32-bit version.
> 
> Compiling the 64-bit version works fine.
> 
> However, you should open a new bug for that. It's unrelated to this.

Alen,

The problem with archive.c is a bug in mingw-w64. I have reported it and attached patches, please see:

https://sourceforge.net/tracker/?func=detail&aid=3427267&group_id=202880&atid=983354

Now let's stop using this as a forum :-)
Comment 8 Sourceware Commits 2011-10-24 11:23:47 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2011-10-24 11:23:41

Modified files:
	bfd            : ChangeLog bfd-in.h bfd-in2.h 

Log message:
	PR binutils/13292
	* bfd-in.h: Include <sys/stat.h> rather than forward defining
	struct stat.
	* bfd-in2.h: Regenerate.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5500&r2=1.5501
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfd-in.h.diff?cvsroot=src&r1=1.158&r2=1.159
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfd-in2.h.diff?cvsroot=src&r1=1.549&r2=1.550
Comment 9 Nick Clifton 2011-10-24 11:26:26 UTC
Hi Pau,

  Thanks for the bug report and patch.  I have checked your patch in along with the following changelog entry.

Cheers
  Nick

bfd/ChangeLog
2011-10-24  Pau Garcia i Quiles  <pgquiles@elpauer.org>

	PR binutils/13292
	* bfd-in.h: Include <sys/stat.h> rather than forward defining
	struct stat.
	* bfd-in2.h: Regenerate.