delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/06/13/03:21:36

X-Spam-Check-By: sourceware.org
Message-ID: <466F9B52.1000709@cwilson.fastmail.fm>
Date: Wed, 13 Jun 2007 03:22:58 -0400
From: Charles Wilson <cygwin AT cwilson DOT fastmail DOT fm>
User-Agent: Thunderbird 1.5.0.12 (Windows/20070509)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Some notes on building gcc-4.3.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------000804000006070800080709
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I was testing Danny Smith's latest DWARF-2 patch, and building gcc from 
the current (rather unsettled) trunk was a bit tricky.  So, I thought 
I'd post my experiences, which ultimately resulted in a fully 
bootstrapped native cygwin compiler, with c,c++,objc,fortran,java frontends.

Now, whether it actually *works* after installation -- dunno.  Probably, 
and bootstrapping is pretty good evidence, and building the target 
runtime libs is even better, so...

OTOH, no warranty, express or implied, WJFFM, YMMV, etc etc...



First, I had to massage the tree in the following ways (and I was using 
revision 125636):

1. patched /usr/include/stdio.h
      See: http://www.cygwin.com/ml/newlib/2007/msg00296.html
      the patch I used is attached.

2. patched classpath/native/fdlibm/mprec.h (_EXFUN issue)
      See: http://gcc.gnu.org/ml/gcc/2007-04/msg00648.html
      also attached

3. patched basic_string.[h|tcc] per pr24196
      See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196
      ditto.

4. danny's latest dwarf2 patch
      See: http://gcc.gnu.org/ml/gcc-patches/2007-05/msg02051.html
      the gcc mailing list inlined the patch, so it needed lots of hand
      fixups.  I've attached another copy here.

5. extra dwarf2 patch for cygwin.h
      It's in changelog of #4, but missing from patch...

6. fix for _GC_get_thread_stack_base issue
      See http://gcc.gnu.org/ml/gcc/2007-03/msg00790.html

I configured as:

$ ../gcc/configure \
     --prefix=${PREFIX} \
     --exec-prefix=${PREFIX} \
     --sysconfdir=${PREFIX}/etc \
     --libdir=${PREFIX}/lib \
     --libexecdir=${PREFIX}/lib \
     --with-datarootdir=${PREFIX}/share \
     --enable-languages=c,c++,objc,fortran,java \
     --with-gcc \
     --enable-nls \
     --without-included-gettext \
     --enable-version-specific-runtime-libs \
     --without-x \
     --enable-libgcj \
     --disable-java-awt \
     --with-system-zlib \
     --enable-interpreter \
     --disable-libgcj-debug \
     --enable-threads=posix \
     --enable-java-gc=boehm \
     --disable-win32-registry \
     --disable-sjlj-exceptions \
     --enable-hash-synchronization \
     --enable-libstdcxx-debug \
     --enable-cxx-flags='-fno-function-sections -fno-data-sections' \
     --disable-symvers \
     --enable-libgomp \
     --with-arch=i486 \
     --with-tune=i686 \
     --disable-werror \
     --disable-shared

Where PREFIX=/opt (I had already built and installed binutils with the 
same PREFIX).


$ make bootstrap 2>err.log 1>out.log

This made it all the way thru the three-stage bootstrap, and built most 
of the libraries.  However, the build failed in libjava, due to stack 
overflow in jc1.exe. After manually relinking cc1.exe and jc1.exe with 
100MB of stack (-Wl,--stack,102400000) as recommended here:
     http://gcc.gnu.org/ml/gcc/2007-06/msg00151.html
I kicked off the build again (see below).  Check 'out.log' to get the 
correct commandline to relink those two apps, and then just add
     -Wl,--stack,102400000

$ make all-target LDFLAGS="-L<BUILDDIR>/i686-pc-cygwin/libgcc" \
     2>err2.log 1>out2.log

NOTE: I added the absolute path to the libgcc target directory to 
LDFLAGS because otherwise, when trying to link the applications, any 
installed libgcc.a in the target ${PREFIX}/lib/gcc/${ARCH}/4.3.0/ 
directory will be used, instead of the newly built one.  In my case, the 
installed one was an older 4.3.0 version without the necessary DWARF2 
unwind symbols, and ... boom.


NOTE2: I also had a weird but transient problem with missing symbols 
related to the HTML_401F class in libjava.  As it happened, I ran out of 
virtual memory while trying to compile that class, so I ended up with a 
HTML_401F.o that had NO symbols at all.  After rebooting and shutting 
down all unnecessary processes, I was able to get that file to compile 
correctly.  It required just over 1GB of memory to compile that ONE 
file: on my 512MB machine with 1GB VM file, that was...painful.


