This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GNAT vs DW2/ZCX EH.


Dave Korn wrote:

>   I've attached my current Ada patches 

  No I haven't!  I mean, Now I have!

    cheers,
      DaveK
--- origsrc/gcc-4.3.2/gcc/ada/Makefile.in	2008-02-13 19:04:53.000000000 +0000
+++ src/gcc-4.3.2/gcc/ada/Makefile.in	2009-02-21 20:13:03.406250000 +0000
@@ -198,6 +198,10 @@
 # Type of tools build we are doing; default is not compiling tools.
 TOOLSCASE =
 
+# Which install goal to use.
+INSTALL_GNATLIB_MAIN  = install-gnatlib
+INSTALL_GNATLIB_WIN32 = unused-install-gnatlib
+
 # End of variables for you to override.
 
 all: all.indirect
@@ -1298,7 +1302,7 @@
   LIBRARY_VERSION := $(subst .,_,$(LIB_VERSION))
 endif
 
-ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),)
+ifeq ($(strip $(filter-out cygwin% mingw% pe,$(osys))),)
   LIBGNAT_TARGET_PAIRS = \
   a-dirval.adb<a-dirval-mingw.adb \
   a-excpol.adb<a-excpol-abort.adb \
@@ -1311,8 +1315,6 @@
   s-tasinf.adb<s-tasinf-mingw.adb \
   s-tasinf.ads<s-tasinf-mingw.ads \
   g-bytswa.adb<g-bytswa-x86.adb \
-  g-socthi.ads<g-socthi-mingw.ads \
-  g-socthi.adb<g-socthi-mingw.adb \
   g-stsifd.adb<g-stsifd-sockets.adb \
   g-soccon.ads<g-soccon-mingw.ads \
   g-soliop.ads<g-soliop-mingw.ads
@@ -1342,7 +1344,24 @@
     EXTRA_GNATRTL_NONTASKING_OBJS = g-regist.o
     EXTRA_GNATRTL_TASKING_OBJS=a-exetim.o
 
-    MISCLIB = -lwsock32
+    # Which install goal to use.
+    INSTALL_GNATLIB_MAIN  = unused-install-gnatlib
+    INSTALL_GNATLIB_WIN32 = install-gnatlib
+
+    # Mingw uses winsock-based sockets; cygwin uses POSIX sockets.
+    #ifneq ($(strip $(filter-out cygwin%,$(osys))),)
+    # However it doesn't seem to work too well, so use winsock for both.
+      LIBGNAT_TARGET_PAIRS += \
+      g-socthi.ads<g-socthi-mingw.ads \
+      g-socthi.adb<g-socthi-mingw.adb
+      MISCLIB = -lwsock32
+    #endif
+
+    # Set shared lib prefix (lib for mingw, cyg for cygwin)
+    WIN32_SHARED_LIB_PREFIX=lib
+    ifneq ($(strip $(filter cygwin%,$(osys))),)
+      WIN32_SHARED_LIB_PREFIX=cyg
+    endif
 
     # ??? This will be replaced by gnatlib-shared-dual-win32 when GNAT
     # auto-import support for array/record will be done.
@@ -1354,6 +1373,7 @@
   indepsw.adb<indepsw-mingw.adb
 
   EH_MECHANISM=-gcc
+  T_ADA_CFLAGS=-fexceptions
   GMEM_LIB = gmemlib
   PREFIX_OBJS = $(PREFIX_REAL_OBJS)
   EXTRA_GNATTOOLS = ../../gnatdll$(exeext)
@@ -1798,7 +1818,7 @@
 	  true; \
 	fi
 
-install-gnatlib: ../stamp-gnatlib
+$(INSTALL_GNATLIB_MAIN): ../stamp-gnatlib
 #	Create the directory before deleting it, in case the directory is
 #	a list of directories (as it may be on VMS). This ensures we are
 #	deleting the right one.
@@ -1840,6 +1860,48 @@
 	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb
 	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads
 
