Bug 40578 - FOPEN double defined used in ada/adaint.h:58
Summary: FOPEN double defined used in ada/adaint.h:58
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Dave Korn
URL:
Keywords:
: 40857 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-06-29 05:52 UTC by Christian Joensson
Modified: 2010-03-23 01:58 UTC (History)
6 users (show)

See Also:
Host: i686-pc-cygwin
Target: i686-pc-cygwin
Build: i686-pc-cygwin
Known to work:
Known to fail:
Last reconfirmed: 2009-07-25 16:07:39


Attachments
Rename macros with GNAT_ prefix (1.56 KB, patch)
2009-07-25 16:14 UTC, Dave Korn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Joensson 2009-06-29 05:52:02 UTC
As of commit r149007 (enabling -Werror when building with language Ada), I get these errors on current cygwin:

/usr/local/src/trunk/objdir/./prev-gcc/xgcc -B/usr/local/src/trunk/objdir/./prev-gcc/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/lib/ -isystem /usr/local/i686-pc-cygwin/include -isystem /usr/local/i686-pc-cygwin/sys-include    -c  -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes  -Wmissing-format-attribute -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber    ../../gcc/gcc/ada/cstreams.c -o ada/cstreams.o
cc1: warnings being treated as errors
In file included from ../../gcc/gcc/ada/cstreams.c:47:0:
../../gcc/gcc/ada/adaint.h:58:0: error: "FOPEN" redefined
/usr/include/sys/_default_fcntl.h:95:0: note: this is the location of the previous definition
make[3]: *** [ada/cstreams.o] Error 1

/usr/local/src/trunk/objdir/./prev-gcc/xgcc -B/usr/local/src/trunk/objdir/./prev-gcc/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/lib/ -isystem /usr/local/i686-pc-cygwin/include -isystem /usr/local/i686-pc-cygwin/sys-include    -c  -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes  -Wmissing-format-attribute -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H  \
		 -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber    -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber   ../../gcc/gcc/ada/cio.c -o ada/cio.o
cc1: warnings being treated as errors
In file included from ../../gcc/gcc/ada/cio.c:41:0:
../../gcc/gcc/ada/adaint.h:58:0: error: "FOPEN" redefined
/usr/include/sys/_default_fcntl.h:95:0: note: this is the location of the previous definition
make[3]: *** [ada/cio.o] Error 1

/usr/local/src/trunk/objdir/./prev-gcc/xgcc -B/usr/local/src/trunk/objdir/./prev-gcc/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/lib/ -isystem /usr/local/i686-pc-cygwin/include -isystem /usr/local/i686-pc-cygwin/sys-include    -c  -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes  -Wmissing-format-attribute -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H  \
		 -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber    -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber   ../../gcc/gcc/ada/cio.c -o ada/cio.o
cc1: warnings being treated as errors
In file included from ../../gcc/gcc/ada/cio.c:41:0:
../../gcc/gcc/ada/adaint.h:58:0: error: "FOPEN" redefined
/usr/include/sys/_default_fcntl.h:95:0: note: this is the location of the previous definition
make[3]: *** [ada/cio.o] Error 1

/usr/local/src/trunk/objdir/./prev-gcc/xgcc -B/usr/local/src/trunk/objdir/./prev-gcc/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/lib/ -isystem /usr/local/i686-pc-cygwin/include -isystem /usr/local/i686-pc-cygwin/sys-include    -c  -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes  -Wmissing-format-attribute -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H  \
		 -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber    -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber   ../../gcc/gcc/ada/raise.c -o ada/raise.o
cc1: warnings being treated as errors
In file included from ../../gcc/gcc/ada/raise.c:46:0:
../../gcc/gcc/ada/adaint.h:58:0: error: "FOPEN" redefined
/usr/include/sys/_default_fcntl.h:95:0: note: this is the location of the previous definition
make[3]: *** [ada/raise.o] Error 1

/usr/local/src/trunk/objdir/./prev-gcc/xgcc -B/usr/local/src/trunk/objdir/./prev-gcc/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/lib/ -isystem /usr/local/i686-pc-cygwin/include -isystem /usr/local/i686-pc-cygwin/sys-include    -c  -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes  -Wmissing-format-attribute -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H  \
		 -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber    -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber   ../../gcc/gcc/ada/raise.c -o ada/raise.o