--------------000804000006070800080709
Content-Type: text/plain;
 name="1-stdio-fix.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="1-stdio-fix.patch"

--- stdio.h.orig	2007-06-12 22:10:21.979328000 -0400
+++ stdio.h	2007-06-12 22:08:57.588703000 -0400
@@ -402,7 +402,38 @@
 #define       __sgetc_raw_r(__ptr, __f) (--(__f)->_r < 0 ? __srget_r(__ptr, __f) : (int)(*(__f)->_p++))
 
 #ifdef __SCLE
-static __inline__ int __sgetc_r(struct _reent *__ptr, FILE *__p)
+/*  For a platform with CR/LF, additional logic is required by
+  __sgetc_r which would otherwise simply be a macro; therefore we
+  use an inlined function.  The function is only meant to be inlined
+  in place as used and the function body should never be emitted.  
+
+  There are two possible means to this end when compiling with GCC,
+  one when compiling with a standard C99 compiler, and for other
+  compilers we're just stuck.  At the moment, this issue only
+  affects the Cygwin target, so we'll most likely be using GCC.
+
+  The traditional meaning of 'extern inline' for GCC is not
+  to emit the function body unless the address is explicitly
+  taken.  However this behaviour is changing to match the C99
+  standard, which uses 'extern inline' to indicate that the
+  function body *must* be emitted.  If we are using GCC, but do
+  not have the new behaviour, we need to use extern inline; if
+  we are using a new GCC with the C99-compatible behaviour, or
+  a non-GCC compiler (which we will have to hope is C99, since
+  there is no other way to achieve the effect of omitting the
+  function if it isn't referenced) we just use plain 'inline',
+  which c99 defines to mean more-or-less the same as the Gnu C
+  'extern inline'.  */
+#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
+/* We're using GCC, but without the new C99-compatible behaviour.  */
+#define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__))
+#else
+/* We're using GCC in C99 mode, or an unknown compiler which 
+  we just have to hope obeys the C99 semantics of inline.  */
+#define _ELIDABLE_INLINE __inline__
+#endif
+
+_ELIDABLE_INLINE int __sgetc_r(struct _reent *__ptr, FILE *__p)
   {
     int __c = __sgetc_raw_r(__ptr, __p);
     if ((__p->_flags & __SCLE) && (__c == '\r'))
@@ -422,7 +453,7 @@
 #ifdef _never /* __GNUC__ */
 /* If this inline is actually used, then systems using coff debugging
    info get hopelessly confused.  21sept93 rich AT cygnus DOT com.  */
-static __inline int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
+_ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
 	if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
 		return (*_p->_p++ = _c);
 	else

--------------000804000006070800080709
Content-Type: text/plain;
 name="2-cygwin-EXFUN.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="2-cygwin-EXFUN.patch"

Index: libjava/classpath/native/fdlibm/mprec.h
===================================================================
--- libjava/classpath/native/fdlibm/mprec.h	(revision 125636)
+++ libjava/classpath/native/fdlibm/mprec.h	(working copy)
@@ -294,7 +294,14 @@
 #define	_SIGNED		signed
 #define	_DOTS		, ...
 #define _VOID void
-#define	_EXFUN(name, proto)		name proto
+/* GCJ local */
+#ifndef _EXFUN
+# ifdef __CYGWIN__
+#  define _EXFUN(name, proto)		__cdecl name proto
+# else
+#  define _EXFUN(name, proto)		name proto
+# endif
+#endif
 #define	_DEFUN(name, arglist, args)	name(args)
 #define	_DEFUN_VOID(name)		name(_NOARGS)
 #define _CAST_VOID (void)

--------------000804000006070800080709
Content-Type: text/plain;
 name="3-gcc-pr24196.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="3-gcc-pr24196.patch"

Index: libstdc++-v3/include/bits/basic_string.h
===================================================================
--- libstdc++-v3/include/bits/basic_string.h	(revision 125096)
+++ libstdc++-v3/include/bits/basic_string.h	(working copy)
@@ -230,12 +230,9 @@
 	void
 	_M_dispose(const _Alloc& __a)
 	{
-#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
-	  if (__builtin_expect(this != &_S_empty_rep(), false))
-#endif
-	    if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
-						       -1) <= 0)
-	      _M_destroy(__a);
+	  if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
+						     -1) <= 0)
+	    _M_destroy(__a);
 	}  // XXX MT
 
 	void