+$(INSTALL_GNATLIB_WIN32): ../stamp-gnatlib
+#	Create the directory before deleting it, in case the directory is
+#	a list of directories (as it may be on VMS). This ensures we are
+#	deleting the right one.  This is the win32 version.
+	-$(MKDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
+	-$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
+	$(RMDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
+	$(RMDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
+	-$(MKDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
+	-$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
+	for file in rts/*.ali; do \
+	    $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
+	done
+	-$(INSTALL_DATA) rts/g-trasym$(objext) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
+	-cd rts; for file in *$(arext);do \
+	    $(INSTALL_DATA) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
+	    $(RANLIB_FOR_TARGET) $(DESTDIR)$(ADA_RTL_OBJ_DIR)/$$file; \
+	done
+	-$(foreach file, $(EXTRA_ADALIB_FILES), \
+	    $(INSTALL_DATA_DATE) rts/$(file) $(DESTDIR)$(ADA_RTL_OBJ_DIR) && \
+	) true
+#     Install the shared libraries, if any, using $(INSTALL) instead
+#     of $(INSTALL_DATA). The latter may force a mode inappropriate
+#     for shared libraries on some targets, e.g. on HP-UX where the x
+#     permission is required.  We are win32 here.
+	for file in gnat gnarl; do \
+	   if [ -f rts/$(WIN32_SHARED_LIB_PREFIX)$${file}$(hyphen)$(LIBRARY_VERSION)$(soext) ]; then \
+	      $(INSTALL) rts/$(WIN32_SHARED_LIB_PREFIX)$${file}$(hyphen)$(LIBRARY_VERSION)$(soext) \
+			 $(DESTDIR)$(bindir); \
+	   fi; \
+	   if [ -f rts/$(WIN32_SHARED_LIB_PREFIX)$${file}$(soext) ]; then \
+	      $(LN_S) $(WIN32_SHARED_LIB_PREFIX)$${file}$(hyphen)$(LIBRARY_VERSION)$(soext) \
+	      $(DESTDIR)$(bindir)/lib$${file}$(soext); \
+	   fi; \
+	done
+# This copy must be done preserving the date on the original file.
+	for file in rts/*.ad?; do \
+	    $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_INCLUDE_DIR); \
+	done
+	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb
+	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads
+
 ../stamp-gnatlib2:
 	$(RM) rts/s-*.ali
 	$(RM) rts/s-*$(objext)
@@ -1996,14 +2058,18 @@
              gnatlib
 	$(RM) rts/libgna*$(soext)
 	cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \
-		-o libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+		-o $(WIN32_SHARED_LIB_PREFIX)gnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+		-Wl,--out-implib,libgnat$(soext)$(arext) \
 		$(GNATRTL_NONTASKING_OBJS) $(LIBGNAT_OBJS) \
-		$(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB)
+		$(SO_OPTS)$(WIN32_SHARED_LIB_PREFIX)gnat$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB) \
+		-Wl,--enable-auto-import
 	cd rts; ../../xgcc -B../../ -shared $(TARGET_LIBGCC2_CFLAGS) \
-		-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
+		-o $(WIN32_SHARED_LIB_PREFIX)gnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
+		-Wl,--out-implib,libgnarl$(soext)$(arext) \
 		$(GNATRTL_TASKING_OBJS) \
-		$(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
-		$(THREADSLIB) -Wl,libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
+		$(SO_OPTS)$(WIN32_SHARED_LIB_PREFIX)gnarl$(hyphen)$(LIBRARY_VERSION)$(soext) $(MISCLIB) \
+		-L. $(THREADSLIB) -Wl,libgnat$(soext)$(arext) \
+		-Wl,--enable-auto-import
 
 gnatlib-shared-darwin:
 	$(MAKE) $(FLAGS_TO_PASS) \
--- origsrc/gcc-4.3.2/gcc/ada/gsocket.h	2008-02-13 19:04:53.000000000 +0000
+++ src/gcc-4.3.2/gcc/ada/gsocket.h	2009-01-09 16:40:34.656250000 +0000
@@ -173,7 +173,7 @@
  * VxWorks and VMS).
  */
 
-#if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || defined (__osf__) || defined (_WIN32) || defined (__APPLE__)
+#if defined (_AIX) || defined (__FreeBSD__) || defined (__hpux__) || defined (__osf__) || defined (__CYGWIN__) || defined (_WIN32) || defined (__APPLE__)
 # define HAVE_THREAD_SAFE_GETxxxBYyyy 1
 #elif defined (sgi) || defined (linux) || (defined (sun) && defined (__SVR4) && !defined (__vxworks))
 # define HAVE_GETxxxBYyyy_R 1
--- origsrc/gcc-4.3.2/gcc/ada/initialize.c	2008-01-03 09:35:04.000000000 +0000
+++ src/gcc-4.3.2/gcc/ada/initialize.c	2009-02-21 06:04:46.093750000 +0000
@@ -192,6 +192,40 @@
   __main ();
 }
 
+#elif defined (__CYGWIN__)
+
+/* We must call __main to run the static ctors, or DW2 EH, amongst
+   other things, will fail.  */
+
+/***************************************/
+/* __gnat_initialize (Cygwin Version) */
+/***************************************/
+
+extern void __main (void);
+
+void
+__gnat_initialize (void *eh ATTRIBUTE_UNUSED)
+{
+  __main ();
+
+   /* Initialize floating-point coprocessor. This call is needed because
+      the MS libraries default to 64-bit precision instead of 80-bit
+      precision, and we require the full precision for proper operation,
+      given that we have set Max_Digits etc with this in mind */
+   __gnat_init_float ();
+
+   /* Note that we do not activate this for the compiler itself to avoid a
+      bootstrap path problem.  Older version of gnatbind will generate a call
+      to __gnat_initialize() without argument. Therefore we cannot use eh in
+      this case.  It will be possible to remove the following #ifdef at some
+      point.  */
+#ifdef IN_RTS
+   /* Install the Structured Exception handler.  */
+   if (eh)
+     __gnat_install_SEH_handler (eh);
+#endif
+}
+
 #else
 
 /* For all other versions of GNAT, the initialize routine and handler
--- origsrc/gcc-4.3.2/gcc/ada/sysdep.c	2008-01-03 09:35:04.000000000 +0000
+++ src/gcc-4.3.2/gcc/ada/sysdep.c	2009-01-09 16:40:34.656250000 +0000
@@ -397,7 +397,7 @@
 {
 #if defined (linux) || defined (sun) || defined (sgi) || defined (__EMX__) \
     || (defined (__osf__) && ! defined (__alpha_vxworks)) \
-    || defined (__CYGWIN32__) || defined (__MACHTEN__) || defined (__hpux__) \
+    || defined (__CYGWIN__) || defined (__MACHTEN__) || defined (__hpux__) \
     || defined (_AIX) || (defined (__svr4__) && defined (i386)) \
     || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__)
   char c;
@@ -684,6 +684,40 @@
 }
 
 #endif /* WINNT */
+
+#ifdef __CYGWIN__
+
+size_t _msize(void *memblock)
+{
+  return (size_t) malloc_usable_size (memblock);
+}
+
+#include <windows.h>
+
+int
+__gnat_is_windows_xp (void)
+{
+  static int is_win_xp=0, is_win_xp_checked=0;
+
+  if (!is_win_xp_checked)
+    {
+      OSVERSIONINFO version;
+
+      is_win_xp_checked = 1;
+
+      memset (&version, 0, sizeof (version));
+      version.dwOSVersionInfoSize = sizeof (version);
+
+      is_win_xp = GetVersionEx (&version)
+        && version.dwPlatformId == VER_PLATFORM_WIN32_NT
+        && (version.dwMajorVersion > 5
+            || (version.dwMajorVersion == 5 && version.dwMinorVersion >= 1));
+    }
+  return is_win_xp;
+}
+
+#endif /* __CYGWIN__ */
+
 #ifdef VMS
 
 /* This gets around a problem with using the old threads library on VMS 7.0. */
--- origsrc/gcc-4.3.2/gcc/ada/system-mingw.ads	2007-12-19 16:22:26.000000000 +0000
+++ src/gcc-4.3.2/gcc/ada/system-mingw.ads	2009-02-22 04:08:37.281250000 +0000
@@ -141,7 +141,7 @@
    Always_Compatible_Rep     : constant Boolean := True;
    Suppress_Standard_Library : constant Boolean := False;
    Use_Ada_Main_Program_Name : constant Boolean := False;
-   ZCX_By_Default            : constant Boolean := False;
+   ZCX_By_Default            : constant Boolean := True;
    GCC_ZCX_Support           : constant Boolean := True;
 
    ---------------------------
--- origsrc/gcc-4.3.2/gcc/testsuite/ada/acats/run_all.sh	2006-09-14 11:12:03.000000000 +0100
+++ src/gcc-4.3.2/gcc/testsuite/ada/acats/run_all.sh	2009-02-08 02:29:10.359375000 +0000
@@ -13,7 +13,7 @@
 gnatflags="-gnatws"
 
 target_run () {
-$*
+	$testdir/run_test.exp $1 > $2 2>&1
 }
 
 # End of customization section.
@@ -99,7 +99,7 @@
 
 # Find out the size in bit of an address on the target
 target_gnatmake $testdir/support/impbit.adb >> $dir/acats.log 2>&1
-target_run $dir/support/impbit > $dir/support/impbit.out 2>&1
+target_run $dir/support/impbit $dir/support/impbit.out
 target_bit=`cat $dir/support/impbit.out`
 echo target_bit="$target_bit" >> $dir/acats.log
 
@@ -276,7 +276,7 @@
       if [ ! -x $dir/tests/$chapter/$i/$binmain ]; then
          sync
       fi
-      target_run $dir/tests/$chapter/$i/$binmain > $dir/tests/$chapter/$i/${i}.log 2>&1
+      target_run $dir/tests/$chapter/$i/$binmain $dir/tests/$chapter/$i/${i}.log
       cd $dir/tests/$chapter/$i
       cat ${i}.log >> $dir/acats.log
       egrep -e '(==== |\+\+\+\+ |\!\!\!\! )' ${i}.log > /dev/null 2>&1
--- origsrc/gcc-4.3.2/gcc/testsuite/ada/acats/run_test.exp	1970-01-01 00:00:00.000000000 +0000
+++ src/gcc-4.3.2/gcc/testsuite/ada/acats/run_test.exp	2009-02-08 02:28:26.015625000 +0000
@@ -0,0 +1,10 @@
+#!/usr/bin/expect -f
+
+set timeout 300
+
+spawn -noecho $argv
+expect timeout {
+       send_user "Program timed out.\n"
+       exit 1
+}
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]