cc1: warnings being treated as errors
In file included from ../../gcc/gcc/ada/raise.c:46:0:
../../gcc/gcc/ada/adaint.h:58:0: error: "FOPEN" redefined
/usr/include/sys/_default_fcntl.h:95:0: note: this is the location of the previous definition
make[3]: *** [ada/raise.o] Error 1

/usr/local/src/trunk/objdir/./prev-gcc/xgcc -B/usr/local/src/trunk/objdir/./prev-gcc/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/bin/ -B/usr/local/i686-pc-cygwin/lib/ -isystem /usr/local/i686-pc-cygwin/include -isystem /usr/local/i686-pc-cygwin/sys-include    -c  -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes  -Wmissing-format-attribute -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber    ../../gcc/gcc/ada/exit.c -o ada/exit.o
cc1: warnings being treated as errors
In file included from ../../gcc/gcc/ada/exit.c:45:0:
../../gcc/gcc/ada/adaint.h:58:0: error: "FOPEN" redefined
/usr/include/sys/_default_fcntl.h:95:0: note: this is the location of the previous definition
make[3]: *** [ada/exit.o] Error 1
Comment 1 Kai Tietz 2009-06-29 11:54:41 UTC
Well, I see. A redefinition issue. Does the following patch fixes your issue?

Index: gcc/gcc/ada/adaint.h
===================================================================
--- gcc.orig/gcc/ada/adaint.h   2009-06-22 15:57:24.000000000 +0200
+++ gcc/gcc/ada/adaint.h        2009-06-29 13:52:18.896879700 +0200
@@ -48,6 +48,12 @@
    large files. For now we just list the platforms we have manually
    tested.  */

+#undef FOPEN
+#undef STAT
+#undef FSTAT
+#undef LSTAT
+#undef STRUCT_STAT
+
 #if defined (__GLIBC__) || defined (sun)  || defined (__sgi)
 #define FOPEN fopen64
 #define STAT stat64