@@ -244,10 +241,7 @@
 	_CharT*
 	_M_refcopy() throw()
 	{
-#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
-	  if (__builtin_expect(this != &_S_empty_rep(), false))
-#endif
-            __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
+          __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
 	  return _M_refdata();
 	}  // XXX MT
 
@@ -2067,11 +2061,7 @@
   template<typename _CharT, typename _Traits, typename _Alloc>
     inline basic_string<_CharT, _Traits, _Alloc>::
     basic_string()
-#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
     : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
-#else
-    : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) { }
-#endif
 
   // operator+
   /**
Index: libstdc++-v3/include/bits/basic_string.tcc
===================================================================
--- libstdc++-v3/include/bits/basic_string.tcc	(revision 125096)
+++ libstdc++-v3/include/bits/basic_string.tcc	(working copy)
@@ -83,10 +83,9 @@
       _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
 		   input_iterator_tag)
       {
-#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
 	if (__beg == __end && __a == _Alloc())
-	  return _S_empty_rep()._M_refdata();
-#endif
+	  return _S_empty_rep()._M_refcopy();
+
 	// Avoid reallocation for common case.
 	_CharT __buf[128];
 	size_type __len = 0;
@@ -129,10 +128,9 @@
       _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
 		   forward_iterator_tag)
       {
-#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
 	if (__beg == __end && __a == _Alloc())
-	  return _S_empty_rep()._M_refdata();
-#endif
+	  return _S_empty_rep()._M_refcopy();
+
 	// NB: Not required, but considered best practice.
 	if (__builtin_expect(__gnu_cxx::__is_null_pointer(__beg)
 			     && __beg != __end, 0))
@@ -158,10 +156,9 @@
     basic_string<_CharT, _Traits, _Alloc>::
     _S_construct(size_type __n, _CharT __c, const _Alloc& __a)
     {
-#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
       if (__n == 0 && __a == _Alloc())
-	return _S_empty_rep()._M_refdata();
-#endif
+	return _S_empty_rep()._M_refcopy();
+
       // Check for out_of_range and length_error exceptions.
       _Rep* __r = _Rep::_S_create(__n, size_type(0), __a);
       if (__n)
@@ -429,10 +426,9 @@
     basic_string<_CharT, _Traits, _Alloc>::
     _M_leak_hard()
     {
-#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
       if (_M_rep() == &_S_empty_rep())
 	return;
-#endif
+
       if (_M_rep()->_M_is_shared())
 	_M_mutate(0, 0, 0);
       _M_rep()->_M_set_leaked();

--------------000804000006070800080709
Content-Type: text/plain;
 name="4-gcc-dwarf2-danny-smith-20070530.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="4-gcc-dwarf2-danny-smith-20070530.patch"

Index: libgcc/config.host
===================================================================
--- libgcc/config.host	(revision 125160)
+++ libgcc/config.host	(working copy)
@@ -370,8 +370,8 @@
 i[34567]86-*-pe)
 	;;
 i[34567]86-*-cygwin* | i[34567]86-*-mingw*)
-	extra_parts="crtfastmath.o"
-	tmake_file="i386/t-crtfm"
+	extra_parts="crtbegin.o crtend.o crtfastmath.o"
+	tmake_file="i386/t-cygming i386/t-crtfm"
 	;;
 x86_64-*-mingw*)
 	;;
Index: gcc/config/i386/cygming.h
===================================================================
--- gcc/config/i386/cygming.h	(revision 125159)
+++ gcc/config/i386/cygming.h	(working copy)
@@ -51,6 +51,14 @@
    : (write_symbols == DWARF2_DEBUG			\
       ? svr4_dbx_register_map[n] : dbx_register_map[n]))
 
+
+/* Map gcc register number to DWARF 2 CFA column number. For 32 bit
+   target, always use the svr4_dbx_register_map for DWARF .eh_frame
+   even if we don't use DWARF .debug_frame. */
+#undef DWARF_FRAME_REGNUM
+#define DWARF_FRAME_REGNUM(n) TARGET_64BIT \
+	? dbx64_register_map[(n)] : svr4_dbx_register_map[(n)] 
+
 /* Use section relative relocations for debugging offsets.  Unlike
    other targets that fake this by putting the section VMA at 0, PE
    won't allow it.  */
@@ -279,12 +287,15 @@
 #undef ASM_COMMENT_START
 #define ASM_COMMENT_START " #"
 
