On 23/11/2011 08:43, Eric Botcazou wrote:
> On 23/11/2011 07:28, Eric Botcazou wrote:
>>> /usr/local/src/trunk/objdir.withada/./gcc/xgcc
>>> -B/usr/local/src/trunk/objdir.withada/./gcc/
>>> -B/usr/i686-pc-cygwin/bin/ -B/usr/i686-pc-cygwin/lib/ -isystem
>>> /usr/i686-pc-cygwin/include -isystem /usr/i686-pc-cygwin/sys-include
>>> -c -g -O2 -W -Wall -gnatpg -nostdinc g-socthi.adb -o g-socthi.o
>>> g-socthi.adb:615:15: "WSASYSNOTREADY" is undefined
>>> g-socthi.adb:616:15: "WSAVERNOTSUPPORTED" is undefined
>>> g-socthi.adb:618:15: "WSANOTINITIALISED" is undefined
>>> g-socthi.adb:620:15: "WSAEDISCON" is undefined
>>> g-socthi.adb:627:15: duplication of choice value at line 575
>>> make[6]: *** [g-socthi.o] Error 1
>>> and that is beyond my grasp, there is something odd when cygwin is to
>>> use, I guess, mingw variants of files...
>>
>> But grep is your friend. See s-oscons-tmplt.c lines 1343 and below.
> Try adding defined (__CYGWIN__) to the first line.
Actually, the real problem is that the Cygwin-targeted version of gnat
shouldn't need those definitions in the first place. Cygwin provides a fairly
complete Linux/Posix feature-set, and doing an end-run around it by using the
underlying winsock API isn't usually a good idea, so I think that the better
solution is to switch over to the standard berksock implementation.
The attached patch does that, and it also switches to the standard c-malloc
implementation, as the MinGW version relies on the _msize() API that isn't
provided in Cygwin.
I also had to rejig the sysdep functions a bit, in order to make
__gnat_is_windows_xp() and __gnat_get_stack_bounds() available, else the final
link fails. (I don't know what uses those, but would guess exception
handling; we should switch that over at some point too most likely, but let's
go one step at a time. In the long run we probably ought to switch Cygwin
gnat over to use all the standard implementations and none of the MinGW
versions, but that's a larger and more complicated job, so this patch just
switches those two mentioned, which is the minimum needed to get it building
again.)
gcc/ada/ChangeLog:
* gcc-interface/Makefile.in (WIN_TARG_SUFFIX): New variable, used by
windows targets only to differentiate between MinGW and Cygwin.
(LIBGNAT_TARGET_PAIRS [windows targets]): Correctly detect cygwin,
which no longer has the '32' suffix, and use WIN_TARG_SUFFIX to choose
appropriate implementations of the sockets and memory packages.
* sysdep.c (WIN_SETMODE): New define to choose the correct spelling of
setmode/_setmode for MinGW and Cygwin, respectively.
(__gnat_set_binary_mode [windows targets]): Use the above, and enable
the windows version for Cygwin as well as MinGW.
(__gnat_set_text_mode [windows targets]): Likewise.
(__gnat_ttyname [windows targets]): Provide a Cygwin implementation
in addition to the MinGW version.
(__gnat_is_windows_xp): Make available to Cygwin as well as MinGW.
(__gnat_get_stack_bounds): Likewise.
With this patch it all builds again. Tests running, but the results have to
be better than not even building at all! OK for trunk?
cheers,
DaveK
Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in (revision 181901)
+++ gcc/ada/gcc-interface/Makefile.in (working copy)
@@ -1573,18 +1573,23 @@ ifeq ($(strip $(filter-out avr none powerpc% eabis
indepsw.adb<indepsw-gnu.adb
endif
-ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),)
+ifeq ($(strip $(filter-out cygwin% mingw32% pe,$(osys))),)
+ ifeq ($(strip $(filter-out cygwin%,$(osys))),)
+ WIN_TARG_SUFFIX=
+ else
+ WIN_TARG_SUFFIX=-mingw
+ endif
LIBGNAT_TARGET_PAIRS = \
a-dirval.adb<a-dirval-mingw.adb \
a-excpol.adb<a-excpol-abort.adb \
s-gloloc.adb<s-gloloc-mingw.adb \
s-inmaop.adb<s-inmaop-dummy.adb \
- s-memory.adb<s-memory-mingw.adb \
+ s-memory.adb<s-memory$(WIN_TARG_SUFFIX).adb \
s-taspri.ads<s-taspri-mingw.ads \
s-tasinf.adb<s-tasinf-mingw.adb \
s-tasinf.ads<s-tasinf-mingw.ads \
- g-socthi.ads<g-socthi-mingw.ads \
- g-socthi.adb<g-socthi-mingw.adb \
+ g-socthi.ads<g-socthi$(WIN_TARG_SUFFIX).ads \
+ g-socthi.adb<g-socthi$(WIN_TARG_SUFFIX).adb \
g-stsifd.adb<g-stsifd-sockets.adb \
g-soliop.ads<g-soliop-mingw.ads \
$(ATOMICS_TARGET_PAIRS)
Index: gcc/ada/sysdep.c
===================================================================
--- gcc/ada/sysdep.c (revision 181901)
+++ gcc/ada/sysdep.c (working copy)
@@ -120,38 +120,44 @@ extern struct tm *localtime_r(const time_t *, stru
*/
-#if defined(WINNT)
+#if defined (WINNT) || defined (__CYGWIN__)
const char __gnat_text_translation_required = 1;
+#ifdef __CYGWIN__
+#define WIN_SETMODE setmode
+#include <io.h>
+#else
+#define WIN_SETMODE _setmode
+#endif
+
void
__gnat_set_binary_mode (int handle)
{
- _setmode (handle, O_BINARY);
+ WIN_SETMODE (handle, O_BINARY);
}
void
__gnat_set_text_mode (int handle)
{
- _setmode (handle, O_TEXT);
+ WIN_SETMODE (handle, O_TEXT);
}
-#ifdef __MINGW32__
-#include <windows.h>
+#ifdef __CYGWIN__
-/* Return the name of the tty. Under windows there is no name for
- the tty, so this function, if connected to a tty, returns the generic name
- "console". */
-
char *
__gnat_ttyname (int filedes)
{
- if (isatty (filedes))
- return "console";
- else
- return NULL;
+ extern char *ttyname (int);
+
+ return ttyname (filedes);
}
+#endif /* __CYGWIN__ */
+
+#if defined (__CYGWIN__) || defined (__MINGW32__)
+#include <windows.h>
+
#ifndef RTX
int __gnat_is_windows_xp (void);
@@ -178,7 +184,7 @@ __gnat_is_windows_xp (void)
return is_win_xp;
}
-#endif
+#endif /* !RTX */
/* Get the bounds of the stack. The stack pointer is supposed to be
initialized to BASE when a thread is created and the stack can be extended
@@ -198,8 +204,25 @@ __gnat_get_stack_bounds (void **base, void **limit
*limit = tib->StackLimit;
}
-#endif /* !__MINGW32__ */
+#endif /* __CYGWIN__ || __MINGW32__ */
+#ifdef __MINGW32__
+
+/* Return the name of the tty. Under windows there is no name for
+ the tty, so this function, if connected to a tty, returns the generic name
+ "console". */
+
+char *
+__gnat_ttyname (int filedes)
+{
+ if (isatty (filedes))
+ return "console";
+ else
+ return NULL;
+}
+
+#endif /* __MINGW32__ */
+
#else
const char __gnat_text_translation_required = 0;