Comment 2 Laurent GUERBY 2009-06-29 12:10:58 UTC
Might be safer to rename to GNAT_FOPEN or something like that? FOPEN is likely to be taken on more than one platform.
Comment 3 Kai Tietz 2009-06-29 12:45:48 UTC
Yeah, this would be the best way to solve this.
Comment 4 Christian Joensson 2009-07-01 07:02:55 UTC
(In reply to comment #2)
> Might be safer to rename to GNAT_FOPEN or something like that? FOPEN is likely
> to be taken on more than one platform.

Which line are you suggesting I test change? I initially thought you meant to just change line no. 58 into reading

Index: gcc/ada/adaint.h
===================================================================
--- gcc/ada/adaint.h    (revision 149128)
+++ gcc/ada/adaint.h    (working copy)
@@ -55,7 +55,7 @@
 #define LSTAT lstat64
 #define STRUCT_STAT struct stat64
 #else
-#define FOPEN fopen
+#define GNAT_FOPEN fopen
 #define STAT stat
 #define FSTAT fstat
 #define LSTAT lstat

but that just got me into this error:

gcc -c  -g -fkeep-inline-functions -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes  -Wmissing-format-attribute -Wold-style-definition -fno-common -Wno-error -DHAVE_CONFIG_H -I. -Iada -I../../gcc/gcc -I../../gcc/gcc/ada -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -Iyes/include   -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber    ../../gcc/gcc/ada/adaint.c -o ada/adaint.o
../../gcc/gcc/ada/adaint.c: In function `__gnat_fopen':
../../gcc/gcc/ada/adaint.c:778: error: called object is not a function
../../gcc/gcc/ada/adaint.c: In function `__gnat_to_canonical_file_list_next':
../../gcc/gcc/ada/adaint.c:3247: warning: cast discards qualifiers from pointer target type
make[3]: *** [ada/adaint.o] Error 1
make[3]: Leaving directory `/usr/local/src/trunk/objdir/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/usr/local/src/trunk/objdir'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/usr/local/src/trunk/objdir'
make: *** [all] Error 2
Comment 5 Dave Korn 2009-07-04 15:56:07 UTC
(In reply to comment #4)
> (In reply to comment #2)
> > Might be safer to rename to GNAT_FOPEN or something like that? FOPEN is likely
> > to be taken on more than one platform.
> 
> Which line are you suggesting I test change? I initially thought you meant to
> just change line no. 58 into reading
> 
> Index: gcc/ada/adaint.h
> ===================================================================
> --- gcc/ada/adaint.h    (revision 149128)
> +++ gcc/ada/adaint.h    (working copy)
> @@ -55,7 +55,7 @@
>  #define LSTAT lstat64
>  #define STRUCT_STAT struct stat64
>  #else
> -#define FOPEN fopen
> +#define GNAT_FOPEN fopen
>  #define STAT stat
>  #define FSTAT fstat
>  #define LSTAT lstat
> 
> but that just got me into this error:

> ../../gcc/gcc/ada/adaint.c: In function `__gnat_fopen':
> ../../gcc/gcc/ada/adaint.c:778: error: called object is not a function

  It's no good just changing the definition if you don't change the use as well!  That's the line of adaint.c that references the FOPEN macro; it's now picking up whatever the system definition of FOPEN is that cause the probem in the first place, which probably makes for mangled gibberish source code.  Change it to also use GNAT_FOPEN!  (Also before this patch would be ready for mainline it would also be necessary to change the 64-bit definition of FOPEN to GNAT_FOPEN as well.)

$ grep -n FOPEN adaint.*
adaint.c:778:  return FOPEN (path, mode);
adaint.h:52:#define FOPEN fopen64
adaint.h:58:#define FOPEN fopen

Comment 6 Dave Korn 2009-07-25 16:06:58 UTC
*** Bug 40857 has been marked as a duplicate of this bug. ***
Comment 7 Dave Korn 2009-07-25 16:14:32 UTC
Created attachment 18253 [details]
Rename macros with GNAT_ prefix

Now testing this (respun) version of the fix I originally suggested to bug 40857
Comment 8 Dave Korn 2009-07-26 15:09:26 UTC
Subject: Bug 40578

Author: davek
Date: Sun Jul 26 15:09:10 2009
New Revision: 150098

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150098
Log:
	PR bootstrap/40578
	* adaint.h (FOPEN, STAT, FSTAT, LSTAT, STRUCT_STAT): Rename from these
	(GNAT_FOPEN, GNAT_STAT, GNAT_FSTAT, GNAT_LSTAT, GNAT_STRUCT_STAT): ...
	to these.
	(__gnat_stat): Adjust reference to STAT in prototype.
	* adaint.c (__gnat_try_lock, __gnat_fopen, __gnat_file_length,
	__gnat_named_file_length, __gnat_file_time_name, __gnat_file_time_fd,
	__gnat_get_libraries_from_registry, __gnat_stat, __gnat_file_exists,
	__gnat_is_regular_file, __gnat_is_directory, __gnat_is_readable_file,
	__gnat_is_writable_file, __gnat_is_executable_file,
	__gnat_set_writable, __gnat_set_executable, __gnat_set_non_writable,
	__gnat_set_readable, __gnat_set_non_readable, __gnat_is_symbolic_link,
	__gnat_copy_attribs): Adjust all references to the above.
	* cstreams.c (__gnat_is_regular_file_fd): Likewise.


Modified:
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/adaint.c
    trunk/gcc/ada/adaint.h
    trunk/gcc/ada/cstreams.c

Comment 9 Dave Korn 2009-07-26 15:13:46 UTC
All done now.
Comment 10 Ludovic Brenta 2009-08-18 12:10:14 UTC
Does the fix mean that GNAT does not support large files on any platform?
Comment 11 Dave Korn 2009-08-18 13:36:54 UTC
(In reply to comment #10)
> Does the fix mean that GNAT does not support large files on any platform?
> 

No need to worry, that was reason why I mentioned it would be necessary to change the 64-bit definition as well, back in comment #5, and that's what I did in the final patch.  Large file support in GNAT is entirely unchanged.