-/* DWARF2 Unwinding doesn't work with exception handling yet.  To make
-   it work, we need to build a libgcc_s.dll, and dcrt0.o should be
-   changed to call __register_frame_info/__deregister_frame_info.  */
 #ifndef DWARF2_UNWIND_INFO
+/* If configured with --disable-sjlj-exceptions, use DWARF2, else
+   default to SJLJ  */
+#if defined (CONFIG_SJLJ_EXCEPTIONS) && !CONFIG_SJLJ_EXCEPTIONS
+#define DWARF2_UNWIND_INFO 1
+#else
 #define DWARF2_UNWIND_INFO 0
 #endif
+#endif
 
 /* Don't assume anything about the header files.  */
 #define NO_IMPLICIT_EXTERN_C
Index: gcc/config/i386/mingw32.h
===================================================================
--- gcc/config/i386/mingw32.h	(revision 125160)
+++ gcc/config/i386/mingw32.h	(working copy)
@@ -84,11 +84,13 @@
 
 #undef STARTFILE_SPEC
 #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
-  %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s}"
+  %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \
+  crtbegin.o%s"
 
 #undef ENDFILE_SPEC
 #define ENDFILE_SPEC \
-  "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
+  "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+  crtend.o%s"
 
 /* Override startfile prefix defaults.  */
 #ifndef STANDARD_STARTFILE_PREFIX_1
@@ -141,3 +143,11 @@
 /* mingw32 atexit function is safe to use in shared libraries.  Use it
    to register C++ static destructors.  */
 #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
+
+/* JCR_SECTION works on mingw32.  */
+#undef TARGET_USE_JCR_SECTION
+#define TARGET_USE_JCR_SECTION 1
+
+#if !TARGET_64BIT
+#define MD_UNWIND_SUPPORT "config/i386/w32-unwind.h"
+#endif
*** /dev/null	Wed May 30 22:39:31 2007
--- libgcc/config/i386/t-cygming	Wed May 30 21:23:21 2007
***************
*** 0 ****
--- 1,11 ----
+ CUSTOM_CRTSTUFF = yes
+ 
+ crtbegin.o: $(gcc_srcdir)/config/i386/cygming-crtbegin.c
+ 	$(crt_compile) -fno-omit-frame-pointer  -c \
+ 	$(gcc_srcdir)/config/i386/cygming-crtbegin.c
+ 
+ # We intentintionally use a implemntation-reserved init priority of 0,
+ #  so allow the warning. 
+ crtend.o: $(gcc_srcdir)/config/i386/cygming-crtend.c
+ 	$(crt_compile) -fno-omit-frame-pointer -Wno-error -c \
+ 	$(gcc_srcdir)/config/i386/cygming-crtend.c
*** /dev/null	Wed May 30 22:39:52 2007
--- gcc/config/i386/cygming-crtbegin.c	Wed May 30 22:23:56 2007
***************
*** 0 ****
--- 1,140 ----
+ /* crtbegin object for windows32 targets.
+    Copyright (C) 2007  Free Software Foundation, Inc.
+ 
+    Contributed by Danny Smith <dannysmith AT users DOT sourceforge DOT net>
+ 
+ This file is part of GCC.
+ 
+ GCC is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+ 
+ In addition to the permissions in the GNU General Public License, the
+ Free Software Foundation gives you unlimited permission to link the
+ compiled version of this file into combinations with other programs,
+ and to distribute those combinations without any restriction coming
+ from the use of this file.  (The General Public License restrictions
+ do apply in other respects; for example, they cover modification of
+ the file, and distribution when not linked into a combine
+ executable.)
+ 
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING.  If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.  */
+ 
+ /* Target machine header files require this define. */
+ #define IN_LIBGCC2
+ 
+ #include "auto-host.h"
+ #include "tconfig.h"
+ #include "tsystem.h"
+ #include "coretypes.h"
+ #include "tm.h"
+ #include "unwind-dw2-fde.h"
+ 
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ 
+ #ifndef LIBGCC_SONAME
+ #define LIBGCC_SONAME "libgcc_s.dll"
+ #endif
+ 
+ #ifndef LIBGCJ_SONAME
+ #define LIBGCJ_SONAME "libgcj_s.dll"
+ #endif
+ 
+ 
+ /* Make the declarations weak.  This is critical for
+    _Jv_RegisterClasses because it lives in libgcj.a  */
+ extern void __register_frame_info (const void *, struct object *)
+ 				   TARGET_ATTRIBUTE_WEAK;
+ extern void *__deregister_frame_info (const void *)
+ 				      TARGET_ATTRIBUTE_WEAK;
+ extern void _Jv_RegisterClasses (const void *) TARGET_ATTRIBUTE_WEAK;
+ 
+ #if defined(HAVE_LD_RO_RW_SECTION_MIXING)
+ # define EH_FRAME_SECTION_CONST const
+ #else
+ # define EH_FRAME_SECTION_CONST
+ #endif
+ 
+ /* Stick a label at the beginning of the frame unwind info so we can
+    register/deregister it with the exception handling library code. */
+ #if DWARF2_UNWIND_INFO
+ static EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[]
+   __attribute__((section(EH_FRAME_SECTION_NAME), aligned(4)))
+   = { };
+ 
+ static struct object obj;
+ #endif
+ 
+ #if TARGET_USE_JCR_SECTION
+ static void *__JCR_LIST__[]
+   __attribute__ ((unused, section(JCR_SECTION_NAME), aligned(4)))
+   = { };
+ #endif
+ 
+ /* Pull in references from libgcc.a(unwind-dw2-fde.o) in the
+    startfile. These are referenced by a ctor and dtor in crtend.o.  */
+ extern void __gcc_register_frame (void);
+ extern void __gcc_deregister_frame (void);
+ 
+ void
+ __gcc_register_frame (void)
+ {
+ #if DWARF2_UNWIND_INFO
+ /* Weak undefined symbols won't be pulled in from dlls; hence
+    we first test if the dll is already loaded and, if so,
+    get the symbol's address at run-time.  If the dll is not loaded,
+    fallback to weak linkage to static archive.  */
+ 
+   void (*register_frame_fn) (const void *, struct object *);
+   HANDLE h = GetModuleHandle (LIBGCC_SONAME);
+   if (h)
+     register_frame_fn = (void (*) (const void *, struct object *))
+ 			GetProcAddress (h, "__register_frame_info");
+   else 
+     register_frame_fn = __register_frame_info;
+   if (register_frame_fn)
+      register_frame_fn (__EH_FRAME_BEGIN__, &obj);
+ #endif
+ 
+ #if TARGET_USE_JCR_SECTION 
+   if (__JCR_LIST__[0])
+     {
+       void (*register_class_fn) (const void *);
+       HANDLE h = GetModuleHandle (LIBGCJ_SONAME);
+       if (h)
+ 	register_class_fn = (void (*) (const void *))
+ 			     GetProcAddress (h, "_Jv_RegisterClasses");
+       else
+ 	register_class_fn = _Jv_RegisterClasses;
+ 
+       if (register_class_fn)
+ 	register_class_fn (__JCR_LIST__);
+     }
+ #endif
+ }
+ 
+ void
+ __gcc_deregister_frame (void)
+ {
+ #if DWARF2_UNWIND_INFO
+   void *  (*deregister_frame_fn) (const void *);
+   HANDLE h = GetModuleHandle (LIBGCC_SONAME);
+   if (h)
+     deregister_frame_fn = (void* (*) (const void *))
+ 			  GetProcAddress (h, "__deregister_frame_info");
+   else 
+     deregister_frame_fn = __deregister_frame_info;
+   if (deregister_frame_fn)
+      deregister_frame_fn (__EH_FRAME_BEGIN__);
+ #endif
+ }
*** /dev/null	Wed May 30 22:40:01 2007
--- gcc/config/i386/cygming-crtend.c	Wed May 30 22:24:37 2007
***************
*** 0 ****
--- 1,86 ----
+ /* crtend object for windows32 targets.
+    Copyright (C) 2007  Free Software Foundation, Inc.
+ 
+    Contributed by Danny Smith <dannysmith AT users DOT sourceforge DOT net>
+ 
+ This file is part of GCC.
+ 
+ GCC is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+ 
+ In addition to the permissions in the GNU General Public License, the
+ Free Software Foundation gives you unlimited permission to link the
+ compiled version of this file into combinations with other programs,
+ and to distribute those combinations without any restriction coming
+ from the use of this file.  (The General Public License restrictions
+ do apply in other respects; for example, they cover modification of
+ the file, and distribution when not linked into a combine
+ executable.)
+ 
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING.  If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.  */
+ 
+ /* Target machine header files require this define. */
+ #define IN_LIBGCC2
+ 
+ /* auto-host.h is needed by cygming.h for HAVE_GAS_WEAK and here
+    for HAVE_LD_RO_RW_SECTION_MIXING.  */  
+ #include "auto-host.h"
+ #include "tconfig.h"
+ #include "tsystem.h"
+ #include "coretypes.h"
+ #include "tm.h"
+ #include "unwind-dw2-fde.h"
+ 
+ #if defined(HAVE_LD_RO_RW_SECTION_MIXING)
+ # define EH_FRAME_SECTION_CONST const
+ #else
+ # define EH_FRAME_SECTION_CONST
+ #endif
+ 
+ #if DWARF2_UNWIND_INFO
+ /* Terminate the frame unwind info section with a 0 as a sentinel;
+    this would be the 'length' field in a real FDE.  */
+ 
+ static EH_FRAME_SECTION_CONST int __FRAME_END__[]
+   __attribute__ ((unused,  section(EH_FRAME_SECTION_NAME),
+ 		  aligned(4)))
+   = { 0 };
+ #endif
+ 
+ #if TARGET_USE_JCR_SECTION
+ /* Null terminate the .jcr section array.  */
+ static void *__JCR_END__[1] 
+    __attribute__ ((unused, section(JCR_SECTION_NAME),
+ 		   aligned(sizeof(void *))))
+    = { 0 };
+ #endif
+ 
+ 
+ extern void __gcc_register_frame (void); 
+ extern void __gcc_deregister_frame (void);
+ 
+ static void register_frame_ctor (void) __attribute__ ((constructor (0)));
+ static void deregister_frame_dtor (void) __attribute__ ((destructor (0)));
+ 
+ 
+ static void
+ register_frame_ctor (void)
+ {
+   __gcc_register_frame ();
+ }
+ 
+ static void
+ deregister_frame_dtor (void)
+ {
+   __gcc_deregister_frame ();
+ }
*** /dev/null	Wed May 30 22:40:16 2007
--- gcc/config/i386/w32-unwind.h	Wed May 30 22:19:58 2007
***************
*** 0 ****
--- 1,215 ----
+ /* Definitions for Dwarf2 EH unwind support for Windows32 targets 
+    Copyright (C) 2007
+    Free Software Foundation, Inc.
+    Contributed by Pascal Obry  <obry AT adacore DOT com>
+ 
+ This file is part of GCC.
+ 
+ GCC is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+ 
+ In addition to the permissions in the GNU General Public License, the
+ Free Software Foundation gives you unlimited permission to link the
+ compiled version of this file with other programs, and to distribute
+ those programs without any restriction coming from the use of this
+ file.  (The General Public License restrictions do apply in other
+ respects; for example, they cover modification of the file, and
+ distribution when not linked into another program.)
+ 
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING.  If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.  */
+ 
+ /* This file implements the md_fallback_frame_state_for routine for Windows,
+    triggered when the GCC table based unwinding process hits a frame for which
+    no unwind info has been registered. This typically occurs when raising an
+    exception from a signal handler, because the handler is actually called
+    from the OS kernel.
+ 
+    The basic idea is to detect that we are indeed trying to unwind past a
+    signal handler and to fill out the GCC internal unwinding structures for
+    the OS kernel frame as if it had been directly called from the interrupted
+    context.
+ 
+    This is all assuming that the code to set the handler asked the kernel to
+    pass a pointer to such context information.
+ 
+    There is three main parts.
+ 
+    1) The first thing to do is to check if we are in a signal context. If not
+       we can just return as there is nothing to do. We are probably on some
+       foreign code for which no unwind frame can be found. If this is a call
+       from the Windows signal handler, then:
+ 
+    2) We must get the signal context information. 
+ 
+       * With the standard exception filter:
+ 
+       This is on Windows pointed to by an EXCEPTION_POINTERS. We know that the
+       signal handle will call an UnhandledExceptionFilter with this
+       parameter. The spec for this routine is:
+ 
+          LONG WINAPI UnhandledExceptionFilter(struct _EXCEPTION_POINTERS*);
+ 
+       So the pointer to struct _EXCEPTION_POINTERS must be somewhere on the
+       stack.
+ 
+       This was found experimentally to always be at offset 0 of the context
+       frame in all cases handled by this implementation.
+ 
+       * With the SEH exception handler:
+ 
+       In this case the signal context is directly on the stack as the SEH
+       exception handler has the following prototype:
+ 
+          DWORD
+          SEH_error_handler (PEXCEPTION_RECORD ExceptionRecord,
+                             PVOID EstablisherFrame,
+                             PCONTEXT ContextRecord,
+                             PVOID DispatcherContext)
+ 
+       This was found experimentally to always be at offset 56 of the context
+       frame in all cases handled by this implementation.
+ 
+    3) When we have the signal context we just have to save some registers and
+       set the return address based on the program counter (Eip).
+ 
+    Note that this implementation follows closely the same principles as the
+    GNU/Linux and OSF ones.  */
+ 
+ #define WIN32_MEAN_AND_LEAN
+ #include <windows.h>
+ /* Patterns found experimentally to be on a Windows signal handler  */
+ 
+ /* In a standard exception filter  */
+ 
+ #define SIG_PAT1 \
+       (pc_[-2] == 0xff && pc_[-1] == 0xd0     /* call %eax */ \
+       && pc_[0] == 0x83 && pc_[1] == 0xf8)    /* cmp 0xdepl,%eax */
+ 
+ #define SIG_PAT2 \
+         (pc_[-5] == 0xe8 && pc_[-4] == 0x68   /* call (depl16) */ \
+          && pc_[0] == 0xc3)                   /* ret */
+ 
+ /* In a Win32 SEH handler  */
+ 
+ #define SIG_SEH1 \
+         (pc_[-5] == 0xe8                      /* call addr */ \
+          && pc_[0] == 0x83 && pc_[1] == 0xc4  /* add 0xval,%esp */ \
+          && pc_[3] == 0xb8)                   /* mov 0xval,%eax */
+ 
+ #define SIG_SEH2 \
+         (pc_[-5] == 0x8b && pc_[-4] == 0x4d   /* mov depl(%ebp),%ecx */ \
+          && pc_[0] == 0x64 && pc_[1] == 0x8b) /* mov %fs:(0),<reg> */ \
+ 
+ /* In the GCC alloca (stack probing)  */
+ 
+ #define SIG_ALLOCA \
+           (pc_[-1] == 0x83                    /* orl $0x0,(%ecx) */ \
+ 	   && pc_[0] == 0x9 && pc_[1] == 0 \
+ 	   && pc_[2] == 0x2d && pc_[3] == 0   /* subl $0x1000,%eax   */ \
+ 	   && pc_[4] == 0x10 && pc_[5] == 0)
+ 
+ 
+ #define MD_FALLBACK_FRAME_STATE_FOR i386_w32_fallback_frame_state
+ 
+ static _Unwind_Reason_Code
+ i386_w32_fallback_frame_state (struct _Unwind_Context *context, 
+ 			       _Unwind_FrameState *fs)
+ 
+ {
+   void * ctx_ra_  = (void *)(context->ra);  /* return address */
+   void * ctx_cfa_ = (void *)(context->cfa); /* context frame address */
+   unsigned char * pc_ = (unsigned char *) ctx_ra_;
+ 
+   /* In the test below we look for two specific patterns found
+      experimentally to be in the Windows signal handler.  */
+ 
+   if (SIG_PAT1 || SIG_PAT2 || SIG_SEH1 || SIG_SEH2)
+     {
+       PEXCEPTION_POINTERS weinfo_;
+       PCONTEXT proc_ctx_;
+       long new_cfa_;
+ 
+       if (SIG_SEH1) 
+ 	proc_ctx_ = (PCONTEXT) (*(int*)(ctx_cfa_ + 56));
+       else if (SIG_SEH2)
+ 	proc_ctx_ = (PCONTEXT) (*(int*)(ctx_cfa_ + 8));
+       else
+ 	{
+ 	  weinfo_ = (PEXCEPTION_POINTERS) (*(int*)ctx_cfa_);
+ 	  proc_ctx_ = weinfo_->ContextRecord;
+ 	}
+ 
+       /* The new context frame address is the stack pointer.  */
+ 
+       new_cfa_ = proc_ctx_->Esp;
+       fs->regs.cfa_how = CFA_REG_OFFSET;
+       fs->regs.cfa_reg = __builtin_dwarf_sp_column();
+       fs->regs.cfa_offset = new_cfa_ - (long) ctx_cfa_;
+ 
+       /* Save some registers.  */
+ 
+       fs->regs.reg[0].how = REG_SAVED_OFFSET;
+       fs->regs.reg[0].loc.offset = (long)&proc_ctx_->Eax - new_cfa_;
+       fs->regs.reg[3].how = REG_SAVED_OFFSET;
+       fs->regs.reg[3].loc.offset = (long)&proc_ctx_->Ebx - new_cfa_;
+       fs->regs.reg[1].how = REG_SAVED_OFFSET;
+       fs->regs.reg[1].loc.offset = (long)&proc_ctx_->Ecx - new_cfa_;
+       fs->regs.reg[2].how = REG_SAVED_OFFSET;
+       fs->regs.reg[2].loc.offset = (long)&proc_ctx_->Edx - new_cfa_;
+       fs->regs.reg[6].how = REG_SAVED_OFFSET;
+       fs->regs.reg[6].loc.offset = (long)&proc_ctx_->Esi - new_cfa_;
+       fs->regs.reg[7].how = REG_SAVED_OFFSET;
+       fs->regs.reg[7].loc.offset = (long)&proc_ctx_->Edi - new_cfa_;
+       fs->regs.reg[9].how = REG_SAVED_OFFSET;
+       fs->regs.reg[9].loc.offset = (long)&proc_ctx_->Eip - new_cfa_;
+       fs->regs.reg[4].how = REG_SAVED_OFFSET;
+       fs->regs.reg[4].loc.offset = (long)&proc_ctx_->Ebp - new_cfa_;
+ 
+       /* Set the return address to Eip + 1. As we can be called multiple
+ 	 times we use another register for this.  */
+       
+       proc_ctx_->Dr0 = proc_ctx_->Eip + 1;
+       fs->regs.reg[8].how = REG_SAVED_OFFSET;
+       fs->regs.reg[8].loc.offset = (long)&proc_ctx_->Dr0 - new_cfa_;
+       fs->retaddr_column = 8;
+       return _URC_NO_REASON;
+     }
+ 
+   /* Unwinding through _alloca, propagating from a trap triggered by
+      one of it's probes prior to the real SP adjustment. The only
+      operations of interest performed is "pushl %ecx", followed by
+      ecx clobbering.  */
+ 
+   else if (SIG_ALLOCA) 
+     {
+       /* Only one push between entry in _alloca and the probe trap. */ 
+       long new_cfa_ = (long) ctx_cfa_ + 4;
+ 
+       fs->regs.cfa_how = CFA_REG_OFFSET;
+       fs->regs.cfa_reg = __builtin_dwarf_sp_column();
+       fs->regs.cfa_offset = new_cfa_ - (long) ctx_cfa_;
+ 
+       /* The saved value of %ecx is at CFA - 4 */
+       fs->regs.reg[1].how = REG_SAVED_OFFSET;
+       fs->regs.reg[1].loc.offset = -4;
+ 
+       /* and what is stored at the CFA is the return address.  */
+       fs->retaddr_column = 8;
+       fs->regs.reg[8].how = REG_SAVED_OFFSET;
+       fs->regs.reg[8].loc.offset = 0;
+  
+       return _URC_NO_REASON;
+     }
+   else
+     return _URC_END_OF_STACK;
+ }


--------------000804000006070800080709
Content-Type: text/plain;
 name="5-gcc-dwarf2-danny-smith-20070530-EXTRA.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="5-gcc-dwarf2-danny-smith-20070530-EXTRA.patch"

Index: cygwin.h
===================================================================
--- cygwin.h	(revision 125636)
+++ cygwin.h	(working copy)
@@ -38,11 +38,12 @@
   %{shared|mdll: %{mno-cygwin:dllcrt2%O%s}}\
   %{!shared: %{!mdll: %{!mno-cygwin:crt0%O%s} %{mno-cygwin:crt2%O%s}\
   %{pg:gcrt0%O%s}}}\
-"
+  crtbegin.o%s"
 
 #undef ENDFILE_SPEC
 #define ENDFILE_SPEC \
-  "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
+  "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
+  crtend.o%s"
 
 /* Normally, -lgcc is not needed since everything in it is in the DLL, but we
    want to allow things to be added to it when installing new versions of
@@ -242,3 +243,9 @@
    and the -pthread flag is not recognized.  */
 #undef GOMP_SELF_SPECS
 #define GOMP_SELF_SPECS ""
+
+
+/* This works on cygwin. */
+#undef TARGET_USE_JCR_SECTION
+#define TARGET_USE_JCR_SECTION 1
+

--------------000804000006070800080709
Content-Type: text/plain;
 name="6-boehm-gc-win32thr.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="6-boehm-gc-win32thr.patch"

Index: boehm-gc/win32_threads.c
===================================================================
--- boehm-gc/win32_threads.c	(revision 125636)
+++ boehm-gc/win32_threads.c	(working copy)
@@ -337,6 +337,11 @@
     }
 # endif
 
+GC_PTR GC_get_thread_stack_base()
+{
+  return 0;
+}
+
 void GC_push_all_stacks()
 {
   DWORD thread_id = GetCurrentThreadId();


--------------000804000006070800080709
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
--------------000804000006070800080709--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019