View Issue Details

IDProjectCategoryView StatusLast Update
0000467GCC - GNU C CompilerBugpublic2011-04-22 23:19
Reporterdmik Assigned Topsmedley  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Summary0000467: GCC 4.5.2 (20101231) - CC1.EXE crash
DescriptionI experience stable crashes in CC1.EXE on a particular file when building the current OpenJDK.
Additional InformationHere is the output:

../../../src/windows/native/java/lang/java_props_md.c:398:27: warning: "/*" within comment
../../../src/windows/native/java/lang/java_props_md.c: In function 'getHomeFromRegistry':
../../../src/windows/native/java/lang/java_props_md.c:542:5: warning: pointer targets in passing argument 5 of 'RegQueryValueExA' differ in signedness
D:/Coding/odin32/include/Win/winreg.h:215:20: note: expected 'LPBYTE' but argument is of type 'char *'
../../../src/windows/native/java/lang/java_props_md.c:542:5: warning: passing argument 6 of 'RegQueryValueExA' from incompatible pointer type
D:/Coding/odin32/include/Win/winreg.h:215:20: note: expected 'LPDWORD' but argument is of type 'int *'

Killed by SIGSEGV
pid=0x1e1e ppid=0x1e1d tid=0x0001 slot=0x00b9 pri=0x0200 mc=0x0001
D:\DEV\GCC452\USR\LOCAL452\LIBEXEC\GCC\I386-PC-OS2-EMX\4.5.2\CC1.EXE
CC1 0:001f9915
cs:eip=005b:00209915 ss:esp=0053:009beeb8 ebp=009beeb8
 ds=0053 es=0053 fs=150b gs=0000 efl=00010202
eax=05cef680 ebx=009bef84 ecx=00000007 edx=00000000 edi=009bf04f esi=00859fc0
Process dumping was disabled, use DUMPPROC / PROCDUMP to enable it.
gcc: Internal error: Segmentation fault (program cc1)
Please submit a full bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[3]: *** [D:/Coding/javaos2/openjdk/build-product-release/tmp/java/java.lang/java/obj/java_props_md.obj] Error 1
make[3]: Leaving directory `D:/Coding/javaos2/openjdk/jdk/make/java/java'
make[2]: *** [all] Error 1
make[2]: Leaving directory `D:/Coding/javaos2/openjdk/jdk/make/java'
make[1]: *** [all] Error 1
make[1]: Leaving directory `D:/Coding/javaos2/openjdk/jdk/make'
make: *** [jdk-build] Error 2
TagsNo tags attached.
Attached Files
java_props_md.pp.c.zip (120,503 bytes)
gcc-4.4.5.diff (72,213 bytes)   
Only in gcc-4.4.5: build.log
Only in gcc-4.4.5: conf.cmd
Only in gcc-4.4.5/config: mh-emx
Only in gcc-4.4.5: config.log
Only in gcc-4.4.5: config.status
diff -ur gcc-4.4.5-o/configure gcc-4.4.5/configure
--- gcc-4.4.5-o/configure	2010-06-08 05:40:40.000000000 +0930
+++ gcc-4.4.5/configure	2010-10-03 18:54:50.000000000 +1030
@@ -2196,7 +2196,7 @@
 	;;
     *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11*)
 	;;
-    *-*-darwin* | *-*-aix*)
+    *-*-darwin* | *-*-aix* | i*86-pc-*emx)
 	;;
     *)
 	noconfigdirs="$noconfigdirs target-libgomp"
diff -ur gcc-4.4.5-o/configure.ac gcc-4.4.5/configure.ac
--- gcc-4.4.5-o/configure.ac	2010-06-08 05:40:40.000000000 +0930
+++ gcc-4.4.5/configure.ac	2010-10-03 18:54:50.000000000 +1030
@@ -431,7 +431,7 @@
 	;;
     *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11*)
 	;;
-    *-*-darwin* | *-*-aix*)
+    *-*-darwin* | *-*-aix*  | i*86-pc-*emx)
 	;;
     *)
 	noconfigdirs="$noconfigdirs target-libgomp"
@@ -1050,6 +1050,9 @@
   i[[3456789]]86-*-msdosdjgpp*)
     host_makefile_frag="config/mh-djgpp"
     ;;
+  i[3456]86-*-os2*)
+    host_makefile_frag="config/mh-emx"
+    ;;
   *-cygwin*)
     ACX_CHECK_CYGWIN_CAT_WORKS
     host_makefile_frag="config/mh-cygwin"
Only in gcc-4.4.5: configure.lineno
diff -ur gcc-4.4.5-o/fixincludes/fixincl.c gcc-4.4.5/fixincludes/fixincl.c
--- gcc-4.4.5-o/fixincludes/fixincl.c	2009-04-10 08:53:06.000000000 +0930
+++ gcc-4.4.5/fixincludes/fixincl.c	2010-10-03 18:54:50.000000000 +1030
@@ -29,7 +29,7 @@
 #include <sys/wait.h>
 #endif
 
-#if defined( HAVE_MMAP_FILE )
+#if defined( HAVE_MMAP_FILE ) && !defined(__OS2__)
 #include <sys/mman.h>
 #define  BAD_ADDR ((void*)-1)
 #endif
@@ -336,7 +336,7 @@
       return (char*)NULL;
     }
 
-#ifdef HAVE_MMAP_FILE
+#if defined( HAVE_MMAP_FILE ) && !defined(__OS2__)
   curr_data_mapped = BOOL_TRUE;
 
   /*  IF the file size is a multiple of the page size,
diff -ur gcc-4.4.5-o/fixincludes/fixlib.h gcc-4.4.5/fixincludes/fixlib.h
--- gcc-4.4.5-o/fixincludes/fixlib.h	2009-04-10 08:53:06.000000000 +0930
+++ gcc-4.4.5/fixincludes/fixlib.h	2010-10-03 18:54:50.000000000 +1030
@@ -211,7 +211,7 @@
 
 extern int gnu_type_map_ct;
 
-#ifdef HAVE_MMAP_FILE
+#if defined( HAVE_MMAP_FILE ) && !defined(__OS2__)
 #define UNLOAD_DATA() do { if (curr_data_mapped) { \
   munmap ((void*)pz_curr_data, data_map_size); close (data_map_fd); } \
   else free ((void*)pz_curr_data); } while(0)
Only in gcc-4.4.5/fixincludes/tests/base: arpa
Only in gcc-4.4.5/fixincludes/tests/base: fs
Only in gcc-4.4.5/fixincludes/tests/base: machine
Only in gcc-4.4.5/gcc: ada
Only in gcc-4.4.5/gcc/config/i386: emx-ctordtor.c
Only in gcc-4.4.5/gcc/config/i386: emx-cxx.c
Only in gcc-4.4.5/gcc/config/i386: emx-dllinit.c
Only in gcc-4.4.5/gcc/config/i386: emx-eh.c
Only in gcc-4.4.5/gcc/config/i386: emx-libgcc_so_d.def
Only in gcc-4.4.5/gcc/config/i386: emx-libgcc1.asm
Only in gcc-4.4.5/gcc/config/i386: emx-stubs.c
Only in gcc-4.4.5/gcc/config/i386: emx.c
Only in gcc-4.4.5/gcc/config/i386: emx.c.orig
Only in gcc-4.4.5/gcc/config/i386: emx.c.rej
Only in gcc-4.4.5/gcc/config/i386: emx.h
Only in gcc-4.4.5/gcc/config/i386: host-emx.c
diff -ur gcc-4.4.5-o/gcc/config/i386/i386-protos.h gcc-4.4.5/gcc/config/i386/i386-protos.h
--- gcc-4.4.5-o/gcc/config/i386/i386-protos.h	2010-07-22 16:16:28.000000000 +0930
+++ gcc-4.4.5/gcc/config/i386/i386-protos.h	2010-10-03 18:54:50.000000000 +1030
@@ -279,3 +279,16 @@
 #ifdef HAVE_ATTR_cpu
 extern enum attr_cpu ix86_schedule;
 #endif
+
+/* In emx.c  */
+extern bool i386_emx_binds_local_p (const_tree);
+extern void i386_emx_init_sections (void);
+extern void i386_emx_asm_out_destructor (rtx, int);
+extern tree i386_emx_mangle_decl_assembler_name (tree, tree);
+extern void i386_emx_maybe_record_exported_symbol (tree, const char *, int);
+extern bool i386_emx_valid_dllimport_attribute_p (const_tree);
+
+/* In emx-cxx.c  */
+extern void i386_emx_adjust_class_at_definition (tree);
+extern bool i386_emx_type_dllimport_p (tree);
+extern bool i386_emx_type_dllexport_p (tree);
diff -ur gcc-4.4.5-o/gcc/config/i386/i386.c gcc-4.4.5/gcc/config/i386/i386.c
--- gcc-4.4.5-o/gcc/config/i386/i386.c	2010-08-06 17:22:04.000000000 +0930
+++ gcc-4.4.5/gcc/config/i386/i386.c	2010-10-03 18:54:52.000000000 +1030
@@ -62,6 +62,10 @@
 #define CHECK_STACK_LIMIT (-1)
 #endif
 
+#ifdef EMX
+extern bool i386_emx_binds_local_p (const_tree);
+#endif
+
 /* Return index of given mode in mult and division cost tables.  */
 #define MODE_INDEX(mode)					\
   ((mode) == QImode ? 0						\
@@ -4529,7 +4533,11 @@
   rtd = TARGET_RTD && (!fundecl || TREE_CODE (fundecl) != IDENTIFIER_NODE);
 
   /* Cdecl functions override -mrtd, and never pop the stack.  */
-  if (! lookup_attribute ("cdecl", TYPE_ATTRIBUTES (funtype)))
+  if (! lookup_attribute ("cdecl", TYPE_ATTRIBUTES (funtype))
+#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
+   && ! lookup_attribute ("system", TYPE_ATTRIBUTES (funtype))
+#endif
+     ) 
     {
       /* Stdcall and fastcall functions will pop the stack if not
          variable args.  */
@@ -4756,6 +4764,11 @@
 		      ? (!prototype_p (fntype) || stdarg_p (fntype))
 		      : !libname);
 
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
+  /* _Optlink calling convention says all args until the ellipsis
+             are passed in registers, and all varargs on the stack. */
+  if (!cum->optlink)
+#endif
   if (!TARGET_64BIT)
     {
       /* If there are variable arguments, then we won't pass anything
@@ -4781,8 +4794,26 @@
 	      cum->fastcall = 1;
 	    }
 	  else
-	    cum->nregs = ix86_function_regparm (fntype, fndecl);
+            {
+		cum->nregs = ix86_function_regparm (fntype, fndecl);
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES /* reasonable confidence */
+		if (lookup_attribute ("optlink", TYPE_ATTRIBUTES (fntype)))
+	          {
+			cum->nregs = 3; cum->optlink = 1;
+		  }
+#endif
+	    }
 	}
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
+      /* Limit number of registers to pass arguments as in _Optlink specification */
+      if (cum->optlink)
+        {
+          if (cum->nregs > 3)
+            cum->nregs = 3;
+          if (cum->fpu_nregs > 4)
+            cum->fpu_nregs = 4;
+        }
+#endif
 
       /* Set up the number of SSE registers used for passing SFmode
 	 and DFmode arguments.  Warn for mismatching ABI.  */
@@ -5579,6 +5610,61 @@
     case HImode:
     case QImode:
       cum->words += words;
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES /* looks ok */
+          /* Optlink functions never pass aggregates in registers
+             (they are pushed on the stack, and the registers are
+             preserved for following parameters). */
+          if (cum->optlink)
+            {
+              /* If out of eyecatcher slots, do nothing */
+              if (!cum->ec_slots)
+                return;
+
+              if (INTEGRAL_TYPE_P (type)
+               || POINTER_TYPE_P (type))
+                {
+                  /* Integer types takes one slot in eyecatcher */
+                  cum->ec_slots--;
+                }
+              else if (FLOAT_MODE_P (mode))
+                {
+                  /* Fixed-point parameters are passed in FPU registers */
+                  if (cum->fpu_nregs)
+                    {
+                      cum->fpu_nregs--;
+                      cum->fpu_regno++;
+                      /* Args passed in FPU stack takes one eyecatcher slot */
+                      cum->ec_slots--;
+                    }
+                  else
+                    {
+                      /* FPU args passed on RT stack takes 1/2/4 slots */
+                      cum->ec_slots -= words;
+                    }
+
+                  /* The case with ec_slots <= 0 will be catched a little lates */
+                  if (cum->ec_slots > 0)
+                    return;
+                }
+              else
+                {
+                  /* This is nor a integer, address or float parameter.
+                     Pass it on the stack but count its size in eyecatcher. */
+                  cum->ec_slots -= words;
+                  if (cum->ec_slots > 0)
+                    return;
+                }
+
+              /* If we're out of eyecatcher slots, pass the arg on the stack */
+              if (cum->ec_slots <= 0)
+                {
+                  cum->ec_slots = 0;
+                  cum->nregs = 0;
+                  cum->fpu_nregs = 0;
+                  return;
+                }
+            }
+#endif
       cum->nregs -= words;
       cum->regno += words;
 
@@ -5614,7 +5700,11 @@
     case V2DImode:
     case V4SFmode:
     case V2DFmode:
-      if (!type || !AGGREGATE_TYPE_P (type))
+      if (!type || !AGGREGATE_TYPE_P (type)
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES /* looks ok */
+          && !cum->optlink
+#endif
+        )
 	{
 	  cum->sse_words += words;
 	  cum->sse_nregs -= 1;
@@ -5735,11 +5825,36 @@
   if (mode == VOIDmode)
     return constm1_rtx;
 
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES /* looks ok */
+  rtx ret = NULL_RTX;
+      /* For optlink calling convention, don't pass anything other than
+         integral types and floats through registers. */
+      if (!cum->optlink
+          || INTEGRAL_TYPE_P (type)
+          || POINTER_TYPE_P (type)
+          || (TREE_CODE (type) == REAL_TYPE))
+#endif
+
   switch (mode)
     {
     default:
       break;
 
+#if defined TARGET_OPTLINK_DECL_ATTRIBUTES /* looks ok  */
+        case XFmode:
+        case TFmode:
+        if (cum->fpu_nregs && cum->optlink && cum->ec_slots)
+          {
+            /* Pass first four floating-point args in FPU registers */
+            ret = gen_rtx_PARALLEL (mode, rtvec_alloc (2));
+            XVECEXP (ret, 0, 0) = gen_rtx_EXPR_LIST ( VOIDmode,
+                                           NULL_RTX, const0_rtx);
+            XVECEXP (ret, 0, 1) = gen_rtx_EXPR_LIST (VOIDmode,
+                                           gen_rtx_REG ( mode, FIRST_FLOAT_REG + cum->fpu_regno),
+                                           const0_rtx);
+          }
+        break;
+#endif
     case BLKmode:
       if (bytes < 0)
 	break;
@@ -5749,6 +5864,28 @@
     case HImode:
     case QImode:
       if (words <= cum->nregs)
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES /* looks ok */
+          {
+            if (cum->optlink)
+              {
+                if (cum->ec_slots)
+                  {
+                    /* Optlink specs says that the parameter is passed in a register
+                       and space on the stack is reserved for it as well (which is not
+                       filled). Currently GCC will pass the parameter *both* in register
+                       and stack; this is suboptimal but is compatible. */
+                    ret = gen_rtx_PARALLEL ( mode, rtvec_alloc (2));
+                    XVECEXP (ret, 0, 0) = gen_rtx_EXPR_LIST ( VOIDmode,
+                                                   NULL_RTX, const0_rtx);
+                    XVECEXP (ret, 0, 1) = gen_rtx_EXPR_LIST ( VOIDmode,
+                                                   gen_rtx_REG ( mode, cum->regno),
+                                                   const0_rtx);
+                  }
+              }
+            else
+              ret = gen_rtx_REG (mode, cum->regno);
+          }
+#else
 	{
 	  int regno = cum->regno;
 
@@ -5768,12 +5905,39 @@
 	    }
 	  return gen_rtx_REG (mode, regno);
 	}
+#endif
       break;
 
     case DFmode:
+#if defined TARGET_OPTLINK_DECL_ATTRIBUTES /* looks ok  */
+        if (cum->fpu_nregs && cum->optlink && cum->ec_slots)
+          {
+            /* Pass first four floating-point args in FPU registers */
+            ret = gen_rtx_PARALLEL (mode, rtvec_alloc (2));
+            XVECEXP (ret, 0, 0) = gen_rtx_EXPR_LIST ( VOIDmode,
+                                           NULL_RTX, const0_rtx);
+            XVECEXP (ret, 0, 1) = gen_rtx_EXPR_LIST (VOIDmode,
+                                           gen_rtx_REG ( mode, FIRST_FLOAT_REG + cum->fpu_regno),
+                                           const0_rtx);
+          }
+        break;
+#endif
       if (cum->float_in_sse < 2)
 	break;
     case SFmode:
+#if defined TARGET_OPTLINK_DECL_ATTRIBUTES /* looks ok */
+        if (cum->fpu_nregs && cum->optlink && cum->ec_slots)
+          {
+            /* Pass first four floating-point args in FPU registers */
+            ret = gen_rtx_PARALLEL (mode, rtvec_alloc (2));
+            XVECEXP (ret, 0, 0) = gen_rtx_EXPR_LIST ( VOIDmode,
+                                           NULL_RTX, const0_rtx);
+            XVECEXP (ret, 0, 1) = gen_rtx_EXPR_LIST (VOIDmode,
+                                           gen_rtx_REG ( mode, FIRST_FLOAT_REG + cum->fpu_regno),
+                                           const0_rtx);
+          }
+        break;
+#endif
       if (cum->float_in_sse < 1)
 	break;
       /* FALLTHRU */
@@ -6007,6 +6171,9 @@
        || mode == TFmode
        || mode == TCmode)
       && (!TYPE_USER_ALIGN (type) || TYPE_ALIGN (type) > 128))
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTESz
+          && !cum->optlink
+#endif
     return true;
   if (TYPE_ALIGN (type) < 128)
     return false;
@@ -9027,12 +9194,13 @@
       if (SYMBOL_REF_TLS_MODEL (x))
 	return false;
 
+#ifndef __EMX__ /* 2009-01-15 */
       /* DLLIMPORT symbols are never valid.  */
       if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
-	  && SYMBOL_REF_DLLIMPORT_P (x))
+	  && SYMBOL_REF_DLLIMPORT_P (x)) 
 	return false;
+#endif
       break;
-
     case CONST_DOUBLE:
       if (GET_MODE (x) == TImode
 	  && x != CONST0_RTX (TImode)
@@ -9948,7 +10116,11 @@
   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
   name = targetm.strip_name_encoding (name);
   prefix = name[0] == FASTCALL_PREFIX || user_label_prefix[0] == 0
+#ifndef __OS2__
     ? "*__imp_" : "*__imp__";
+#else
+    ? "" : "";
+#endif
   namelen = strlen (name);
   prefixlen = strlen (prefix);
   imp_name = (char *) alloca (namelen + prefixlen + 1);
@@ -10027,7 +10199,8 @@
       return gen_rtx_PLUS (Pmode, t, XEXP (XEXP (x, 0), 1));
     }
 
-  if (TARGET_DLLIMPORT_DECL_ATTRIBUTES)
+#ifndef __EMX__ /* 2009-01-15 */
+  if (TARGET_DLLIMPORT_DECL_ATTRIBUTES) 
     {
       if (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_DLLIMPORT_P (x))
 	return legitimize_dllimport_symbol (x, true);
@@ -10040,7 +10213,7 @@
 	  return gen_rtx_PLUS (Pmode, t, XEXP (XEXP (x, 0), 1));
 	}
     }
-
+#endif
   if (flag_pic && SYMBOLIC_CONST (x))
     return legitimize_pic_address (x, 0);
 
@@ -12338,9 +12511,11 @@
 	  if (op1 == op0)
 	    return;
 	}
+#ifndef __EMX__ /* 2009-01-16 */
       else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
-	       && SYMBOL_REF_DLLIMPORT_P (op1))
+	       && SYMBOL_REF_DLLIMPORT_P (op1)) 
 	op1 = legitimize_dllimport_symbol (op1, false);
+#endif
     }
   else if (GET_CODE (op1) == CONST
 	   && GET_CODE (XEXP (op1, 0)) == PLUS
@@ -12353,10 +12528,11 @@
       model = SYMBOL_REF_TLS_MODEL (symbol);
       if (model)
 	tmp = legitimize_tls_address (symbol, model, true);
+#ifndef __EMX__ /* 2009-01-16 */
       else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
-	       && SYMBOL_REF_DLLIMPORT_P (symbol))
+	       && SYMBOL_REF_DLLIMPORT_P (symbol)) 
 	tmp = legitimize_dllimport_symbol (symbol, true);
-
+#endif
       if (tmp)
 	{
 	  tmp = force_operand (tmp, NULL);
@@ -29568,9 +29744,18 @@
   { "ms_abi", 0, 0, false, true, true, ix86_handle_abi_attribute },
   { "sysv_abi", 0, 0, false, true, true, ix86_handle_abi_attribute },
   /* End element.  */
+#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
+  /* System says the function is extern "C" and is not underscored. */
+  { "system",    0, 0, false, true,  true,  ix86_handle_cconv_attribute },
+#endif
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
+  /* Optlink is like regparm with a few differences */
+  { "optlink",   0, 0, false, true,  true,  ix86_handle_cconv_attribute },
+#endif
   { NULL,        0, 0, false, false, false, NULL }
 };
 
+
 /* Implement targetm.vectorize.builtin_vectorization_cost.  */
 static int
 x86_builtin_vectorization_cost (bool runtime_test)
@@ -29808,8 +29993,13 @@
 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
 #endif
 #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
+#ifndef __EMX__
 #undef TARGET_BINDS_LOCAL_P
 #define TARGET_BINDS_LOCAL_P i386_pe_binds_local_p
+#else
+#undef TARGET_BINDS_LOCAL_P
+#define TARGET_BINDS_LOCAL_P i386_emx_binds_local_p
+#endif /* __EMX__ */
 #endif
 
 #undef TARGET_ASM_OUTPUT_MI_THUNK
Only in gcc-4.4.5/gcc/config/i386: i386.c.orig
diff -ur gcc-4.4.5-o/gcc/config/i386/i386.h gcc-4.4.5/gcc/config/i386/i386.h
--- gcc-4.4.5-o/gcc/config/i386/i386.h	2009-11-14 05:43:16.000000000 +1030
+++ gcc-4.4.5/gcc/config/i386/i386.h	2010-10-03 18:54:52.000000000 +1030
@@ -1586,6 +1586,12 @@
 				   be passed in SSE registers.  Otherwise 0.  */
   int call_abi;			/* Set to SYSV_ABI for sysv abi. Otherwise
  				   MS_ABI for ms abi.  */
+#ifdef __OS2__
+  int fpu_regno;		/* next available FPU register number */
+  int fpu_nregs;		/* # registers available for passing */
+  int ec_slots;			/* # eyecatcher slots left (see optlink specs) */
+  int optlink;			/* nonzero if optlink (vs. regparm) */
+#endif /* EMX */
 } CUMULATIVE_ARGS;
 
 /* Initialize a variable CUM of type CUMULATIVE_ARGS
diff -ur gcc-4.4.5-o/gcc/config/i386/i386.md gcc-4.4.5/gcc/config/i386/i386.md
--- gcc-4.4.5-o/gcc/config/i386/i386.md	2010-06-12 17:13:40.000000000 +0930
+++ gcc-4.4.5/gcc/config/i386/i386.md	2010-10-03 18:54:52.000000000 +1030
@@ -20295,7 +20295,7 @@
    (set (reg:SI SP_REG) (minus:SI (reg:SI SP_REG) (match_dup 1)))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_64BIT && TARGET_STACK_PROBE"
-  "call\t___chkstk"
+  "call\t__alloca"
   [(set_attr "type" "multi")
    (set_attr "length" "5")])
 
@@ -20308,7 +20308,7 @@
    (clobber (reg:DI R11_REG))
    (clobber (reg:CC FLAGS_REG))]
   "TARGET_64BIT && TARGET_STACK_PROBE"
-  "call\t___chkstk"
+  "call\t__alloca"
   [(set_attr "type" "multi")
    (set_attr "length" "5")])
 
Only in gcc-4.4.5/gcc/config/i386: i386.md.orig
diff -ur gcc-4.4.5-o/gcc/config/i386/predicates.md gcc-4.4.5/gcc/config/i386/predicates.md
--- gcc-4.4.5-o/gcc/config/i386/predicates.md	2009-11-15 05:23:08.000000000 +1030
+++ gcc-4.4.5/gcc/config/i386/predicates.md	2010-10-03 18:54:52.000000000 +1030
@@ -501,8 +501,10 @@
 {
   if (ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
     return false;
+#ifndef __EMX__ /* mangles dllimport symbols in a bad way on OS/2 */
   if (TARGET_DLLIMPORT_DECL_ATTRIBUTES && SYMBOL_REF_DLLIMPORT_P (op))
     return false;
+#endif
   return true;
 })
 
Only in gcc-4.4.5/gcc/config/i386: t
Only in gcc-4.4.5/gcc/config/i386: t-emx
Only in gcc-4.4.5/gcc/config/i386: x-emx
Only in gcc-4.4.5/gcc/config/i386: xm-emx.h
Only in gcc-4.4.5/gcc/config: mt
diff -ur gcc-4.4.5-o/gcc/config.build gcc-4.4.5/gcc/config.build
--- gcc-4.4.5-o/gcc/config.build	2008-02-22 06:25:38.000000000 +1030
+++ gcc-4.4.5/gcc/config.build	2010-10-03 18:54:52.000000000 +1030
@@ -119,5 +119,9 @@
     # All other System V variants.
     build_install_headers_dir=install-headers-cpio
     ;;
+i*86-pc-*emx)		# i?86 running OS/2
+    build_xm_file=i386/xm-emx.h
+    exeext=.exe
+    build_exeext=.exe
 esac
 
diff -ur gcc-4.4.5-o/gcc/config.gcc gcc-4.4.5/gcc/config.gcc
--- gcc-4.4.5-o/gcc/config.gcc	2010-06-14 07:46:50.000000000 +0930
+++ gcc-4.4.5/gcc/config.gcc	2010-10-03 18:54:54.000000000 +1030
@@ -1315,6 +1315,25 @@
 			;;
 	esac
 	;;
+i*86-pc-*emx)		# i?86 running OS/2
+	xm_file=i386/xm-emx.h
+	tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h i386/emx.h"
+	extra_objs="emx.o emx-stubs.o"
+	cxx_target_objs="${cxx_target_objs} emx-cxx.o"
+	xm_defines="USG BSTRING NO_SYS_SIGLIST"
+	exeext=.exe
+	tmake_file=i386/t-emx
+    # r=bird: why do we do this??
+	target_alias=${host}
+    # r=bird: and this??
+	CFLAGS="-Zstack 1024 -Zcrtdll"
+	if test x$enable_threads = xyes; then
+		thread_file=os2
+	fi
+	gas=yes
+	gnu_ld=yes
+	float_format=none
+	;;
 i[34567]86-*-interix3*)
 	tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/i386-interix.h i386/i386-interix3.h interix.h interix3.h"
 	tmake_file="${tmake_file} i386/t-interix"
Only in gcc-4.4.5/gcc: config.gcc.orig
diff -ur gcc-4.4.5-o/gcc/config.host gcc-4.4.5/gcc/config.host
--- gcc-4.4.5-o/gcc/config.host	2009-09-14 02:32:50.000000000 +0930
+++ gcc-4.4.5/gcc/config.host	2011-01-22 12:56:02.000000000 +1030
@@ -197,6 +197,11 @@
         ;;
     esac
     ;;
+  i*86-pc-*emx)		# i?86 running OS/2
+    host_exeext=.exe
+#    out_host_hook_obj=host-emx.o
+#    host_xmake_file="${host_xmake_file} i386/x-emx"
+    ;;
   i[34567]86-*-pe | i[34567]86-*-cygwin*)
     host_xm_file=i386/xm-cygwin.h
     out_host_hook_obj=host-cygwin.o
diff -ur gcc-4.4.5-o/gcc/cp/class.c gcc-4.4.5/gcc/cp/class.c
--- gcc-4.4.5-o/gcc/cp/class.c	2010-07-10 05:17:34.000000000 +0930
+++ gcc-4.4.5/gcc/cp/class.c	2010-10-03 18:54:54.000000000 +1030
@@ -2384,6 +2384,18 @@
       if (!DECL_VINDEX (decl))
 	DECL_VINDEX (decl) = error_mark_node;
       IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)) = 1;
+/* Added 2009-01-11 */
+      if (DECL_DLLIMPORT_P (decl))
+	{
+	  /* When we handled the dllimport attribute we may not have known
+	     that this function is virtual   We can't use dllimport 
+	     semantics for a virtual method because we need to initialize
+	     the vtable entry with a constant address.  */
+	  DECL_DLLIMPORT_P (decl) = 0;
+	  DECL_ATTRIBUTES (decl)
+	    = remove_attribute ("dllimport", DECL_ATTRIBUTES (decl));
+	}
+
     }
 }
 
diff -ur gcc-4.4.5-o/gcc/cp/cp-tree.h gcc-4.4.5/gcc/cp/cp-tree.h
--- gcc-4.4.5-o/gcc/cp/cp-tree.h	2009-12-16 01:44:58.000000000 +1030
+++ gcc-4.4.5/gcc/cp/cp-tree.h	2010-10-03 18:54:54.000000000 +1030
@@ -4461,7 +4461,11 @@
 extern void expand_end_catch_block		(void);
 extern tree build_exc_ptr			(void);
 extern tree build_throw				(tree);
+#ifndef __OS2__
 extern int nothrow_libfn_p			(const_tree);
+#else
+extern int nothrow_libfn_p			(tree);
+#endif
 extern void check_handlers			(tree);
 extern void choose_personality_routine		(enum languages);
 extern tree eh_type_info			(tree);
diff -ur gcc-4.4.5-o/gcc/cp/decl.c gcc-4.4.5/gcc/cp/decl.c
--- gcc-4.4.5-o/gcc/cp/decl.c	2010-05-28 04:30:32.000000000 +0930
+++ gcc-4.4.5/gcc/cp/decl.c	2010-10-03 18:54:54.000000000 +1030
@@ -10748,7 +10748,22 @@
 	    }
 	}
     }
-
+#if 0 /* Broken in 3.4.6 - is it still necessary??? */
+#if 1 /* bird: HACK ALERT! HACK ALERT! */
+  /* Don't replace attributes with nothing. See the nsSupportWeakReference / friend problem.
+     Limit any negative sideeffects this hack may have by only caring for a select number of attributes. */
+  if (   TYPE_ATTRIBUTES (t)
+      && (   lookup_attribute ("dllexport", TYPE_ATTRIBUTES (t))
+          || lookup_attribute ("dllimport", TYPE_ATTRIBUTES (t))
+          || lookup_attribute ("system", TYPE_ATTRIBUTES (t))
+          || lookup_attribute ("cdecl", TYPE_ATTRIBUTES (t))
+          || lookup_attribute ("optlink", TYPE_ATTRIBUTES (t))
+          || lookup_attribute ("stdcall", TYPE_ATTRIBUTES (t))))
+    TYPE_ATTRIBUTES (t) = merge_attributes(TYPE_ATTRIBUTES (t), attributes);
+  else
+    TYPE_ATTRIBUTES (t) = attributes;
+#endif
+#endif
   POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
 }
 
Only in gcc-4.4.5/gcc/cp: decl.c.orig
diff -ur gcc-4.4.5-o/gcc/cp/dump.c gcc-4.4.5/gcc/cp/dump.c
--- gcc-4.4.5-o/gcc/cp/dump.c	2008-03-22 05:26:50.000000000 +1030
+++ gcc-4.4.5/gcc/cp/dump.c	2010-10-03 18:54:54.000000000 +1030
@@ -202,6 +202,31 @@
   }
 }
 
+#if 1 /* bird hacking */
+static void cp_dump_attributes (dump_info_p di, tree t)
+{
+  tree attr = NULL;
+  if (DECL_P (t))
+    attr = DECL_ATTRIBUTES (t);
+  else if (TYPE_P (t))
+    attr = TYPE_ATTRIBUTES (t);
+  else
+    return;
+  if (lookup_attribute ("optlink", attr))
+    dump_string (di, "optlink");
+  if (lookup_attribute ("stdcall", attr))
+    dump_string (di, "stdcall");
+  if (lookup_attribute ("cdecl", attr))
+    dump_string (di, "cdecl");
+  if (lookup_attribute ("system", attr))
+    dump_string (di, "system");
+  if (lookup_attribute ("dllexport", attr))
+    dump_string (di, "dllexport");
+  if (lookup_attribute ("dllimport", attr))
+    dump_string (di, "dllimport");
+}
+#endif /* bird hacking */
+
 bool
 cp_dump_tree (void* dump_info, tree t)
 {
@@ -217,6 +242,10 @@
 	dump_string_field (di, "lang", language_to_string (DECL_LANGUAGE (t)));
     }
 
+#if 1 /* bird hacking */
+  cp_dump_attributes (di, t);
+#endif 
+
   switch (code)
     {
     case IDENTIFIER_NODE:
diff -ur gcc-4.4.5-o/gcc/cp/error.c gcc-4.4.5/gcc/cp/error.c
--- gcc-4.4.5-o/gcc/cp/error.c	2010-06-23 06:18:24.000000000 +0930
+++ gcc-4.4.5/gcc/cp/error.c	2010-10-03 18:54:54.000000000 +1030
@@ -28,6 +28,7 @@
 #include "toplev.h"
 #include "flags.h"
 #include "diagnostic.h"
+#include "tm_p.h"
 #include "langhooks-def.h"
 #include "cxx-pretty-print.h"
 
@@ -590,12 +591,18 @@
 	 templates, e.g. std::is_function.  */
     case FUNCTION_TYPE:
       dump_type_prefix (TREE_TYPE (t), flags);
+#ifdef TARGET_PRINT_TYPE_ATTRS
+      TARGET_PRINT_TYPE_ATTRS (t, scratch_buffer);
+#endif
       break;
 
     case METHOD_TYPE:
       dump_type_prefix (TREE_TYPE (t), flags);
       pp_maybe_space (cxx_pp);
       pp_cxx_left_paren (cxx_pp);
+#ifdef TARGET_PRINT_TYPE_ATTRS
+      TARGET_PRINT_TYPE_ATTRS (t, scratch_buffer);
+#endif
       dump_aggr_type (TYPE_METHOD_BASETYPE (t), flags);
       pp_cxx_colon_colon (cxx_pp);
       break;
diff -ur gcc-4.4.5-o/gcc/cp/except.c gcc-4.4.5/gcc/cp/except.c
--- gcc-4.4.5-o/gcc/cp/except.c	2008-08-18 20:47:52.000000000 +0930
+++ gcc-4.4.5/gcc/cp/except.c	2010-10-03 18:54:54.000000000 +1030
@@ -929,8 +929,13 @@
 
 #include "cfns.h"
 
+#ifndef __OS2__
 int
 nothrow_libfn_p (const_tree fn)
+#else
+int
+nothrow_libfn_p (tree fn)
+#endif
 {
   tree id;
 
@@ -947,6 +952,13 @@
      unless the system headers are playing rename tricks, and if
      they are, we don't want to be confused by them.  */
   id = DECL_NAME (fn);
+#ifdef TARGET_CXX_SET_DECL_ASSEMBLER_NAME /* GCC-OS2 */
+  /* Actually the above is a bug. We can't mangle correctly unless we
+     have a complete decl. Until then, as a partial fix, reset the
+     mangled name to NULL so that next DECL_ASSEMBLER_NAME calls
+     mangler again, now with a complete decl. */
+  SET_DECL_ASSEMBLER_NAME(fn, NULL_TREE);
+#endif
   return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
 }
 
diff -ur gcc-4.4.5-o/gcc/cp/g++spec.c gcc-4.4.5/gcc/cp/g++spec.c
--- gcc-4.4.5-o/gcc/cp/g++spec.c	2009-02-21 01:50:38.000000000 +1030
+++ gcc-4.4.5/gcc/cp/g++spec.c	2010-10-03 18:54:54.000000000 +1030
@@ -47,6 +47,12 @@
 #ifndef LIBSTDCXX_STATIC
 #define LIBSTDCXX_STATIC LIBSTDCXX
 #endif
+#ifdef LIBSTDCXX_STATIC                                                             /* bird */
+#define LIBSTDCXX_STATIC "-lstdc++"                                                 /* bird */
+#endif                                                                              /* bird */
+#ifdef LIBSTDCXX_PROFILE_STATIC                                                     /* bird */
+#define LIBSTDCXX_PROFILE_STATIC "-lstdc++"                                         /* bird */
+#endif                                                                              /* bird */
 
 void
 lang_specific_driver (int *in_argc, const char *const **in_argv,
@@ -99,6 +105,9 @@
   /* True if we should add -shared-libgcc to the command-line.  */
   int shared_libgcc = 1;
 
+  /* True if we saw the '-static' option on the commandline. */                     /* bird */
+  int saw_static = 0;                                                               /* bird */
+                                                                                    /* bird */
   /* The total number of arguments with the new stuff.  */
   int argc;
 
@@ -200,9 +209,13 @@
 		 cause a warning.  */
 	      library = -1;
 	    }
-	  else if (strcmp (argv[i], "-static-libgcc") == 0
-		   || strcmp (argv[i], "-static") == 0)
+	  else if (strcmp (argv[i], "-static-libgcc") == 0)                             /* bird */
 	    shared_libgcc = 0;
+          else if (strcmp (argv[i], "-static") == 0)                                /* bird */
+            {                                                                       /* bird */
+              saw_static = 1;                                                       /* bird */
+              shared_libgcc = 0;                                                    /* bird */
+            }                                                                       /* bird */
 	  else if (DEFAULT_WORD_SWITCH_TAKES_ARG (&argv[i][1]))
 	    i++;
 	  else
diff -ur gcc-4.4.5-o/gcc/cp/mangle.c gcc-4.4.5/gcc/cp/mangle.c
--- gcc-4.4.5-o/gcc/cp/mangle.c	2009-12-23 00:58:54.000000000 +1030
+++ gcc-4.4.5/gcc/cp/mangle.c	2010-10-03 18:54:54.000000000 +1030
@@ -78,6 +78,11 @@
 # define MANGLE_TRACE_TREE(FN, NODE)
 #endif
 
+/* Provide a dummy target-specific name mangling hook */
+#ifndef TARGET_CXX_SET_DECL_ASSEMBLER_NAME
+#define TARGET_CXX_SET_DECL_ASSEMBLER_NAME(decl) 0
+#endif
+
 /* Nonzero if NODE is a class template-id.  We can't rely on
    CLASSTYPE_USE_TEMPLATE here because of tricky bugs in the parser
    that hard to distinguish A<T> from A, where A<T> is the type as
@@ -2796,9 +2801,13 @@
 void
 mangle_decl (const tree decl)
 {
-  tree id = mangle_decl_string (decl);
-  id = targetm.mangle_decl_assembler_name (decl, id);
-  SET_DECL_ASSEMBLER_NAME (decl, id);
+  /* GCC-OS2: mangling hack - fixes _System */
+  tree id;
+  if (!TARGET_CXX_SET_DECL_ASSEMBLER_NAME (decl)) {
+     id = mangle_decl_string (decl);
+     id = targetm.mangle_decl_assembler_name (decl, id);
+     SET_DECL_ASSEMBLER_NAME (decl, id);
+  }
 }
 
 /* Generate the mangled representation of TYPE.  */
diff -ur gcc-4.4.5-o/gcc/cppdefault.c gcc-4.4.5/gcc/cppdefault.c
--- gcc-4.4.5-o/gcc/cppdefault.c	2007-07-26 18:07:00.000000000 +0930
+++ gcc-4.4.5/gcc/cppdefault.c	2010-10-03 18:54:54.000000000 +1030
@@ -41,6 +41,8 @@
 # undef CROSS_INCLUDE_DIR
 #endif
 
+/* GCC-OS2: Added a few more configuration options so we can automagically
+   rewrite /gcc/ to whereever we're installed for all of the dirs we use. */
 const struct default_include cpp_include_defaults[]
 #ifdef INCLUDE_DEFAULTS
 = INCLUDE_DEFAULTS;
@@ -60,10 +62,10 @@
 #endif
 #ifdef LOCAL_INCLUDE_DIR
     /* /usr/local/include comes before the fixincluded header files.  */
-    { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
+    { LOCAL_INCLUDE_DIR, LOCAL_INCLUDE_COMPONENT, 0, 1, 1, 0 },
 #endif
 #ifdef PREFIX_INCLUDE_DIR
-    { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 },
+    { PREFIX_INCLUDE_DIR, PREFIX_INCLUDE_COMPONENT, 0, 1, 0, 0 },
 #endif
 #ifdef GCC_INCLUDE_DIR
     /* This is the dir for gcc's private headers.  */
@@ -91,7 +93,7 @@
 #endif
 #ifdef SYSTEM_INCLUDE_DIR
     /* Some systems have an extra dir of include files.  */
-    { SYSTEM_INCLUDE_DIR, 0, 0, 0, 1, 0 },
+    { SYSTEM_INCLUDE_DIR, SYSTEM_INCLUDE_COMPONENT, 0, 0, 1, 0 },
 #endif
 #ifdef STANDARD_INCLUDE_DIR
     /* /usr/include comes dead last.  */
diff -ur gcc-4.4.5-o/gcc/cppdefault.h gcc-4.4.5/gcc/cppdefault.h
--- gcc-4.4.5-o/gcc/cppdefault.h	2007-07-26 18:07:00.000000000 +0930
+++ gcc-4.4.5/gcc/cppdefault.h	2010-10-03 18:54:54.000000000 +1030
@@ -67,4 +67,26 @@
 /* Return true if the toolchain is relocated.  */
 bool cpp_relocated (void);
 
+/* GCC-OS2: Additional configuration options. */
+#ifndef STANDARD_INCLUDE_SYSROOT
+#define STANDARD_INCLUDE_SYSROOT 1
+#endif 
+       
+#ifndef SYSTEM_INCLUDE_COMPONENT
+#define SYSTEM_INCLUDE_COMPONENT 0
+#endif 
+
+#ifndef SYSTEM_INCLUDE_SYSROOT
+#define SYSTEM_INCLUDE_SYSROOT 1
+#endif 
+
+#ifndef LOCAL_INCLUDE_COMPONENT
+#define LOCAL_INCLUDE_COMPONENT 0
+#endif 
+
+#ifndef PREFIX_INCLUDE_COMPONENT
+#define PREFIX_INCLUDE_COMPONENT 0
+#endif 
+/* GCC-OS2: end */
+
 #endif /* ! GCC_CPPDEFAULT_H */
diff -ur gcc-4.4.5-o/gcc/dbxout.c gcc-4.4.5/gcc/dbxout.c
--- gcc-4.4.5-o/gcc/dbxout.c	2009-10-19 22:45:26.000000000 +1030
+++ gcc-4.4.5/gcc/dbxout.c	2010-10-03 18:54:54.000000000 +1030
@@ -1342,7 +1342,14 @@
 static void
 dbxout_global_decl (tree decl)
 {
-  if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
+  if (TREE_CODE (decl) == VAR_DECL 
+#ifdef EMXx /* bird: debug info for all referenced global vars. problem with 4.3.2*/
+      && (   !DECL_EXTERNAL (decl)
+          || (   use_gnu_debug_info_extensions
+              && TREE_SYMBOL_REFERENCED (DECL_NAME (decl))))
+#else
+      && ! DECL_EXTERNAL (decl))
+#endif
     {
       int saved_tree_used = TREE_USED (decl);
       TREE_USED (decl) = 1;
@@ -2153,6 +2160,13 @@
       /* We must use the same test here as we use in the DBX_NO_XREFS case
 	 above.  We simplify it a bit since an enum will never have a variable
 	 size.  */
+#ifdef EMX
+      /* bird: I believe this test is wrong. The test above checks if we
+         already used gnu extenstions and gathers that it's ok to continue
+         do non-standard stuff then.
+         Anyway, we can't cope with crossreferences to enums. */
+     if (!use_gnu_debug_info_extensions)
+#endif
       if ((TYPE_NAME (type) != 0
 	   && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
 		 && DECL_IGNORED_P (TYPE_NAME (type)))
@@ -2775,10 +2789,19 @@
 
     case RESULT_DECL:
     case VAR_DECL:
+#ifdef EMX
+      /* Don't mention a variable that is external and unreferenced..
+	 bird: Referenced variables must be mentioned for OMF support.  */
+      if (DECL_EXTERNAL (decl)
+          && (   !use_gnu_debug_info_extensions
+              || !TREE_SYMBOL_REFERENCED (DECL_NAME (decl))))
+        break;
+#else
       /* Don't mention a variable that is external.
 	 Let the file that defines it describe it.  */
       if (DECL_EXTERNAL (decl))
 	break;
+#endif
 
       /* If the variable is really a constant
 	 and not written in memory, inform the debugger.
@@ -3054,6 +3077,35 @@
 	  addr = 0;
 	  number = offs;
 	  code = N_GSYM;
+#ifdef EMX 
+          /* bird: Two hacks.
+             1) Get right address for globals. We're using the value field of
+                the entry for this. This makes the following code work:
+                class foo { foo() {static const char *psz= "foo";} };
+             2) Hack 1 doesn't work for external or communal data. They would
+                both require a fixup of the stabs value to work - which a.out
+                naturally doesn't support (ELF does though).
+                So, what we'll do is to make an extra entry before the 'G'
+                entry which tells us the symbol name.
+                In this case the value of the 'G' entry is -12357.  */
+          if (use_gnu_debug_info_extensions)
+            {
+              addr = XEXP (home, 0);
+              if (DECL_EXTERNAL (decl) || DECL_COMMON (decl))
+                {
+                  fprintf (asm_out_file, "\t.stabs\t\"");
+                  output_addr_const (asm_out_file, addr);
+#if 0
+                  fprintf (asm_out_file, "\",%d,0,0,0\n", /*N_EXT | N_UNDF*/1);
+#else
+                  fprintf (asm_out_file, "\",%d,0,0,0\n", /*extension*/ 0xfe);
+#endif
+                  addr = 0;
+                  number = -12357;
+                }
+            }
+#endif
+
 	}
     }
   else if (GET_CODE (home) == CONCAT)
diff -ur gcc-4.4.5-o/gcc/explow.c gcc-4.4.5/gcc/explow.c
--- gcc-4.4.5-o/gcc/explow.c	2009-02-21 01:50:38.000000000 +1030
+++ gcc-4.4.5/gcc/explow.c	2010-10-03 18:54:54.000000000 +1030
@@ -1346,6 +1346,7 @@
 					         plus_constant (size, first)));
 
       addr = convert_memory_address (ptr_mode, addr);
+
       emit_library_call (stack_check_libfunc, LCT_NORMAL, VOIDmode, 1, addr,
 			 ptr_mode);
     }
diff -ur gcc-4.4.5-o/gcc/fix-header.c gcc-4.4.5/gcc/fix-header.c
--- gcc-4.4.5-o/gcc/fix-header.c	2009-02-21 01:50:38.000000000 +1030
+++ gcc-4.4.5/gcc/fix-header.c	2010-10-03 18:54:54.000000000 +1030
@@ -1086,6 +1086,10 @@
   long int inf_size;
   struct symbol_list *cur_symbols;
 
+#if defined (__EMX__)
+  return 0;	// fix-header does only harm to emx` includes
+#endif
+
   progname = "fix-header";
   if (argv[0] && argv[0][0])
     {
diff -ur gcc-4.4.5-o/gcc/function.c gcc-4.4.5/gcc/function.c
--- gcc-4.4.5-o/gcc/function.c	2010-08-17 05:54:54.000000000 +0930
+++ gcc-4.4.5/gcc/function.c	2010-10-03 18:54:56.000000000 +1030
@@ -4260,6 +4260,7 @@
      || (!defined(HAS_INIT_SECTION)			\
 	 && !defined(INIT_SECTION_ASM_OP)		\
 	 && !defined(INIT_ARRAY_SECTION_ASM_OP)))
+
   emit_library_call (init_one_libfunc (NAME__MAIN), LCT_NORMAL, VOIDmode, 0);
 #endif
 }
Only in gcc-4.4.5/gcc: function.c.orig
diff -ur gcc-4.4.5-o/gcc/gcc.c gcc-4.4.5/gcc/gcc.c
--- gcc-4.4.5-o/gcc/gcc.c	2010-01-09 10:35:06.000000000 +1030
+++ gcc-4.4.5/gcc/gcc.c	2010-10-03 18:54:56.000000000 +1030
@@ -362,7 +362,7 @@
 static void init_gcc_specs (struct obstack *, const char *, const char *,
 			    const char *);
 #endif
-#if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
+#if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX) && !defined (NO_FORCE_EXEOBJ_SUFFIX)
 static const char *convert_filename (const char *, int, int);
 #endif
 
@@ -1948,7 +1948,6 @@
 static int signal_count;
 
 /* Name with which this program was invoked.  */
-
 static const char *programname;
 
 /* Allocate the argument vector.  */
@@ -2884,7 +2883,7 @@
   for (n_commands = 1, i = 0; i < argbuf_index; i++)
     if (strcmp (argbuf[i], "|") == 0)
       {				/* each command.  */
-#if defined (__MSDOS__) || defined (OS2) || defined (VMS)
+#if defined (__MSDOS__) || defined (VMS)
 	fatal ("-pipe not supported");
 #endif
 	argbuf[i] = 0;	/* termination of command args.  */
@@ -3162,7 +3161,7 @@
 
 const char **outfiles;
 
-#if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
+#if (defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)) && !defined (NO_FORCE_EXEOBJ_SUFFIX)
 
 /* Convert NAME to a new name if it is the standard suffix.  DO_EXE
    is true if we should look for an executable suffix.  DO_OBJ
@@ -3572,6 +3571,7 @@
 	}
     }
 
+#ifndef __EMX__ /* Under OS/2 (__EMX__) LPATH is used in LANManager client & server */
   /* Use LPATH like LIBRARY_PATH (for the CMU build program).  */
   GET_ENVIRONMENT (temp, "LPATH");
   if (temp && *cross_compile == '0')
@@ -3604,6 +3604,7 @@
 	    endp++;
 	}
     }
+#endif /* not __EMX__ */
 
   /* Convert new-style -- options to old-style.  */
   translate_options (&argc, (const char *const **) &argv);
@@ -3930,6 +3931,7 @@
 
 	    case 'o':
 	      have_o = 1;
+#ifndef NO_FORCE_EXEOBJ_SUFFIX
 #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
 	      if (! have_c)
 		{
@@ -3965,6 +3967,7 @@
 	      else
 		argv[i] = convert_filename (argv[i], ! have_c, 0);
 #endif
+#endif
 	      goto normal_switch;
 
 	    default:
@@ -4039,14 +4042,12 @@
      configured-in locations.  */
   if (!gcc_exec_prefix)
     {
-#ifndef OS2
       add_prefix (&exec_prefixes, standard_libexec_prefix, "GCC",
 		  PREFIX_PRIORITY_LAST, 1, 0);
       add_prefix (&exec_prefixes, standard_libexec_prefix, "BINUTILS",
 		  PREFIX_PRIORITY_LAST, 2, 0);
       add_prefix (&exec_prefixes, standard_exec_prefix, "BINUTILS",
 		  PREFIX_PRIORITY_LAST, 2, 0);
-#endif
       add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS",
 		  PREFIX_PRIORITY_LAST, 1, 0);
     }
@@ -4301,7 +4302,7 @@
 	}
       else
 	{
-#ifdef HAVE_TARGET_OBJECT_SUFFIX
+#if defined (HAVE_TARGET_OBJECT_SUFFIX) && !defined (NO_FORCE_EXEOBJ_SUFFIX)
 	  argv[i] = convert_filename (argv[i], 0, access (argv[i], F_OK));
 #endif
 
@@ -6821,6 +6822,7 @@
      with %b in LINK_SPEC. We use the first input file that we can find
      a compiler to compile it instead of using infiles.language since for
      languages other than C we use aliases that we then lookup later.  */
+#ifndef __EMX__ /* This code fails on OS/2 - revert to the GCC 3.4.6 code */
   if (n_infiles > 0)
     {
       int i;
@@ -6832,6 +6834,10 @@
 	    break;
 	  }
     }
+#else
+  if (n_infiles > 0)
+    set_input (infiles[0].name);
+#endif
 
   if (error_count == 0)
     {
diff -ur gcc-4.4.5-o/gcc/genattrtab.c gcc-4.4.5/gcc/genattrtab.c
--- gcc-4.4.5-o/gcc/genattrtab.c	2008-07-09 16:15:20.000000000 +0930
+++ gcc-4.4.5/gcc/genattrtab.c	2010-10-03 18:54:56.000000000 +1030
@@ -4443,6 +4443,11 @@
   rtx tem;
   int i;
 
+#ifdef EMX
+  /* Otherwise we can't use more than 32Mb memory and genattrtab uses a lot */
+  _uflags (_UF_SBRK_MODEL, _UF_SBRK_ARBITRARY);
+#endif
+
   progname = "genattrtab";
 
   if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
diff -ur gcc-4.4.5-o/gcc/gengtype.c gcc-4.4.5/gcc/gengtype.c
--- gcc-4.4.5-o/gcc/gengtype.c	2008-08-07 01:40:22.000000000 +0930
+++ gcc-4.4.5/gcc/gengtype.c	2010-10-03 18:54:56.000000000 +1030
@@ -328,7 +328,11 @@
       /* No space for a lang_bitmap is necessary.  Discard the '['. */
       c = getc (list);
       line = here;
+#ifndef __EMX__
       while (c != ']' && c != '\n' && c != EOF)
+#else
+      while (c != ']' && c != '\n' && c != EOF && c != '\r')
+#endif
 	{
 	  *here++ = c;
 	  c = getc (list);
@@ -338,7 +342,11 @@
       if (c == ']')
 	{
 	  c = getc (list);  /* eat what should be a newline */
+#ifndef __EMX__
 	  if (c != '\n' && c != EOF)
+#else
+	  if (c != '\n' && c != EOF && c != '\r' )
+#endif
 	    error_at_line (pos, "junk on line after language tag [%s]", line);
 	}
       else
diff -ur gcc-4.4.5-o/gcc/genmultilib gcc-4.4.5/gcc/genmultilib
--- gcc-4.4.5-o/gcc/genmultilib	2007-07-26 18:07:00.000000000 +0930
+++ gcc-4.4.5/gcc/genmultilib	2010-10-03 18:54:56.000000000 +1030
@@ -40,6 +40,9 @@
 # elements in the second list are separated by spaces.  If the second
 # argument is empty, the option names will be used as the directory
 # names.
+# If number of elements in second argument is bigger than number of options
+# in the first argument, the n+1'th element is used as default directory
+# name (i.e. when no one of options specified in argument 1 was used)
 
 # The optional third argument is a list of options which are
 # identical.  The elements in the list are separated by spaces.  Each
@@ -261,6 +264,12 @@
   fi
 fi
 
+# See if default directory was specified
+if [ -n "$1" ]; then
+  defaultdir="$1"
+else
+  defaultdir="."
+fi
 # We need another recursive shell script to correctly handle positive
 # matches.  If we are invoked as
 #   genmultilib "opt1 opt2" "" "opt1=nopt1 opt2=nopt2"
diff -ur gcc-4.4.5-o/gcc/ggc-page.c gcc-4.4.5/gcc/ggc-page.c
--- gcc-4.4.5-o/gcc/ggc-page.c	2008-07-29 00:03:56.000000000 +0930
+++ gcc-4.4.5/gcc/ggc-page.c	2011-01-22 14:58:14.000000000 +1030
@@ -662,7 +662,7 @@
 
   if (page == (char *) MAP_FAILED)
     {
-      perror ("virtual memory exhausted");
+      perror ("virtual memory exhaustedXX");
       exit (FATAL_EXIT_CODE);
     }
 
diff -ur gcc-4.4.5-o/gcc/ggc-zone.c gcc-4.4.5/gcc/ggc-zone.c
--- gcc-4.4.5-o/gcc/ggc-zone.c	2008-07-04 14:17:54.000000000 +0930
+++ gcc-4.4.5/gcc/ggc-zone.c	2011-01-22 09:41:24.000000000 +1030
@@ -39,6 +39,7 @@
 
 /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
    file open.  Prefer either to valloc.  */
+#ifndef __OS2__
 #ifdef HAVE_MMAP_ANON
 # undef HAVE_MMAP_DEV_ZERO
 
@@ -59,6 +60,7 @@
 # endif
 # define USING_MMAP
 #endif
+#endif /* __OS2__ */
 
 #ifndef USING_MMAP
 #error Zone collector requires mmap
@@ -852,7 +854,7 @@
 
   if (page == (char *) MAP_FAILED)
     {
-      perror ("virtual memory exhausted");
+      perror ("virtual memory exhaustedYY");
       exit (FATAL_EXIT_CODE);
     }
 
Only in gcc-4.4.5/gcc: gthr-os2.h
diff -ur gcc-4.4.5-o/gcc/gthr.h gcc-4.4.5/gcc/gthr.h
--- gcc-4.4.5-o/gcc/gthr.h	2009-04-10 08:53:06.000000000 +0930
+++ gcc-4.4.5/gcc/gthr.h	2010-10-03 18:54:56.000000000 +1030
@@ -137,6 +137,7 @@
      POSIX/Unix95 threads with -D_PTHREADS95
      DCE threads with -D_DCE_THREADS
      Solaris/UI threads with -D_SOLARIS_THREADS
+     OS/2 threads with -D_OS2_THREADS
    
 */
 
@@ -151,6 +152,8 @@
 #include "gthr-dce.h"
 #elif _SOLARIS_THREADS
 #include "gthr-solaris.h"
+#elif _OS2_THREADS 
+#include "gthr-os2.h"
 
 /* Include GTHREAD_FILE if one is defined.  */
 #elif defined(HAVE_GTHR_DEFAULT)
Only in gcc-4.4.5/gcc: include-fixed
diff -ur gcc-4.4.5-o/gcc/incpath.c gcc-4.4.5/gcc/incpath.c
--- gcc-4.4.5-o/gcc/incpath.c	2009-02-21 01:50:38.000000000 +1030
+++ gcc-4.4.5/gcc/incpath.c	2010-10-03 18:54:56.000000000 +1030
@@ -37,7 +37,11 @@
 # define INO_T_EQ(A, B) (!memcmp (&(A), &(B), sizeof (A)))
 # define INO_T_COPY(DEST, SRC) memcpy(&(DEST), &(SRC), sizeof (SRC))
 #elif !defined (HOST_LACKS_INODE_NUMBERS)
-# define INO_T_EQ(A, B) ((A) == (B))
+# if defined __EMX__
+#  define INO_T_EQ(A, B) 0
+# else
+#  define INO_T_EQ(A, B) ((A) == (B))
+# endif
 # define INO_T_COPY(DEST, SRC) (DEST) = (SRC)
 #endif
 
diff -ur gcc-4.4.5-o/gcc/langhooks.c gcc-4.4.5/gcc/langhooks.c
--- gcc-4.4.5-o/gcc/langhooks.c	2010-06-16 02:02:24.000000000 +0930
+++ gcc-4.4.5/gcc/langhooks.c	2010-10-03 18:54:56.000000000 +1030
@@ -38,6 +38,12 @@
 #include "ggc.h"
 #include "diagnostic.h"
 
+/* Provide a dummy target-specific name mangling hook */
+#ifndef TARGET_C_SET_DECL_ASSEMBLER_NAME
+#define TARGET_C_SET_DECL_ASSEMBLER_NAME(decl) 0
+#endif
+
+
 /* Do nothing; in many cases the default hook.  */
 
 void
@@ -166,6 +172,9 @@
 		      || DECL_EXTERNAL (decl)
 		      || TREE_PUBLIC (decl))));
   
+     /* GCCOS2: Some targets may want to apply special mangling
+        depending on certain attributes etc (e.g. stdcall). */
+     if (!TARGET_C_SET_DECL_ASSEMBLER_NAME (decl)) {
   /* By default, assume the name to use in assembly code is the same
      as that used in the source language.  (That's correct for C, and
      GCC used to set DECL_ASSEMBLER_NAME to the same value as
@@ -189,7 +198,7 @@
       id = get_identifier (label);
     }
   SET_DECL_ASSEMBLER_NAME (decl, id);
-
+ } /* os2 */
 }
 
 /* Type promotion for variable arguments.  */
Only in gcc-4.4.5/gcc: langhooks.c.orig
diff -ur gcc-4.4.5-o/gcc/libgcc2.c gcc-4.4.5/gcc/libgcc2.c
--- gcc-4.4.5-o/gcc/libgcc2.c	2009-09-25 04:30:44.000000000 +0930
+++ gcc-4.4.5/gcc/libgcc2.c	2010-10-03 18:54:56.000000000 +1030
@@ -2139,7 +2139,7 @@
       (*(p-1)) ();
     }
 #endif
-#if defined (EH_FRAME_SECTION_NAME) && !defined (HAS_INIT_SECTION)
+#if defined (EH_FRAME_SECTION_NAME) && !defined (HAS_INIT_SECTION) && !defined (DONT_AUTOREGISTER_FRAME_INFO)
   {
     static int completed = 0;
     if (! completed)
@@ -2158,7 +2158,7 @@
 void
 __do_global_ctors (void)
 {
-#ifdef EH_FRAME_SECTION_NAME
+#if defined (EH_FRAME_SECTION_NAME) && !defined (DONT_AUTOREGISTER_FRAME_INFO)
   {
     static struct object object;
     __register_frame_info (__EH_FRAME_BEGIN__, &object);
diff -ur gcc-4.4.5-o/gcc/Makefile.in gcc-4.4.5/gcc/Makefile.in
--- gcc-4.4.5-o/gcc/Makefile.in	2010-09-07 20:37:30.000000000 +0930
+++ gcc-4.4.5/gcc/Makefile.in	2010-10-03 18:54:56.000000000 +1030
@@ -206,6 +206,9 @@
 # -------------------------------------------
 
 SHELL = @SHELL@
+# "mkdir cp; cp something cp" doesn't work ash on OS/2.
+CP = cp@host_exeext@
+
 # pwd command to use.  Allow user to override default by setting PWDCMD in
 # the environment to account for automounters.  The make variable must not
 # be called PWDCMD, otherwise the value set here is passed to make
@@ -933,6 +936,16 @@
 	    build/min-insn-modes.o build/gensupport.o build/print-rtl.o
 BUILD_ERRORS = build/errors.o
 
+# GCC-OS2: help
+# This gets linked into gcc if command-line help was enabled
+#CLH_LIBS = @gcc_clh_libs@
+# These definitions enables --help for gcc
+#CLH_CFLAGS = @gcc_clh_cflags@
+#CLH_GCC = @gcc_clh_gcc@
+#CLH_CPP = @gcc_clh_cpp@
+#CLH_G77 = @gcc_clh_g77@
+#CLH_GCJ = @gcc_clh_gcj@
+
 # Specify the directories to be searched for header files.
 # Both . and srcdir are used, in that order,
 # so that *config.h will be found in the compilation
@@ -1637,7 +1650,7 @@
 # compile libgcc2.a.
 # Also create gcc-cross, so that install-common will install properly.
 gcc-cross$(exeext): xgcc$(exeext)
-	cp xgcc$(exeext) gcc-cross$(exeext)
+	$(CP) xgcc$(exeext) gcc-cross$(exeext)
 
 dummy-checksum.o : dummy-checksum.c
 
@@ -1654,6 +1667,16 @@
 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) cc1-checksum.o \
 	  $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
+# GCC-OS2: help.
+clh.o: clh.c $(CONFIG_H)
+	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $(srcdir)/clh.c
+
+clh_gcc.c: $(srcdir)/doc/invoke.texi $(srcdir)/mkoptdesc.sh
+	$(srcdir)/mkoptdesc.sh $(srcdir)/doc/invoke.texi gcc > clh_gcc.c
+
+clh_cpp.c: $(srcdir)/doc/invoke.texi $(srcdir)/mkoptdesc.sh
+	$(srcdir)/mkoptdesc.sh $(srcdir)/doc/invoke.texi cpp > clh_cpp.c
+
 #
 # Build libgcc.a.
 
@@ -3522,7 +3545,7 @@
 
 test-protoize-simple: ./protoize ./unprotoize $(GCC_PASSES)
 	-rm -f tmp-proto.[cso]
-	cp $(srcdir)/protoize.c tmp-proto.c
+	$(CP) $(srcdir)/protoize.c tmp-proto.c
 	chmod u+w tmp-proto.c
 	./protoize -N -B ./ -x getopt.h -c "-B./ -Wall -Wwrite-strings \
 	  $(GCC_CFLAGS) $(INCLUDES) \
@@ -3595,12 +3618,12 @@
 	    realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
 	    $(STAMP) include/$$realfile; \
 	    rm -f include/$$realfile; \
-	    cp $$file include; \
+	    $(CP) $$file include; \
 	    chmod a+r include/$$realfile; \
 	  fi; \
 	done
 	rm -f include/unwind.h
-	cp $(UNWIND_H) include/unwind.h
+	$(CP) $(UNWIND_H) include/unwind.h
 	set -e; for ml in `cat fixinc_list`; do \
 	  sysroot_headers_suffix=`echo $${ml} | sed -e 's/;.*$$//'`; \
 	  multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
@@ -3618,7 +3641,7 @@
 	done
 # Install the README
 	rm -f include-fixed/README
-	cp $(srcdir)/../fixincludes/README-fixinc include-fixed/README
+	$(CP) $(srcdir)/../fixincludes/README-fixinc include-fixed/README
 	chmod a+r include-fixed/README
 	$(STAMP) $@
 
@@ -3707,7 +3730,7 @@
 	    if [ -f $${fix_dir}/limits.h ]; then \
 	      mv $${fix_dir}/limits.h $${fix_dir}/syslimits.h; \
 	    else \
-	      cp $(srcdir)/gsyslimits.h $${fix_dir}/syslimits.h; \
+	      $(CP) $(srcdir)/gsyslimits.h $${fix_dir}/syslimits.h; \
 	    fi; \
 	    chmod a+r $${fix_dir}/syslimits.h; \
 	  done; \
diff -ur gcc-4.4.5-o/gcc/prefix.c gcc-4.4.5/gcc/prefix.c
--- gcc-4.4.5-o/gcc/prefix.c	2007-09-04 02:39:20.000000000 +0930
+++ gcc-4.4.5/gcc/prefix.c	2010-10-03 18:54:56.000000000 +1030
@@ -352,5 +352,7 @@
 void
 set_std_prefix (const char *prefix, int len)
 {
+#ifndef __EMX__
   std_prefix = save_string (prefix, len);
+#endif
 }
diff -ur gcc-4.4.5-o/gcc/reg-stack.c gcc-4.4.5/gcc/reg-stack.c
--- gcc-4.4.5-o/gcc/reg-stack.c	2009-05-23 04:29:30.000000000 +0930
+++ gcc-4.4.5/gcc/reg-stack.c	2010-10-03 18:54:56.000000000 +1030
@@ -2612,6 +2612,21 @@
   edge e;
   edge_iterator ei;
 
+  /* GCC-OS2: fp regs passing
+     Figure out the arguments passed in stack registers.  */
+  tree parm = DECL_ARGUMENTS (current_function_decl);
+  int incoming_arg [REG_STACK_SIZE];
+  int i;
+
+  memset (incoming_arg, 0, sizeof (incoming_arg));
+  while (parm)
+    {
+      rtx x = DECL_INCOMING_RTL (parm);
+      if (STACK_REG_P (x))
+	incoming_arg[REGNO (x) - FIRST_STACK_REG] = x;
+      parm = TREE_CHAIN (parm);
+    }
+
   /* Load something into each stack register live at function entry.
      Such live registers can be caused by uninitialized variables or
      functions not returning values on all paths.  In order to keep
@@ -2626,9 +2641,17 @@
       basic_block block = e->dest;
       block_info bi = BLOCK_INFO (block);
       int reg, top = -1;
+      int dead_arguments = 0; /* GCC-OS2: fp regs passing */ 
+
+      /* GCC-OS2: fp regs passing
+         Put the incoming arguments to the stack. */
+      for (i = LAST_STACK_REG; i >= FIRST_STACK_REG; i--)
+	if (incoming_arg [i - FIRST_STACK_REG])
+	  bi->stack_in.reg[++top] = i;
 
       for (reg = LAST_STACK_REG; reg >= FIRST_STACK_REG; --reg)
-	if (TEST_HARD_REG_BIT (bi->stack_in.reg_set, reg))
+	if (TEST_HARD_REG_BIT (bi->stack_in.reg_set, reg)
+	    && !incoming_arg [reg - FIRST_STACK_REG]) /* GCC-OS2: fp regs passing */
 	  {
 	    rtx init;
 
@@ -2642,6 +2665,42 @@
 	  }
 
       bi->stack_in.top = top;
+
+      /* GCC-OS2: fp regs passing */
+
+      /* Check whether there are any dead arguments that needs
+         to be popped.  */
+      for (i = LAST_STACK_REG; i >= FIRST_STACK_REG; i--)
+	if (incoming_arg [i - FIRST_STACK_REG]
+	    && !TEST_HARD_REG_BIT (bi->stack_in.reg_set, i))
+          {
+	    dead_arguments = 1;
+	    break;
+          }
+
+      if (dead_arguments)
+	{
+	  rtx seq;
+	  rtx after;
+	  start_sequence ();
+		  
+	  /* ??? pop_stack needs some point to emit insns after.
+	     Also needed to keep gen_sequence from returning a 
+	     pattern as opposed to a sequence, which would lose
+	     REG_DEAD notes.  */
+	  after = emit_note (NOTE_INSN_DELETED);
+
+	  for (i = LAST_STACK_REG; i >= FIRST_STACK_REG; i--)
+	    if (incoming_arg [i - FIRST_STACK_REG]
+		&& !TEST_HARD_REG_BIT (bi->stack_in.reg_set,i))
+	      after = emit_pop_insn (after, &bi->stack_in,
+				     FP_MODE_REG (i, DFmode), EMIT_AFTER);
+
+	  seq = get_insns ();
+	  end_sequence ();
+	  inserted = 1;
+	  insert_insn_on_edge (seq, e);
+	}
     }
 
   return inserted;
diff -ur gcc-4.4.5-o/gcc/target-def.h gcc-4.4.5/gcc/target-def.h
--- gcc-4.4.5-o/gcc/target-def.h	2009-02-21 01:50:38.000000000 +1030
+++ gcc-4.4.5/gcc/target-def.h	2010-10-03 18:54:56.000000000 +1030
@@ -95,7 +95,9 @@
 #define TARGET_ASM_FUNCTION_PROLOGUE default_function_pro_epilogue
 #define TARGET_ASM_FUNCTION_EPILOGUE default_function_pro_epilogue
 #define TARGET_ASM_FUNCTION_END_PROLOGUE no_asm_to_stream
+#ifndef TARGET_ASM_FUNCTION_BEGIN_EPILOGUE /* GCC-OS2 */
 #define TARGET_ASM_FUNCTION_BEGIN_EPILOGUE no_asm_to_stream
+#endif                                     /* GCC-OS2 */
 
 #ifndef TARGET_ASM_RELOC_RW_MASK
 #define TARGET_ASM_RELOC_RW_MASK default_reloc_rw_mask
diff -ur gcc-4.4.5-o/gcc/toplev.c gcc-4.4.5/gcc/toplev.c
--- gcc-4.4.5-o/gcc/toplev.c	2010-03-31 13:21:30.000000000 +1030
+++ gcc-4.4.5/gcc/toplev.c	2010-10-03 18:54:56.000000000 +1030
@@ -1572,9 +1572,11 @@
   pp_format_decoder (global_dc->printer) = &default_tree_printer;
 
   /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
+#ifndef __OS2__ /* On OS/2 we'd rather see the registers to help understand where the crash occured */
 #ifdef SIGSEGV
   signal (SIGSEGV, crash_signal);
 #endif
+#endif
 #ifdef SIGILL
   signal (SIGILL, crash_signal);
 #endif
diff -ur gcc-4.4.5-o/gcc/tree.c gcc-4.4.5/gcc/tree.c
--- gcc-4.4.5-o/gcc/tree.c	2010-04-08 20:58:06.000000000 +0930
+++ gcc-4.4.5/gcc/tree.c	2010-10-03 18:54:56.000000000 +1030
@@ -4186,7 +4186,6 @@
 
   return NULL_TREE;
 }
-
 #endif /* TARGET_DLLIMPORT_DECL_ATTRIBUTES  */
 
 /* Set the type qualifiers for TYPE to TYPE_QUALS, which is a bitmask
@@ -7022,7 +7021,6 @@
      the program) rather than the file name (which imposes extra
      constraints).  */
   sprintf (buf, FILE_FUNCTION_FORMAT, type, p);
-
   return get_identifier (buf);
 }
 
Only in gcc-4.4.5/gcc: treelang
diff -ur gcc-4.4.5-o/gcc/unwind-compat.c gcc-4.4.5/gcc/unwind-compat.c
--- gcc-4.4.5-o/gcc/unwind-compat.c	2009-04-10 08:53:06.000000000 +0930
+++ gcc-4.4.5/gcc/unwind-compat.c	2010-10-03 18:54:56.000000000 +1030
@@ -23,7 +23,7 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if defined (USE_GAS_SYMVER) && defined (USE_LIBUNWIND_EXCEPTIONS)
+#if defined (USE_GAS_SYMVER) && defined (USE_LIBUNWIND_EXCEPTIONS) 
 #include "tconfig.h"
 #include "tsystem.h"
 #include "unwind.h"
diff -ur gcc-4.4.5-o/gcc/unwind.inc gcc-4.4.5/gcc/unwind.inc
--- gcc-4.4.5-o/gcc/unwind.inc	2009-04-10 08:53:06.000000000 +0930
+++ gcc-4.4.5/gcc/unwind.inc	2010-12-20 11:46:50.000000000 +1030
@@ -135,7 +135,6 @@
   uw_install_context (&this_context, &cur_context);
 }
 
-
 /* Subroutine of _Unwind_ForcedUnwind also invoked from _Unwind_Resume.  */
 
 static _Unwind_Reason_Code
@@ -261,7 +260,6 @@
   uw_install_context (&this_context, &cur_context);
 }
 
-
 /* A convenience function that calls the exception_cleanup field.  */
 
 void
@@ -271,7 +269,6 @@
     (*exc->exception_cleanup) (_URC_FOREIGN_EXCEPTION_CAUGHT, exc);
 }
 
-
 /* Perform stack backtrace through unwind data.  */
 
 _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
diff -ur gcc-4.4.5-o/gcc/varasm.c gcc-4.4.5/gcc/varasm.c
--- gcc-4.4.5-o/gcc/varasm.c	2010-01-20 21:57:48.000000000 +1030
+++ gcc-4.4.5/gcc/varasm.c	2010-10-03 18:54:56.000000000 +1030
@@ -1511,7 +1511,6 @@
 default_named_section_asm_out_destructor (rtx symbol, int priority)
 {
   section *sec;
-
   if (priority != DEFAULT_INIT_PRIORITY)
     sec = get_cdtor_priority_section (priority, 
 				      /*constructor_p=*/false);
@@ -2445,6 +2444,20 @@
 	name = IDENTIFIER_POINTER (id);
       gcc_assert (! TREE_CHAIN (id));
     }
+#if 0
+  /* Some code assume that this is the identifier returned 
+     by DECL_ASSEMBLER_NAME (). However, for GCC-OS2 it's not
+     since the calling conventions _Optlink, __stdcall, and
+     _System name encodings are included in the identifier
+     returned by DECL_ASSEMBLER_NAME ().
+     Therefore we need this extra little cludge here. */
+  if (name != real_name)
+    {
+      id = maybe_get_identifier (name);
+      if (id)
+	mark_referenced (id);
+   }
+#endif
 
   assemble_name_raw (file, name);
 }
Only in gcc-4.4.5: gcc.diff
Only in gcc-4.4.5: gcc445_good.def
Only in gcc-4.4.5: gcc445_orig.def
Only in gcc-4.4.5: gcc445.lib
Only in gcc-4.4.5: gnattools
diff -ur gcc-4.4.5-o/include/filenames.h gcc-4.4.5/include/filenames.h
--- gcc-4.4.5-o/include/filenames.h	2008-03-22 10:05:06.000000000 +1030
+++ gcc-4.4.5/include/filenames.h	2010-10-03 18:54:56.000000000 +1030
@@ -30,7 +30,7 @@
 extern "C" {
 #endif
 
-#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
+#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__) || defined(__EMX__)
 
 #ifndef HAVE_DOS_BASED_FILE_SYSTEM
 #define HAVE_DOS_BASED_FILE_SYSTEM 1
Only in gcc-4.4.5: libada
Only in gcc-4.4.5/libgcc/config/i386: t-emx
diff -ur gcc-4.4.5-o/libgcc/config.host gcc-4.4.5/libgcc/config.host
--- gcc-4.4.5-o/libgcc/config.host	2009-04-17 21:28:40.000000000 +0930
+++ gcc-4.4.5/libgcc/config.host	2010-10-03 18:54:56.000000000 +1030
@@ -339,6 +339,9 @@
 	;;
 x86_64-*-mingw*)
 	;;
+i*86-pc-*emx)		# i?86 running OS/2
+    host_exeext=.exe
+    ;;
 i[34567]86-*-interix3*)
 	;;
 ia64*-*-elf*)
Only in gcc-4.4.5: libgcc.diff
diff -ur gcc-4.4.5-o/libgomp/config/posix/lock.c gcc-4.4.5/libgomp/config/posix/lock.c
--- gcc-4.4.5-o/libgomp/config/posix/lock.c	2009-04-10 08:53:06.000000000 +0930
+++ gcc-4.4.5/libgomp/config/posix/lock.c	2010-10-03 18:54:56.000000000 +1030
@@ -243,6 +243,7 @@
 void
 gomp_init_nest_lock_25 (omp_nest_lock_25_t *lock)
 {
+#ifndef __EMX__
   pthread_mutexattr_t attr;
 
   pthread_mutexattr_init (&attr);
@@ -250,6 +251,7 @@
   pthread_mutex_init (&lock->lock, &attr);
   lock->count = 0;
   pthread_mutexattr_destroy (&attr);
+#endif
 }
 
 void
diff -ur gcc-4.4.5-o/libgomp/config/posix/omp-lock.h gcc-4.4.5/libgomp/config/posix/omp-lock.h
--- gcc-4.4.5-o/libgomp/config/posix/omp-lock.h	2008-06-06 22:31:54.000000000 +0930
+++ gcc-4.4.5/libgomp/config/posix/omp-lock.h	2010-10-03 18:54:56.000000000 +1030
@@ -8,11 +8,13 @@
    thread than the one that called pthread_mutex_lock.  */
 
 #include <pthread.h>
+#ifndef __EMX__
 #include <semaphore.h>
+#endif
 
 typedef pthread_mutex_t omp_lock_25_t;
 typedef struct { pthread_mutex_t lock; int count; } omp_nest_lock_25_t;
-#ifdef HAVE_BROKEN_POSIX_SEMAPHORES
+#if defined(HAVE_BROKEN_POSIX_SEMAPHORES) || defined(__EMX__)
 /* If we don't have working semaphores, we'll make all explicit tasks
    tied to the creating thread.  */
 typedef pthread_mutex_t omp_lock_t;
diff -ur gcc-4.4.5-o/libgomp/config/posix/sem.h gcc-4.4.5/libgomp/config/posix/sem.h
--- gcc-4.4.5-o/libgomp/config/posix/sem.h	2009-04-10 08:53:06.000000000 +0930
+++ gcc-4.4.5/libgomp/config/posix/sem.h	2010-10-03 18:54:56.000000000 +1030
@@ -37,7 +37,11 @@
 # pragma GCC visibility push(default)
 #endif
 
+#ifndef __EMX__
 #include <semaphore.h>
+#else
+#define HAVE_BROKEN_POSIX_SEMAPHORES 1
+#endif 
 
 #ifdef HAVE_ATTRIBUTE_VISIBILITY
 # pragma GCC visibility pop
diff -ur gcc-4.4.5-o/libiberty/argv.c gcc-4.4.5/libiberty/argv.c
--- gcc-4.4.5-o/libiberty/argv.c	2007-07-24 02:59:16.000000000 +0930
+++ gcc-4.4.5/libiberty/argv.c	2010-10-03 18:54:56.000000000 +1030
@@ -183,6 +183,7 @@
 	    {
 	      input++;
 	    }
+
 	  if ((maxargc == 0) || (argc >= (maxargc - 1)))
 	    {
 	      /* argv needs initialization, or expansion */
@@ -223,10 +224,12 @@
 		      bsquote = 0;
 		      *arg++ = *input;
 		    }
+#ifndef __OS2__ /* skip this due to use of backslash in drive paths */
 		  else if (*input == '\\')
 		    {
 		      bsquote = 1;
 		    }
+#endif
 		  else if (squote)
 		    {
 		      if (*input == '\'')
@@ -474,7 +477,6 @@
   "arg 'Jack said \\'hi\\'' has single quotes",
   "arg 'Jack said \\\"hi\\\"' has double quotes",
   "a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9",
-  
   /* This should be expanded into only one argument.  */
   "trailing-whitespace ",
 
diff -ur gcc-4.4.5-o/libiberty/basename.c gcc-4.4.5/libiberty/basename.c
--- gcc-4.4.5-o/libiberty/basename.c	2005-04-16 10:10:08.000000000 +0930
+++ gcc-4.4.5/libiberty/basename.c	2010-10-03 18:54:56.000000000 +1030
@@ -24,7 +24,7 @@
 #endif
 
 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-  defined (__OS2__)
+  defined (__OS2__) || defined (__EMX__)
 #define HAVE_DOS_BASED_FILE_SYSTEM
 #ifndef DIR_SEPARATOR_2 
 #define DIR_SEPARATOR_2 '\\'
Only in gcc-4.4.5/libiberty/config: mh-emx
diff -ur gcc-4.4.5-o/libiberty/configure gcc-4.4.5/libiberty/configure
--- gcc-4.4.5-o/libiberty/configure	2009-04-08 23:48:32.000000000 +0930
+++ gcc-4.4.5/libiberty/configure	2010-10-03 18:54:56.000000000 +1030
@@ -2467,13 +2467,13 @@
   CFLAGS=$ac_save_CFLAGS
 elif test $ac_cv_prog_cc_g = yes; then
   if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
+    CFLAGS="-g"
   else
     CFLAGS="-g"
   fi
 else
   if test "$GCC" = yes; then
-    CFLAGS="-O2"
+    CFLAGS=""
   else
     CFLAGS=
   fi
@@ -4104,6 +4104,7 @@
 if [ "${shared}" = "yes" ]; then
   case "${host}" in
     *-*-cygwin*)	;;
+    i*86-pc-*emx)	;;
     alpha*-*-linux*)	PICFLAG=-fPIC ;;
     arm*-*-*)		PICFLAG=-fPIC ;;
     hppa*-*-*)		PICFLAG=-fPIC ;;
diff -ur gcc-4.4.5-o/libiberty/configure.ac gcc-4.4.5/libiberty/configure.ac
--- gcc-4.4.5-o/libiberty/configure.ac	2009-04-08 23:48:32.000000000 +0930
+++ gcc-4.4.5/libiberty/configure.ac	2010-10-03 18:54:56.000000000 +1030
@@ -201,6 +201,7 @@
 if [[ "${shared}" = "yes" ]]; then
   case "${host}" in
     *-*-cygwin*)	;;
+    i*86-pc-*emx)	;;
     alpha*-*-linux*)	PICFLAG=-fPIC ;;
     arm*-*-*)		PICFLAG=-fPIC ;;
     hppa*-*-*)		PICFLAG=-fPIC ;;
diff -ur gcc-4.4.5-o/libiberty/getpwd.c gcc-4.4.5/libiberty/getpwd.c
--- gcc-4.4.5-o/libiberty/getpwd.c	2005-05-25 06:18:24.000000000 +0930
+++ gcc-4.4.5/libiberty/getpwd.c	2010-10-03 18:54:56.000000000 +1030
@@ -57,7 +57,7 @@
 #define GUESSPATHLEN 100
 #endif
 
-#if !(defined (VMS) || (defined(_WIN32) && !defined(__CYGWIN__)))
+#if !(defined (VMS) || (defined(_WIN32) && !defined(__CYGWIN__)) || defined(__EMX__))
 
 /* Get the working directory.  Use the PWD environment variable if it's
    set correctly, since this is faster and gives more uniform answers
@@ -105,7 +105,7 @@
   return p;
 }
 
-#else	/* VMS || _WIN32 && !__CYGWIN__ */
+#else	/* VMS || _WIN32 && !__CYGWIN__ || __EMX__ */
 
 #ifndef MAXPATHLEN
 #define MAXPATHLEN 255
@@ -125,4 +125,4 @@
   return pwd;
 }
 
-#endif	/* VMS || _WIN32 && !__CYGWIN__ */
+#endif	/* VMS || _WIN32 && !__CYGWIN__ || __EMX__ */
diff -ur gcc-4.4.5-o/libiberty/make-relative-prefix.c gcc-4.4.5/libiberty/make-relative-prefix.c
--- gcc-4.4.5-o/libiberty/make-relative-prefix.c	2008-03-25 03:41:20.000000000 +1030
+++ gcc-4.4.5/libiberty/make-relative-prefix.c	2010-10-03 18:54:56.000000000 +1030
@@ -74,7 +74,7 @@
 #endif
 
 #if defined (_WIN32) || defined (__MSDOS__) \
-    || defined (__DJGPP__) || defined (__OS2__)
+    || defined (__DJGPP__) || defined (__OS2__) || defined (__EMX__)
 #  define HAVE_DOS_BASED_FILE_SYSTEM
 #  define HAVE_HOST_EXECUTABLE_SUFFIX
 #  define HOST_EXECUTABLE_SUFFIX ".exe"
diff -ur gcc-4.4.5-o/libiberty/make-temp-file.c gcc-4.4.5/libiberty/make-temp-file.c
--- gcc-4.4.5-o/libiberty/make-temp-file.c	2009-02-23 05:13:30.000000000 +1030
+++ gcc-4.4.5/libiberty/make-temp-file.c	2010-10-03 18:54:56.000000000 +1030
@@ -132,7 +132,14 @@
       len = strlen (base);
       tmpdir = XNEWVEC (char, len + 2);
       strcpy (tmpdir, base);
+#ifdef __EMX__
+  if (tmpdir[len - 1] == '\\' || tmpdir[len - 1] == '/')
+    tmpdir[--len] = DIR_SEPARATOR;
+  else
+    tmpdir[len] = DIR_SEPARATOR;
+#else
       tmpdir[len] = DIR_SEPARATOR;
+#endif
       tmpdir[len+1] = '\0';
       memoized_tmpdir = tmpdir;
 #else /* defined(_WIN32) && !defined(__CYGWIN__) */
diff -ur gcc-4.4.5-o/libiberty/Makefile.in gcc-4.4.5/libiberty/Makefile.in
--- gcc-4.4.5-o/libiberty/Makefile.in	2008-10-23 00:00:18.000000000 +1030
+++ gcc-4.4.5/libiberty/Makefile.in	2010-10-03 18:54:56.000000000 +1030
@@ -71,7 +71,7 @@
 
 # A configuration can specify extra .o files that should be included,
 # even if they are in libc. (Perhaps the libc version is buggy.)
-EXTRA_OFILES = 
+EXTRA_OFILES =
 
 # Flags to pass to a recursive make.
 FLAGS_TO_PASS = \
diff -ur gcc-4.4.5-o/libiberty/pex-unix.c gcc-4.4.5/libiberty/pex-unix.c
--- gcc-4.4.5-o/libiberty/pex-unix.c	2007-08-24 17:10:34.000000000 +0930
+++ gcc-4.4.5/libiberty/pex-unix.c	2010-10-03 18:54:56.000000000 +1030
@@ -86,7 +86,7 @@
 
 static pid_t pex_wait (struct pex_obj *, pid_t, int *, struct pex_time *);
 
-#ifdef HAVE_WAIT4
+#if defined(HAVE_WAIT4) && !defined(__EMX__)
 
 static pid_t
 pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status,
Only in gcc-4.4.5/libstdc++-v3/config/cpu: mips
Only in gcc-4.4.5/libstdc++-v3/config/os/solaris: solaris2.5
Only in gcc-4.4.5/libstdc++-v3/config/os/solaris: solaris2.6
Only in gcc-4.4.5/libstdc++-v3/config/os: windiss
diff -ur gcc-4.4.5-o/libstdc++-v3/include/bits/stringfwd.h gcc-4.4.5/libstdc++-v3/include/bits/stringfwd.h
--- gcc-4.4.5-o/libstdc++-v3/include/bits/stringfwd.h	2009-04-10 08:53:06.000000000 +0930
+++ gcc-4.4.5/libstdc++-v3/include/bits/stringfwd.h	2010-10-03 18:54:56.000000000 +1030
@@ -59,6 +59,8 @@
   template<> struct char_traits<wchar_t>;
 
   typedef basic_string<wchar_t> wstring;
+#elif defined(__OS2__)
+  typedef basic_string<wchar_t> wstring;
 #endif
 
 #if (defined(__GXX_EXPERIMENTAL_CXX0X__) \
diff -ur gcc-4.4.5-o/libstdc++-v3/include/parallel/compatibility.h gcc-4.4.5/libstdc++-v3/include/parallel/compatibility.h
--- gcc-4.4.5-o/libstdc++-v3/include/parallel/compatibility.h	2009-04-10 08:53:06.000000000 +0930
+++ gcc-4.4.5/libstdc++-v3/include/parallel/compatibility.h	2010-10-03 18:54:56.000000000 +1030
@@ -39,7 +39,7 @@
 #include <sys/atomic.h>
 #endif
 
-#if !defined(_WIN32) || defined (__CYGWIN__)
+#if (!defined(_WIN32) && !defined(__OS2__)) || defined (__CYGWIN__)
 #include <sched.h>
 #endif
 
@@ -341,6 +341,9 @@
   {
 #if defined (_WIN32) && !defined (__CYGWIN__)
     Sleep(0);
+#elif defined (__OS2__)
+    unsigned long _System DosSleep (unsigned long ulInterval);
+    DosSleep(0);
 #else
     sched_yield();
 #endif
Only in gcc-4.4.5/libstdc++-v3: libmath
diff -ur gcc-4.4.5-o/libstdc++-v3/libsupc++/typeinfo gcc-4.4.5/libstdc++-v3/libsupc++/typeinfo
--- gcc-4.4.5-o/libstdc++-v3/libsupc++/typeinfo	2009-04-10 08:53:06.000000000 +0930
+++ gcc-4.4.5/libstdc++-v3/libsupc++/typeinfo	2010-10-03 18:54:56.000000000 +1030
@@ -59,7 +59,7 @@
 // indicate whether or not pointer comparison can be used.
 
 #ifndef __GXX_MERGED_TYPEINFO_NAMES
-  #if !__GXX_WEAK__
+  #if !__GXX_WEAK__ || (defined(__OS2__) && defined(__EMX__)) /* bird */
     // If weak symbols are not supported, typeinfo names are not merged.
     #define __GXX_MERGED_TYPEINFO_NAMES 0
   #else
@@ -70,7 +70,7 @@
 
 // By default follow the same rules as for __GXX_MERGED_TYPEINFO_NAMES.
 #ifndef __GXX_TYPEINFO_EQUALITY_INLINE
-  #if !__GXX_WEAK__
+  #if !__GXX_WEAK__ || (defined(__OS2__) && defined(__EMX__)) /* bird */
     #define __GXX_TYPEINFO_EQUALITY_INLINE 0
   #else
     #define __GXX_TYPEINFO_EQUALITY_INLINE 1
Only in gcc-4.4.5/libstdc++-v3/testsuite/18_support/uncaught_exception: 14026.exe
Only in gcc-4.4.5/libstdc++-v3/testsuite/23_containers/list: operators
Only in gcc-4.4.5/libstdc++-v3/testsuite: thread
Only in gcc-4.4.5/libstdc++-v3/testsuite/util/native_type: assoc
Only in gcc-4.4.5/libstdc++-v3/testsuite/util/native_type: priority_queue
Only in gcc-4.4.5/libstdc++-v3/testsuite/util/regression: assoc
Only in gcc-4.4.5/libstdc++-v3/testsuite/util/regression: priority_queue
Only in gcc-4.4.5/libstdc++-v3/testsuite/util/regression/rand/assoc: detail
Only in gcc-4.4.5/libstdc++-v3/testsuite/util/regression/rand: io
Only in gcc-4.4.5/libstdc++-v3/testsuite/util/regression/rand/priority_queue: detail
Only in gcc-4.4.5/libstdc++-v3/testsuite/util: rng
Only in gcc-4.4.5: libtool.gcc
Only in gcc-4.4.5: libtool.ssp
Only in gcc-4.4.5: Makefile
diff -ur gcc-4.4.5-o/Makefile.in gcc-4.4.5/Makefile.in
--- gcc-4.4.5-o/Makefile.in	2009-04-25 13:40:28.000000000 +0930
+++ gcc-4.4.5/Makefile.in	2010-10-03 18:54:58.000000000 +1030
@@ -418,7 +418,7 @@
 
 LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
 LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
-LDFLAGS_FOR_TARGET = 
+LDFLAGS_FOR_TARGET = @LDFLAGS_FOR_BUILD@
 
 # ------------------------------------
 # Miscellaneous targets and flag lists
Only in gcc-4.4.5: serdep.tmp
diff -ur gcc-4.4.5-o/symlink-tree gcc-4.4.5/symlink-tree
--- gcc-4.4.5-o/symlink-tree	2005-07-14 10:38:12.000000000 +0930
+++ gcc-4.4.5/symlink-tree	2010-10-03 18:54:58.000000000 +1030
@@ -71,7 +71,8 @@
   else
     echo "$f		..linked"
     rm -f $f
-    ln -s ${srcdir}/$f .
+#    ln -s ${srcdir}/$f .
+    cp -p ${srcdir}/$f .
   fi
 done
 
Only in gcc-4.4.5: t.diff
gcc-4.4.5.diff (72,213 bytes)   
gcc-4.5.2.diff (79,419 bytes)   
Only in gcc-4.5.2: build.log
Only in gcc-4.5.2: conf.cmd
Only in gcc-4.5.2/config: mh-emx
Only in gcc-4.5.2: config.log
Only in gcc-4.5.2: config.status
diff -ur gcc-4.5.2-o/configure gcc-4.5.2/configure
--- gcc-4.5.2-o/configure	2010-10-06 20:59:54.000000000 +1030
+++ gcc-4.5.2/configure	2010-12-20 08:04:30.000000000 +1030
@@ -3215,7 +3215,7 @@
 	;;
     *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11*)
 	;;
-    *-*-darwin* | *-*-aix*)
+    *-*-darwin* | *-*-aix* | i*86-pc-*emx)
 	;;
     *)
 	noconfigdirs="$noconfigdirs target-libgomp"
diff -ur gcc-4.5.2-o/configure.ac gcc-4.5.2/configure.ac
--- gcc-4.5.2-o/configure.ac	2010-10-06 20:59:54.000000000 +1030
+++ gcc-4.5.2/configure.ac	2010-12-20 08:04:30.000000000 +1030
@@ -452,7 +452,7 @@
 	;;
     *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11*)
 	;;
-    *-*-darwin* | *-*-aix*)
+    *-*-darwin* | *-*-aix*  | i*86-pc-*emx)
 	;;
     *)
 	noconfigdirs="$noconfigdirs target-libgomp"
@@ -1094,6 +1094,9 @@
   i[[3456789]]86-*-msdosdjgpp*)
     host_makefile_frag="config/mh-djgpp"
     ;;
+  i[3456]86-*-os2*)
+    host_makefile_frag="config/mh-emx"
+    ;;
   *-cygwin*)
     ACX_CHECK_CYGWIN_CAT_WORKS
     host_makefile_frag="config/mh-cygwin"
Only in gcc-4.5.2: configure.lineno
diff -ur gcc-4.5.2-o/fixincludes/fixincl.c gcc-4.5.2/fixincludes/fixincl.c
--- gcc-4.5.2-o/fixincludes/fixincl.c	2009-04-10 00:30:18.000000000 +0930
+++ gcc-4.5.2/fixincludes/fixincl.c	2010-12-20 08:04:30.000000000 +1030
@@ -29,7 +29,7 @@
 #include <sys/wait.h>
 #endif
 
-#if defined( HAVE_MMAP_FILE )
+#if defined( HAVE_MMAP_FILE ) && !defined(__OS2__)
 #include <sys/mman.h>
 #define  BAD_ADDR ((void*)-1)
 #endif
@@ -336,7 +336,7 @@
       return (char*)NULL;
     }
 
-#ifdef HAVE_MMAP_FILE
+#if defined( HAVE_MMAP_FILE ) && !defined(__OS2__)
   curr_data_mapped = BOOL_TRUE;
 
   /*  IF the file size is a multiple of the page size,
diff -ur gcc-4.5.2-o/fixincludes/fixlib.h gcc-4.5.2/fixincludes/fixlib.h
--- gcc-4.5.2-o/fixincludes/fixlib.h	2009-04-10 00:30:18.000000000 +0930
+++ gcc-4.5.2/fixincludes/fixlib.h	2010-12-20 08:04:30.000000000 +1030
@@ -211,7 +211,7 @@
 
 extern int gnu_type_map_ct;
 
-#ifdef HAVE_MMAP_FILE
+#if defined( HAVE_MMAP_FILE ) && !defined(__OS2__)
 #define UNLOAD_DATA() do { if (curr_data_mapped) { \
   munmap ((void*)pz_curr_data, data_map_size); close (data_map_fd); } \
   else free ((void*)pz_curr_data); } while(0)
Only in gcc-4.5.2/fixincludes/tests/base: arpa
Only in gcc-4.5.2/fixincludes/tests/base: fs
Only in gcc-4.5.2/fixincludes/tests/base: machine
diff -ur gcc-4.5.2-o/gcc/c-decl.c gcc-4.5.2/gcc/c-decl.c
--- gcc-4.5.2-o/gcc/c-decl.c	2010-11-12 07:10:32.000000000 +1030
+++ gcc-4.5.2/gcc/c-decl.c	2010-12-20 08:04:30.000000000 +1030
@@ -1877,6 +1877,7 @@
 	     built in, newdecl silently overrides olddecl.  The latter
 	     occur only in Objective C; see also above.  (FIXME: Make
 	     Objective C use normal builtins.)  */
+
 	  if (!DECL_IS_BUILTIN (olddecl)
 	      && !DECL_EXTERN_INLINE (olddecl))
 	    {
diff -ur gcc-4.5.2-o/gcc/calls.c gcc-4.5.2/gcc/calls.c
--- gcc-4.5.2-o/gcc/calls.c	2010-09-25 00:31:52.000000000 +0930
+++ gcc-4.5.2/gcc/calls.c	2010-12-20 08:04:30.000000000 +1030
@@ -3943,7 +3943,9 @@
   va_list p;
 
   va_start (p, nargs);
+
   emit_library_call_value_1 (0, orgfun, NULL_RTX, fn_type, outmode, nargs, p);
+
   va_end (p);
 }
 
Only in gcc-4.5.2/gcc/config/i386: emx-ctordtor.c
Only in gcc-4.5.2/gcc/config/i386: emx-cxx.c
Only in gcc-4.5.2/gcc/config/i386: emx-dllinit.c
Only in gcc-4.5.2/gcc/config/i386: emx-eh.c
Only in gcc-4.5.2/gcc/config/i386: emx-libgcc_so_d.def
Only in gcc-4.5.2/gcc/config/i386: emx-libgcc1.asm
Only in gcc-4.5.2/gcc/config/i386: emx-stubs.c
Only in gcc-4.5.2/gcc/config/i386: emx.c
Only in gcc-4.5.2/gcc/config/i386: emx.h
Only in gcc-4.5.2/gcc/config/i386: host-emx.c
diff -ur gcc-4.5.2-o/gcc/config/i386/i386-protos.h gcc-4.5.2/gcc/config/i386/i386-protos.h
--- gcc-4.5.2-o/gcc/config/i386/i386-protos.h	2010-07-22 16:12:02.000000000 +0930
+++ gcc-4.5.2/gcc/config/i386/i386-protos.h	2010-12-20 08:04:30.000000000 +1030
@@ -186,6 +186,8 @@
 extern void ix86_expand_truncdf_32 (rtx, rtx);
 
 #ifdef TREE_CODE
+extern int ix86_check_append_attr PARAMS ((tree, tree, bool *));
+
 extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree);
 extern rtx function_arg (CUMULATIVE_ARGS *, enum machine_mode, tree, int);
 extern void function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
@@ -203,6 +205,9 @@
 extern unsigned int ix86_minimum_alignment (tree, enum machine_mode,
 					    unsigned int);
 extern int ix86_constant_alignment (tree, int);
+#ifdef __EMX__
+extern tree ix86_handle_dll_attribute (tree *, tree, tree, int, bool *);
+#endif
 extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *);
 extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *);
 extern int x86_field_alignment (tree, int);
@@ -277,3 +282,16 @@
 #ifdef HAVE_ATTR_cpu
 extern enum attr_cpu ix86_schedule;
 #endif
+
+/* In emx.c  */
+extern bool i386_emx_binds_local_p (const_tree);
+extern void i386_emx_init_sections (void);
+extern void i386_emx_asm_out_destructor (rtx, int);
+extern tree i386_emx_mangle_decl_assembler_name (tree, tree);
+extern void i386_emx_maybe_record_exported_symbol (tree, const char *, int);
+extern bool i386_emx_valid_dllimport_attribute_p (const_tree);
+
+/* In emx-cxx.c  */
+extern void i386_emx_adjust_class_at_definition (tree);
+extern bool i386_emx_type_dllimport_p (tree);
+extern bool i386_emx_type_dllexport_p (tree);
diff -ur gcc-4.5.2-o/gcc/config/i386/i386.c gcc-4.5.2/gcc/config/i386/i386.c
--- gcc-4.5.2-o/gcc/config/i386/i386.c	2010-10-01 05:54:54.000000000 +0930
+++ gcc-4.5.2/gcc/config/i386/i386.c	2010-12-20 08:04:30.000000000 +1030
@@ -62,6 +62,10 @@
 #define CHECK_STACK_LIMIT (-1)
 #endif
 
+#ifdef EMX
+extern bool i386_emx_binds_local_p (const_tree);
+#endif
+
 /* Return index of given mode in mult and division cost tables.  */
 #define MODE_INDEX(mode)					\
   ((mode) == QImode ? 0						\
@@ -4287,7 +4291,6 @@
   if (level > 1)
     flag_schedule_insns = 0;
 #endif
-
   if (TARGET_MACHO)
     /* The Darwin libraries never set errno, so we might as well
        avoid calling them when that's the only reason we would.  */
@@ -4537,6 +4540,7 @@
 
   return 1;
 }
+
 
 /* Return the regparm value for a function with the indicated TYPE and DECL.
    DECL may be NULL when calling function indirectly
@@ -4695,7 +4699,11 @@
   rtd = TARGET_RTD && (!fundecl || TREE_CODE (fundecl) != IDENTIFIER_NODE);
 
   /* Cdecl functions override -mrtd, and never pop the stack.  */
-  if (! lookup_attribute ("cdecl", TYPE_ATTRIBUTES (funtype)))
+  if (! lookup_attribute ("cdecl", TYPE_ATTRIBUTES (funtype))
+#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
+   && ! lookup_attribute ("system", TYPE_ATTRIBUTES (funtype))
+#endif
+     ) 
     {
       /* Stdcall and fastcall functions will pop the stack if not
          variable args.  */
@@ -4943,6 +4951,11 @@
 		      ? (!prototype_p (fntype) || stdarg_p (fntype))
 		      : !libname);
 
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTESx
+  /* _Optlink calling convention says all args until the ellipsis
+             are passed in registers, and all varargs on the stack. */
+  if (!cum->optlink)
+#endif
   if (!TARGET_64BIT)
     {
       /* If there are variable arguments, then we won't pass anything
@@ -4968,8 +4981,26 @@
 	      cum->fastcall = 1;
 	    }
 	  else
-	    cum->nregs = ix86_function_regparm (fntype, fndecl);
+            {
+		cum->nregs = ix86_function_regparm (fntype, fndecl);
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTESx
+		if (lookup_attribute ("optlink", TYPE_ATTRIBUTES (fntype)))
+	          {
+			cum->nregs = 3; cum->optlink = 1;
+		  }
+#endif
+	    }
 	}
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTESx
+      /* Limit number of registers to pass arguments as in _Optlink specification */
+      if (cum->optlink)
+        {
+          if (cum->nregs > 3)
+            cum->nregs = 3;
+          if (cum->fpu_nregs > 4)
+            cum->fpu_nregs = 4;
+        }
+#endif
 
       /* Set up the number of SSE registers used for passing SFmode
 	 and DFmode arguments.  Warn for mismatching ABI.  */
@@ -5766,6 +5797,61 @@
     case HImode:
     case QImode:
       cum->words += words;
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTESx
+          /* Optlink functions never pass aggregates in registers
+             (they are pushed on the stack, and the registers are
+             preserved for following parameters). */
+          if (cum->optlink)
+            {
+              /* If out of eyecatcher slots, do nothing */
+              if (!cum->ec_slots)
+                return;
+
+              if (INTEGRAL_TYPE_P (type)
+               || POINTER_TYPE_P (type))
+                {
+                  /* Integer types takes one slot in eyecatcher */
+                  cum->ec_slots--;
+                }
+              else if (FLOAT_MODE_P (mode))
+                {
+                  /* Fixed-point parameters are passed in FPU registers */
+                  if (cum->fpu_nregs)
+                    {
+                      cum->fpu_nregs--;
+                      cum->fpu_regno++;
+                      /* Args passed in FPU stack takes one eyecatcher slot */
+                      cum->ec_slots--;
+                    }
+                  else
+                    {
+                      /* FPU args passed on RT stack takes 1/2/4 slots */
+                      cum->ec_slots -= words;
+                    }
+
+                  /* The case with ec_slots <= 0 will be catched a little lates */
+                  if (cum->ec_slots > 0)
+                    return;
+                }
+              else
+                {
+                  /* This is nor a integer, address or float parameter.
+                     Pass it on the stack but count its size in eyecatcher. */
+                  cum->ec_slots -= words;
+                  if (cum->ec_slots > 0)
+                    return;
+                }
+
+              /* If we're out of eyecatcher slots, pass the arg on the stack */
+              if (cum->ec_slots <= 0)
+                {
+                  cum->ec_slots = 0;
+                  cum->nregs = 0;
+                  cum->fpu_nregs = 0;
+                  return;
+                }
+            }
+#endif
       cum->nregs -= words;
       cum->regno += words;
 
@@ -5923,11 +6009,37 @@
   if (mode == VOIDmode)
     return constm1_rtx;
 
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTESx
+  rtx ret = NULL_RTX;
+      /* For optlink calling convention, don't pass anything other than
+         integral types and floats through registers. */
+      if (!cum->optlink
+          || INTEGRAL_TYPE_P (type)
+          || POINTER_TYPE_P (type)
+          || (TREE_CODE (type) == REAL_TYPE))
+#endif
+
   switch (mode)
     {
     default:
       break;
 
+#if defined TARGET_OPTLINK_DECL_ATTRIBUTESx
+        case XFmode:
+        case TFmode:
+        if (cum->fpu_nregs && cum->optlink && cum->ec_slots)
+          {
+            /* Pass first four floating-point args in FPU registers */
+            ret = gen_rtx_PARALLEL (mode, rtvec_alloc (2));
+            XVECEXP (ret, 0, 0) = gen_rtx_EXPR_LIST ( VOIDmode,
+                                           NULL_RTX, const0_rtx);
+            XVECEXP (ret, 0, 1) = gen_rtx_EXPR_LIST (VOIDmode,
+                                           gen_rtx_REG ( mode, FIRST_FLOAT_REG + cum->fpu_regno),
+                                           const0_rtx);
+          }
+        break;
+#endif
+
     case BLKmode:
       if (bytes < 0)
 	break;
@@ -5937,6 +6049,28 @@
     case HImode:
     case QImode:
       if (words <= cum->nregs)
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTESx
+          {
+            if (cum->optlink)
+              {
+                if (cum->ec_slots)
+                  {
+                    /* Optlink specs says that the parameter is passed in a register
+                       and space on the stack is reserved for it as well (which is not
+                       filled). Currently GCC will pass the parameter *both* in register
+                       and stack; this is suboptimal but is compatible. */
+                    ret = gen_rtx_PARALLEL ( mode, rtvec_alloc (2));
+                    XVECEXP (ret, 0, 0) = gen_rtx_EXPR_LIST ( VOIDmode,
+                                                   NULL_RTX, const0_rtx);
+                    XVECEXP (ret, 0, 1) = gen_rtx_EXPR_LIST ( VOIDmode,
+                                                   gen_rtx_REG ( mode, cum->regno),
+                                                   const0_rtx);
+                  }
+              }
+            else
+              ret = gen_rtx_REG (mode, cum->regno);
+          }
+#else
 	{
 	  int regno = cum->regno;
 
@@ -5956,6 +6090,7 @@
 	    }
 	  return gen_rtx_REG (mode, regno);
 	}
+#endif
       break;
 
     case DFmode:
@@ -6024,6 +6159,9 @@
 				        cum->mmx_regno + FIRST_MMX_REG);
 	}
       break;
+#ifdef __OS2__x /* ????? */
+      }
+#endif
     }
 
   return NULL_RTX;
@@ -6193,6 +6331,9 @@
        || mode == TFmode
        || mode == TCmode)
       && (!TYPE_USER_ALIGN (type) || TYPE_ALIGN (type) > 128))
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTESz
+          && !cum->optlink
+#endif
     return true;
   if (TYPE_ALIGN (type) < 128)
     return false;
@@ -9661,12 +9802,13 @@
       if (SYMBOL_REF_TLS_MODEL (x))
 	return false;
 
+#ifndef __EMX__ /* 2009-01-15 */
       /* DLLIMPORT symbols are never valid.  */
       if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
-	  && SYMBOL_REF_DLLIMPORT_P (x))
+	  && SYMBOL_REF_DLLIMPORT_P (x)) 
 	return false;
+#endif
       break;
-
     case CONST_DOUBLE:
       if (GET_MODE (x) == TImode
 	  && x != CONST0_RTX (TImode)
@@ -10548,7 +10690,11 @@
   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
   name = targetm.strip_name_encoding (name);
   prefix = name[0] == FASTCALL_PREFIX || user_label_prefix[0] == 0
+#ifndef __OS2__
     ? "*__imp_" : "*__imp__";
+#else
+    ? "" : "";
+#endif
   namelen = strlen (name);
   prefixlen = strlen (prefix);
   imp_name = (char *) alloca (namelen + prefixlen + 1);
@@ -10562,7 +10708,6 @@
 
   rtl = gen_const_mem (Pmode, rtl);
   set_mem_alias_set (rtl, ix86_GOT_alias_set ());
-
   SET_DECL_RTL (to, rtl);
   SET_DECL_ASSEMBLER_NAME (to, get_identifier (name));
 
@@ -10625,7 +10770,8 @@
       return gen_rtx_PLUS (Pmode, t, XEXP (XEXP (x, 0), 1));
     }
 
-  if (TARGET_DLLIMPORT_DECL_ATTRIBUTES)
+#ifndef __EMX__ /* 2009-01-15 */
+  if (TARGET_DLLIMPORT_DECL_ATTRIBUTES) 
     {
       if (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_DLLIMPORT_P (x))
 	return legitimize_dllimport_symbol (x, true);
@@ -10638,7 +10784,7 @@
 	  return gen_rtx_PLUS (Pmode, t, XEXP (XEXP (x, 0), 1));
 	}
     }
-
+#endif
   if (flag_pic && SYMBOLIC_CONST (x))
     return legitimize_pic_address (x, 0);
 
@@ -13007,9 +13153,11 @@
 	  if (op1 == op0)
 	    return;
 	}
+#ifndef __EMX__ /* 2009-01-16 */
       else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
-	       && SYMBOL_REF_DLLIMPORT_P (op1))
+	       && SYMBOL_REF_DLLIMPORT_P (op1)) 
 	op1 = legitimize_dllimport_symbol (op1, false);
+#endif
     }
   else if (GET_CODE (op1) == CONST
 	   && GET_CODE (XEXP (op1, 0)) == PLUS
@@ -13022,10 +13170,11 @@
       model = SYMBOL_REF_TLS_MODEL (symbol);
       if (model)
 	tmp = legitimize_tls_address (symbol, model, true);
+#ifndef __EMX__ /* 2009-01-16 */
       else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
-	       && SYMBOL_REF_DLLIMPORT_P (symbol))
+	       && SYMBOL_REF_DLLIMPORT_P (symbol)) 
 	tmp = legitimize_dllimport_symbol (symbol, true);
-
+#endif
       if (tmp)
 	{
 	  tmp = force_operand (tmp, NULL);
@@ -28978,10 +29127,22 @@
 }
 
 
-/* Table of valid machine attributes.  */
+/* Table of valid machine attributes.  
+   If you change it, you must change the array at the beginning of 
+   ix86_comp_type_attributes() as well! */
 static const struct attribute_spec ix86_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
+#ifdef EMX /** @todo: ugly stuff, cleanup later. */
+  /* Stdcall attribute says callee is responsible for popping arguments
+     if they are not variable.  */
+  { "stdcall",   0, 0, false, false, false, ix86_handle_system_attribute },
+  /* Fastcall attribute says callee is responsible for popping arguments
+     if they are not variable.  */
+  { "fastcall",  0, 0, false, false,  false,  ix86_handle_system_attribute },
+  /* Cdecl attribute says the callee is a normal C declaration */
+  { "cdecl",     0, 0, false, false, false, ix86_handle_system_attribute },
+#else
   /* Stdcall attribute says callee is responsible for popping arguments
      if they are not variable.  */
   { "stdcall",   0, 0, false, true,  true,  ix86_handle_cconv_attribute },
@@ -28990,6 +29151,7 @@
   { "fastcall",  0, 0, false, true,  true,  ix86_handle_cconv_attribute },
   /* Cdecl attribute says the callee is a normal C declaration */
   { "cdecl",     0, 0, false, true,  true,  ix86_handle_cconv_attribute },
+#endif
   /* Regparm attribute specifies how many integer arguments are to be
      passed in registers.  */
   { "regparm",   1, 1, false, true,  true,  ix86_handle_cconv_attribute },
@@ -28999,6 +29161,7 @@
   /* force_align_arg_pointer says this function realigns the stack at entry.  */
   { (const char *)&ix86_force_align_arg_pointer_string, 0, 0,
     false, true,  true, ix86_handle_cconv_attribute },
+
 #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
   { "dllimport", 0, 0, false, false, false, handle_dll_attribute },
   { "dllexport", 0, 0, false, false, false, handle_dll_attribute },
@@ -29014,9 +29177,107 @@
   { "sysv_abi", 0, 0, false, true, true, ix86_handle_abi_attribute },
   { "ms_hook_prologue", 0, 0, true, false, false, ix86_handle_fndecl_attribute },
   /* End element.  */
+#ifdef EMX /** @todo: ugly stuff, cleanup later. */
+#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
+  /* System says the function is extern "C" and is not underscored. */
+  { "system",    0, 0, false, false, false, ix86_handle_system_attribute },
+#endif
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
+  /* Optlink is like regparm with a few differences */
+  { "optlink",   0, 0, false, false, false, ix86_handle_optlink_attribute },
+#endif
+#else
+#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
+  /* System says the function is extern "C" and is not underscored. */
+  { "system",    0, 0, false, true,  true,  ix86_handle_system_attribute },
+#endif
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
+  /* Optlink is like regparm with a few differences */
+  { "optlink",   0, 0, false, true,  true,  ix86_handle_optlink_attribute },
+#endif
+#endif
   { NULL,        0, 0, false, false, false, NULL }
 };
 
+/* The attribute denotes a calling convention */
+#define IX86_ATTR_TYPE_CALLCONV  0x00010000
+/* Calling convention mask: attributes with bits
+   in these positions equal are nealy compatible */
+#define IX86_ATTR_MASK_CALLCONV  0x0000000f
+/* Ordinal number for attributes with equal calling convention bits */
+#define IX86_ATTR_MASK_ORDINAL   0x000000f0
+
+/* This array contains some flags containing additional information
+   about attributes. Keep it in sync with ix86_attribute_table. */
+static unsigned ix86_attribute_codes [] =
+{
+  IX86_ATTR_TYPE_CALLCONV | 0x01, /* stdcall */
+  IX86_ATTR_TYPE_CALLCONV | 0x05, /* fastcall */
+  IX86_ATTR_TYPE_CALLCONV | 0x02, /* cdecl */
+  IX86_ATTR_TYPE_CALLCONV | 0x03, /* regparm */
+  IX86_ATTR_TYPE_CALLCONV | 0x06, /* sseregparm */
+#ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
+  0, /* dllimport */
+  0, /* dllexport */
+  0, /* shared */
+#endif
+  IX86_ATTR_TYPE_CALLCONV | 0x07, /* ms_struct */
+  IX86_ATTR_TYPE_CALLCONV | 0x08, /* gcc_struct */
+#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
+  IX86_ATTR_TYPE_CALLCONV | 0x12, /* system is compatible with cdecl */
+#endif
+#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
+  IX86_ATTR_TYPE_CALLCONV | 0x04, /* optlink */
+#endif
+};
+
+
+/* Check if we don't have incompatible calling conversion attributes */
+int
+ix86_check_append_attr (type, name, no_add_attrs)
+    tree type, name;
+     bool *no_add_attrs;
+{
+  /* ??? use ix86_comp_type_attributes maybe ??? */
+  unsigned i;
+  const char *exclname;
+
+  exclname = IDENTIFIER_POINTER (name);
+  if (exclname [0] == '_')
+    {
+      /* Remove leading and trailing underscores */
+      const char *x1, *x2;
+      char *newname;
+      x1 = exclname + 1;
+      while (*x1 == '_')
+        x1++;
+      x2 = strchr (x1, 0);
+      while (x2 [-1] == '_' && x2 > x1)
+        x2--;
+      newname = alloca (x2 - x1 + 1);
+      memcpy (newname, x1, x2 - x1);
+      newname [x2 - x1] = 0;
+      exclname = newname;
+    }
+
+  for (i = 0; ix86_attribute_table [i].name; i++)
+    if ((ix86_attribute_codes [i] & IX86_ATTR_TYPE_CALLCONV)
+     && lookup_attribute (ix86_attribute_table [i].name, TYPE_ATTRIBUTES (type)))
+      {
+        /* Warn if we have another calling convention attribute and it is
+           different from the currently processed attribute. If there is
+           already an attribute with the same name attached, silently ignore
+           currently processed attribute. */
+        if (strcmp (exclname, ix86_attribute_table [i].name))
+          warning ("`%s' attribute is incompatible with earlier defined `%s' attribute",
+                   IDENTIFIER_POINTER (name), ix86_attribute_table [i].name);
+        *no_add_attrs = true;
+        return -1;
+      }
+
+  return 0;
+}
+
 /* Implement targetm.vectorize.builtin_vectorization_cost.  */
 static int
 ix86_builtin_vectorization_cost (bool runtime_test)
@@ -30437,8 +30698,13 @@
 #define TARGET_BINDS_LOCAL_P darwin_binds_local_p
 #endif
 #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
+#ifndef __EMX__
 #undef TARGET_BINDS_LOCAL_P
 #define TARGET_BINDS_LOCAL_P i386_pe_binds_local_p
+#else
+#undef TARGET_BINDS_LOCAL_P
+#define TARGET_BINDS_LOCAL_P i386_emx_binds_local_p
+#endif /* __EMX__ */
 #endif
 
 #undef TARGET_ASM_OUTPUT_MI_THUNK
Only in gcc-4.5.2/gcc/config/i386: i386.c.orig
diff -ur gcc-4.5.2-o/gcc/config/i386/i386.h gcc-4.5.2/gcc/config/i386/i386.h
--- gcc-4.5.2-o/gcc/config/i386/i386.h	2010-04-28 05:44:18.000000000 +0930
+++ gcc-4.5.2/gcc/config/i386/i386.h	2010-12-20 08:04:32.000000000 +1030
@@ -1595,6 +1595,12 @@
 				   be passed in SSE registers.  Otherwise 0.  */
   enum calling_abi call_abi;	/* Set to SYSV_ABI for sysv abi. Otherwise
  				   MS_ABI for ms abi.  */
+#ifdef EMX
+  int fpu_regno;		/* next available FPU register number */
+  int fpu_nregs;		/* # registers available for passing */
+  int ec_slots;			/* # eyecatcher slots left (see optlink specs) */
+  int optlink;			/* nonzero if optlink (vs. regparm) */
+#endif /* EMX */
 } CUMULATIVE_ARGS;
 
 /* Initialize a variable CUM of type CUMULATIVE_ARGS
@@ -2348,12 +2354,13 @@
 
 /* Machine specific CFA tracking during prologue/epilogue generation.  */
 
-#ifndef USED_FOR_TARGET
+#if !defined(USED_FOR_TARGET) || defined(__OS2__)
 struct GTY(()) machine_cfa_state
 {
   rtx reg;
   HOST_WIDE_INT offset;
 };
+#endif
 
 struct GTY(()) machine_function {
   struct stack_local_entry *stack_locals;
@@ -2398,7 +2405,6 @@
      stack below the return address.  */
   BOOL_BITFIELD static_chain_on_stack : 1;
 };
-#endif
 
 #define ix86_stack_locals (cfun->machine->stack_locals)
 #define ix86_varargs_gpr_size (cfun->machine->varargs_gpr_size)
diff -ur gcc-4.5.2-o/gcc/config/i386/i386.md gcc-4.5.2/gcc/config/i386/i386.md
--- gcc-4.5.2-o/gcc/config/i386/i386.md	2010-10-22 15:26:40.000000000 +1030
+++ gcc-4.5.2/gcc/config/i386/i386.md	2010-12-20 08:04:32.000000000 +1030
@@ -18893,7 +18893,7 @@
    (set (reg:SI SP_REG) (minus:SI (reg:SI SP_REG) (match_dup 1)))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_64BIT && TARGET_STACK_PROBE"
-  "call\t___chkstk"
+  "call\t__alloca"
   [(set_attr "type" "multi")
    (set_attr "length" "5")])
 
@@ -18906,7 +18906,7 @@
    (clobber (reg:DI R11_REG))
    (clobber (reg:CC FLAGS_REG))]
   "TARGET_64BIT && TARGET_STACK_PROBE"
-  "call\t___chkstk"
+  "call\t__alloca"
   [(set_attr "type" "multi")
    (set_attr "length" "5")])
 
Only in gcc-4.5.2/gcc/config/i386: i386.md.orig
diff -ur gcc-4.5.2-o/gcc/config/i386/predicates.md gcc-4.5.2/gcc/config/i386/predicates.md
--- gcc-4.5.2-o/gcc/config/i386/predicates.md	2010-06-22 00:22:06.000000000 +0930
+++ gcc-4.5.2/gcc/config/i386/predicates.md	2010-12-20 08:04:32.000000000 +1030
@@ -515,8 +515,10 @@
 {
   if (ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
     return false;
+#ifndef __EMX__ /* mangles dllimport symbols in a bad way on OS/2 */
   if (TARGET_DLLIMPORT_DECL_ATTRIBUTES && SYMBOL_REF_DLLIMPORT_P (op))
     return false;
+#endif
   return true;
 })
 
Only in gcc-4.5.2/gcc/config/i386: t-emx
Only in gcc-4.5.2/gcc/config/i386: winnt-445-452.diff
Only in gcc-4.5.2/gcc/config/i386: winnt-cxx-445-452.diff
Only in gcc-4.5.2/gcc/config/i386: x-emx
Only in gcc-4.5.2/gcc/config/i386: xm-emx.h
Only in gcc-4.5.2/gcc/config: mt
diff -ur gcc-4.5.2-o/gcc/config.build gcc-4.5.2/gcc/config.build
--- gcc-4.5.2-o/gcc/config.build	2009-08-09 16:35:10.000000000 +0930
+++ gcc-4.5.2/gcc/config.build	2010-12-20 08:04:32.000000000 +1030
@@ -133,5 +133,9 @@
     # All other System V variants.
     build_install_headers_dir=install-headers-cpio
     ;;
+i*86-pc-*emx)		# i?86 running OS/2
+    build_xm_file=i386/xm-emx.h
+    exeext=.exe
+    build_exeext=.exe
 esac
 
diff -ur gcc-4.5.2-o/gcc/config.gcc gcc-4.5.2/gcc/config.gcc
--- gcc-4.5.2-o/gcc/config.gcc	2010-10-09 20:05:52.000000000 +1030
+++ gcc-4.5.2/gcc/config.gcc	2010-12-20 08:04:32.000000000 +1030
@@ -1441,6 +1441,25 @@
 			;;
 	esac
 	;;
+i*86-pc-*emx)		# i?86 running OS/2
+	xm_file=i386/xm-emx.h
+	tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h i386/emx.h"
+	extra_objs="emx.o emx-stubs.o"
+	cxx_target_objs="${cxx_target_objs} emx-cxx.o"
+	xm_defines="USG BSTRING NO_SYS_SIGLIST"
+	exeext=.exe
+	tmake_file=i386/t-emx
+    # r=bird: why do we do this??
+	target_alias=${host}
+    # r=bird: and this??
+	CFLAGS="-Zstack 1024 -Zcrtdll"
+	if test x$enable_threads = xyes; then
+		thread_file=os2
+	fi
+	gas=yes
+	gnu_ld=yes
+	float_format=none
+	;;
 i[34567]86-*-interix3*)
 	tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/i386-interix.h i386/i386-interix3.h interix.h interix3.h"
 	tmake_file="${tmake_file} i386/t-interix"
diff -ur gcc-4.5.2-o/gcc/config.host gcc-4.5.2/gcc/config.host
--- gcc-4.5.2-o/gcc/config.host	2009-10-08 15:39:54.000000000 +1030
+++ gcc-4.5.2/gcc/config.host	2010-12-20 08:04:32.000000000 +1030
@@ -201,6 +201,11 @@
         ;;
     esac
     ;;
+  i*86-pc-*emx)		# i?86 running OS/2
+    host_exeext=.exe
+#    out_host_hook_obj=host-emx.o
+#    host_xmake_file="${host_xmake_file} i386/x-emx"
+    ;;
   i[34567]86-*-pe | i[34567]86-*-cygwin*)
     host_xm_file=i386/xm-cygwin.h
     out_host_hook_obj=host-cygwin.o
diff -ur gcc-4.5.2-o/gcc/cp/class.c gcc-4.5.2/gcc/cp/class.c
--- gcc-4.5.2-o/gcc/cp/class.c	2010-07-10 05:20:24.000000000 +0930
+++ gcc-4.5.2/gcc/cp/class.c	2010-12-20 08:04:32.000000000 +1030
@@ -2433,6 +2433,18 @@
       if (!DECL_VINDEX (decl))
 	DECL_VINDEX (decl) = error_mark_node;
       IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)) = 1;
+/* Added 2009-01-11 */
+      if (DECL_DLLIMPORT_P (decl))
+	{
+	  /* When we handled the dllimport attribute we may not have known
+	     that this function is virtual   We can't use dllimport 
+	     semantics for a virtual method because we need to initialize
+	     the vtable entry with a constant address.  */
+	  DECL_DLLIMPORT_P (decl) = 0;
+	  DECL_ATTRIBUTES (decl)
+	    = remove_attribute ("dllimport", DECL_ATTRIBUTES (decl));
+	}
+
     }
 }
 
diff -ur gcc-4.5.2-o/gcc/cp/cp-tree.h gcc-4.5.2/gcc/cp/cp-tree.h
--- gcc-4.5.2-o/gcc/cp/cp-tree.h	2010-04-28 08:33:06.000000000 +0930
+++ gcc-4.5.2/gcc/cp/cp-tree.h	2010-12-20 08:04:32.000000000 +1030
@@ -4799,7 +4799,11 @@
 extern void expand_end_catch_block		(void);
 extern tree build_exc_ptr			(void);
 extern tree build_throw				(tree);
+#ifndef __OS2__
 extern int nothrow_libfn_p			(const_tree);
+#else
+extern int nothrow_libfn_p			(tree);
+#endif
 extern void check_handlers			(tree);
 extern void choose_personality_routine		(enum languages);
 extern tree eh_type_info			(tree);
diff -ur gcc-4.5.2-o/gcc/cp/decl.c gcc-4.5.2/gcc/cp/decl.c
--- gcc-4.5.2-o/gcc/cp/decl.c	2010-12-08 01:50:24.000000000 +1030
+++ gcc-4.5.2/gcc/cp/decl.c	2010-12-20 08:04:32.000000000 +1030
@@ -10935,7 +10935,22 @@
 	    }
 	}
     }
-
+#if 0 /* Broken in 3.4.6 - is it still necessary??? */
+#if 1 /* bird: HACK ALERT! HACK ALERT! */
+  /* Don't replace attributes with nothing. See the nsSupportWeakReference / friend problem.
+     Limit any negative sideeffects this hack may have by only caring for a select number of attributes. */
+  if (   TYPE_ATTRIBUTES (t)
+      && (   lookup_attribute ("dllexport", TYPE_ATTRIBUTES (t))
+          || lookup_attribute ("dllimport", TYPE_ATTRIBUTES (t))
+          || lookup_attribute ("system", TYPE_ATTRIBUTES (t))
+          || lookup_attribute ("cdecl", TYPE_ATTRIBUTES (t))
+          || lookup_attribute ("optlink", TYPE_ATTRIBUTES (t))
+          || lookup_attribute ("stdcall", TYPE_ATTRIBUTES (t))))
+    TYPE_ATTRIBUTES (t) = merge_attributes(TYPE_ATTRIBUTES (t), attributes);
+  else
+    TYPE_ATTRIBUTES (t) = attributes;
+#endif
+#endif
   POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
 }
 
Only in gcc-4.5.2/gcc/cp: decl.c.orig
diff -ur gcc-4.5.2-o/gcc/cp/dump.c gcc-4.5.2/gcc/cp/dump.c
--- gcc-4.5.2-o/gcc/cp/dump.c	2008-03-22 05:26:50.000000000 +1030
+++ gcc-4.5.2/gcc/cp/dump.c	2010-12-20 08:04:32.000000000 +1030
@@ -202,6 +202,31 @@
   }
 }
 
+#if 1 /* bird hacking */
+static void cp_dump_attributes (dump_info_p di, tree t)
+{
+  tree attr = NULL;
+  if (DECL_P (t))
+    attr = DECL_ATTRIBUTES (t);
+  else if (TYPE_P (t))
+    attr = TYPE_ATTRIBUTES (t);
+  else
+    return;
+  if (lookup_attribute ("optlink", attr))
+    dump_string (di, "optlink");
+  if (lookup_attribute ("stdcall", attr))
+    dump_string (di, "stdcall");
+  if (lookup_attribute ("cdecl", attr))
+    dump_string (di, "cdecl");
+  if (lookup_attribute ("system", attr))
+    dump_string (di, "system");
+  if (lookup_attribute ("dllexport", attr))
+    dump_string (di, "dllexport");
+  if (lookup_attribute ("dllimport", attr))
+    dump_string (di, "dllimport");
+}
+#endif /* bird hacking */
+
 bool
 cp_dump_tree (void* dump_info, tree t)
 {
@@ -217,6 +242,10 @@
 	dump_string_field (di, "lang", language_to_string (DECL_LANGUAGE (t)));
     }
 
+#if 1 /* bird hacking */
+  cp_dump_attributes (di, t);
+#endif 
+
   switch (code)
     {
     case IDENTIFIER_NODE:
diff -ur gcc-4.5.2-o/gcc/cp/error.c gcc-4.5.2/gcc/cp/error.c
--- gcc-4.5.2-o/gcc/cp/error.c	2010-06-23 06:16:50.000000000 +0930
+++ gcc-4.5.2/gcc/cp/error.c	2010-12-20 08:04:32.000000000 +1030
@@ -28,6 +28,7 @@
 #include "toplev.h"
 #include "flags.h"
 #include "diagnostic.h"
+#include "tm_p.h"
 #include "langhooks-def.h"
 #include "intl.h"
 #include "cxx-pretty-print.h"
@@ -667,12 +668,18 @@
 	 templates, e.g. std::is_function.  */
     case FUNCTION_TYPE:
       dump_type_prefix (TREE_TYPE (t), flags);
+#ifdef TARGET_PRINT_TYPE_ATTRS
+      TARGET_PRINT_TYPE_ATTRS (t, scratch_buffer);
+#endif
       break;
 
     case METHOD_TYPE:
       dump_type_prefix (TREE_TYPE (t), flags);
       pp_maybe_space (cxx_pp);
       pp_cxx_left_paren (cxx_pp);
+#ifdef TARGET_PRINT_TYPE_ATTRS
+      TARGET_PRINT_TYPE_ATTRS (t, scratch_buffer);
+#endif
       dump_aggr_type (TYPE_METHOD_BASETYPE (t), flags);
       pp_cxx_colon_colon (cxx_pp);
       break;
diff -ur gcc-4.5.2-o/gcc/cp/except.c gcc-4.5.2/gcc/cp/except.c
--- gcc-4.5.2-o/gcc/cp/except.c	2010-05-15 05:29:42.000000000 +0930
+++ gcc-4.5.2/gcc/cp/except.c	2010-12-20 08:04:32.000000000 +1030
@@ -926,8 +926,13 @@
 
 #include "cfns.h"
 
+#ifndef __OS2__
 int
 nothrow_libfn_p (const_tree fn)
+#else
+int
+nothrow_libfn_p (tree fn)
+#endif
 {
   tree id;
 
@@ -944,6 +949,13 @@
      unless the system headers are playing rename tricks, and if
      they are, we don't want to be confused by them.  */
   id = DECL_NAME (fn);
+#ifdef TARGET_CXX_SET_DECL_ASSEMBLER_NAME /* GCC-OS2 */
+  /* Actually the above is a bug. We can't mangle correctly unless we
+     have a complete decl. Until then, as a partial fix, reset the
+     mangled name to NULL so that next DECL_ASSEMBLER_NAME calls
+     mangler again, now with a complete decl. */
+  SET_DECL_ASSEMBLER_NAME(fn, NULL_TREE);
+#endif
   return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
 }
 
diff -ur gcc-4.5.2-o/gcc/cp/g++spec.c gcc-4.5.2/gcc/cp/g++spec.c
--- gcc-4.5.2-o/gcc/cp/g++spec.c	2009-12-02 19:09:10.000000000 +1030
+++ gcc-4.5.2/gcc/cp/g++spec.c	2010-12-20 08:04:32.000000000 +1030
@@ -49,6 +49,12 @@
 #ifndef LIBSTDCXX_STATIC
 #define LIBSTDCXX_STATIC NULL
 #endif
+#ifdef LIBSTDCXX_STATIC                                                             /* bird */
+#define LIBSTDCXX_STATIC "-lstdc++"                                                 /* bird */
+#endif                                                                              /* bird */
+#ifdef LIBSTDCXX_PROFILE_STATIC                                                     /* bird */
+#define LIBSTDCXX_PROFILE_STATIC "-lstdc++"                                         /* bird */
+#endif                                                                              /* bird */
 
 void
 lang_specific_driver (int *in_argc, const char *const **in_argv,
@@ -102,6 +108,9 @@
   /* True if we should add -shared-libgcc to the command-line.  */
   int shared_libgcc = 1;
 
+  /* True if we saw the '-static' option on the commandline. */                     /* bird */
+  int saw_static = 0;                                                               /* bird */
+                                                                                    /* bird */
   /* The total number of arguments with the new stuff.  */
   int argc;
 
diff -ur gcc-4.5.2-o/gcc/cp/mangle.c gcc-4.5.2/gcc/cp/mangle.c
--- gcc-4.5.2-o/gcc/cp/mangle.c	2010-03-24 08:59:52.000000000 +1030
+++ gcc-4.5.2/gcc/cp/mangle.c	2010-12-20 08:04:32.000000000 +1030
@@ -79,6 +79,11 @@
 # define MANGLE_TRACE_TREE(FN, NODE)
 #endif
 
+/* Provide a dummy target-specific name mangling hook */
+#ifndef TARGET_CXX_SET_DECL_ASSEMBLER_NAME
+#define TARGET_CXX_SET_DECL_ASSEMBLER_NAME(decl) 0
+#endif
+
 /* Nonzero if NODE is a class template-id.  We can't rely on
    CLASSTYPE_USE_TEMPLATE here because of tricky bugs in the parser
    that hard to distinguish A<T> from A, where A<T> is the type as
@@ -3053,10 +3058,13 @@
 void
 mangle_decl (const tree decl)
 {
-  tree id = mangle_decl_string (decl);
-  id = targetm.mangle_decl_assembler_name (decl, id);
-  SET_DECL_ASSEMBLER_NAME (decl, id);
-
+  /* GCC-OS2: mangling hack - fixes _System */
+  tree id;
+  if (!TARGET_CXX_SET_DECL_ASSEMBLER_NAME (decl)) {
+     id = mangle_decl_string (decl);
+     id = targetm.mangle_decl_assembler_name (decl, id);
+     SET_DECL_ASSEMBLER_NAME (decl, id);
+  }
   if (G.need_abi_warning)
     {
 #ifdef ASM_OUTPUT_DEF
diff -ur gcc-4.5.2-o/gcc/cppdefault.c gcc-4.5.2/gcc/cppdefault.c
--- gcc-4.5.2-o/gcc/cppdefault.c	2007-07-26 18:07:00.000000000 +0930
+++ gcc-4.5.2/gcc/cppdefault.c	2010-12-20 08:04:34.000000000 +1030
@@ -41,6 +41,8 @@
 # undef CROSS_INCLUDE_DIR
 #endif
 
+/* GCC-OS2: Added a few more configuration options so we can automagically
+   rewrite /gcc/ to whereever we're installed for all of the dirs we use. */
 const struct default_include cpp_include_defaults[]
 #ifdef INCLUDE_DEFAULTS
 = INCLUDE_DEFAULTS;
@@ -60,10 +62,10 @@
 #endif
 #ifdef LOCAL_INCLUDE_DIR
     /* /usr/local/include comes before the fixincluded header files.  */
-    { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
+    { LOCAL_INCLUDE_DIR, LOCAL_INCLUDE_COMPONENT, 0, 1, 1, 0 },
 #endif
 #ifdef PREFIX_INCLUDE_DIR
-    { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 },
+    { PREFIX_INCLUDE_DIR, PREFIX_INCLUDE_COMPONENT, 0, 1, 0, 0 },
 #endif
 #ifdef GCC_INCLUDE_DIR
     /* This is the dir for gcc's private headers.  */
@@ -91,7 +93,7 @@
 #endif
 #ifdef SYSTEM_INCLUDE_DIR
     /* Some systems have an extra dir of include files.  */
-    { SYSTEM_INCLUDE_DIR, 0, 0, 0, 1, 0 },
+    { SYSTEM_INCLUDE_DIR, SYSTEM_INCLUDE_COMPONENT, 0, 0, 1, 0 },
 #endif
 #ifdef STANDARD_INCLUDE_DIR
     /* /usr/include comes dead last.  */
diff -ur gcc-4.5.2-o/gcc/cppdefault.h gcc-4.5.2/gcc/cppdefault.h
--- gcc-4.5.2-o/gcc/cppdefault.h	2007-07-26 18:07:00.000000000 +0930
+++ gcc-4.5.2/gcc/cppdefault.h	2010-12-20 08:04:34.000000000 +1030
@@ -67,4 +67,26 @@
 /* Return true if the toolchain is relocated.  */
 bool cpp_relocated (void);
 
+/* GCC-OS2: Additional configuration options. */
+#ifndef STANDARD_INCLUDE_SYSROOT
+#define STANDARD_INCLUDE_SYSROOT 1
+#endif 
+       
+#ifndef SYSTEM_INCLUDE_COMPONENT
+#define SYSTEM_INCLUDE_COMPONENT 0
+#endif 
+
+#ifndef SYSTEM_INCLUDE_SYSROOT
+#define SYSTEM_INCLUDE_SYSROOT 1
+#endif 
+
+#ifndef LOCAL_INCLUDE_COMPONENT
+#define LOCAL_INCLUDE_COMPONENT 0
+#endif 
+
+#ifndef PREFIX_INCLUDE_COMPONENT
+#define PREFIX_INCLUDE_COMPONENT 0
+#endif 
+/* GCC-OS2: end */
+
 #endif /* ! GCC_CPPDEFAULT_H */
diff -ur gcc-4.5.2-o/gcc/dbxout.c gcc-4.5.2/gcc/dbxout.c
--- gcc-4.5.2-o/gcc/dbxout.c	2009-11-25 21:25:54.000000000 +1030
+++ gcc-4.5.2/gcc/dbxout.c	2010-12-20 08:04:34.000000000 +1030
@@ -1350,7 +1350,14 @@
 static void
 dbxout_global_decl (tree decl)
 {
-  if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
+  if (TREE_CODE (decl) == VAR_DECL 
+#ifdef EMXx /* bird: debug info for all referenced global vars. problem with 4.3.2*/
+      && (   !DECL_EXTERNAL (decl)
+          || (   use_gnu_debug_info_extensions
+              && TREE_SYMBOL_REFERENCED (DECL_NAME (decl))))
+#else
+      && ! DECL_EXTERNAL (decl))
+#endif
     {
       int saved_tree_used = TREE_USED (decl);
       TREE_USED (decl) = 1;
@@ -2179,6 +2186,13 @@
       /* We must use the same test here as we use in the DBX_NO_XREFS case
 	 above.  We simplify it a bit since an enum will never have a variable
 	 size.  */
+#ifdef EMX
+      /* bird: I believe this test is wrong. The test above checks if we
+         already used gnu extenstions and gathers that it's ok to continue
+         do non-standard stuff then.
+         Anyway, we can't cope with crossreferences to enums. */
+     if (!use_gnu_debug_info_extensions)
+#endif
       if ((TYPE_NAME (type) != 0
 	   && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
 		 && DECL_IGNORED_P (TYPE_NAME (type)))
@@ -2799,10 +2813,19 @@
 
     case RESULT_DECL:
     case VAR_DECL:
+#ifdef EMX
+      /* Don't mention a variable that is external and unreferenced..
+	 bird: Referenced variables must be mentioned for OMF support.  */
+      if (DECL_EXTERNAL (decl)
+          && (   !use_gnu_debug_info_extensions
+              || !TREE_SYMBOL_REFERENCED (DECL_NAME (decl))))
+        break;
+#else
       /* Don't mention a variable that is external.
 	 Let the file that defines it describe it.  */
       if (DECL_EXTERNAL (decl))
 	break;
+#endif
 
       /* If the variable is really a constant
 	 and not written in memory, inform the debugger.
@@ -3078,6 +3101,35 @@
 	  addr = 0;
 	  number = offs;
 	  code = N_GSYM;
+#ifdef EMX 
+          /* bird: Two hacks.
+             1) Get right address for globals. We're using the value field of
+                the entry for this. This makes the following code work:
+                class foo { foo() {static const char *psz= "foo";} };
+             2) Hack 1 doesn't work for external or communal data. They would
+                both require a fixup of the stabs value to work - which a.out
+                naturally doesn't support (ELF does though).
+                So, what we'll do is to make an extra entry before the 'G'
+                entry which tells us the symbol name.
+                In this case the value of the 'G' entry is -12357.  */
+          if (use_gnu_debug_info_extensions)
+            {
+              addr = XEXP (home, 0);
+              if (DECL_EXTERNAL (decl) || DECL_COMMON (decl))
+                {
+                  fprintf (asm_out_file, "\t.stabs\t\"");
+                  output_addr_const (asm_out_file, addr);
+#if 0
+                  fprintf (asm_out_file, "\",%d,0,0,0\n", /*N_EXT | N_UNDF*/1);
+#else
+                  fprintf (asm_out_file, "\",%d,0,0,0\n", /*extension*/ 0xfe);
+#endif
+                  addr = 0;
+                  number = -12357;
+                }
+            }
+#endif
+
 	}
     }
   else if (GET_CODE (home) == CONCAT)
diff -ur gcc-4.5.2-o/gcc/gcc.c gcc-4.5.2/gcc/gcc.c
--- gcc-4.5.2-o/gcc/gcc.c	2010-04-19 03:16:08.000000000 +0930
+++ gcc-4.5.2/gcc/gcc.c	2010-12-20 08:04:34.000000000 +1030
@@ -393,7 +393,7 @@
 static void init_gcc_specs (struct obstack *, const char *, const char *,
 			    const char *);
 #endif
-#if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
+#if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX) && !defined (NO_FORCE_EXEOBJ_SUFFIX)
 static const char *convert_filename (const char *, int, int);
 #endif
 
@@ -1264,6 +1264,9 @@
    {"--warn-", "-W", "*j"},
    {"--write-dependencies", "-MD", 0},
    {"--write-user-dependencies", "-MMD", 0},
+#ifdef CLH
+   {"--help", "-h", "oj"},
+#endif
    {"--", "-f", "*j"}
  };
 
@@ -2038,8 +2041,11 @@
 static int signal_count;
 
 /* Name with which this program was invoked.  */
-
+#ifdef CLH
+const char *programname;
+#else
 static const char *programname;
+#endif
 
 /* Allocate the argument vector.  */
 
@@ -2974,7 +2980,7 @@
   for (n_commands = 1, i = 0; i < argbuf_index; i++)
     if (strcmp (argbuf[i], "|") == 0)
       {				/* each command.  */
-#if defined (__MSDOS__) || defined (OS2) || defined (VMS)
+#if defined (__MSDOS__) || defined (VMS)
 	fatal ("-pipe not supported");
 #endif
 	argbuf[i] = 0;	/* termination of command args.  */
@@ -3315,7 +3321,7 @@
 
 const char **outfiles;
 
-#if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
+#if (defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)) && !defined (NO_FORCE_EXEOBJ_SUFFIX)
 
 /* Convert NAME to a new name if it is the standard suffix.  DO_EXE
    is true if we should look for an executable suffix.  DO_OBJ
@@ -3758,6 +3764,7 @@
 	}
     }
 
+#ifndef __EMX__ /* Under OS/2 (__EMX__) LPATH is used in LANManager client & server */
   /* Use LPATH like LIBRARY_PATH (for the CMU build program).  */
   GET_ENVIRONMENT (temp, "LPATH");
   if (temp && *cross_compile == '0')
@@ -3790,6 +3797,7 @@
 	    endp++;
 	}
     }
+#endif /* not __EMX__ */
 
   /* Scan argv twice.  Here, the first time, just count how many switches
      there will be in their vector, and how many input files in theirs.
@@ -4087,6 +4095,14 @@
 	  verbose_only_flag++;
 	  verbose_flag++;
 	}
+#ifdef CLH
+      else if (! strncmp (argv[i], "-h", 2))
+	{
+	  extern int clh_display (const char *text, const char *selector);
+          extern char *gcc_clh_text;
+          exit (clh_display (gcc_clh_text, &argv[i][2]));
+        }
+#endif /* CLH */
       else if (argv[i][0] == '-' && argv[i][1] != 0)
 	{
 	  const char *p = &argv[i][1];
@@ -4166,6 +4182,7 @@
 
 	    case 'o':
 	      have_o = 1;
+#ifndef NO_FORCE_EXEOBJ_SUFFIX
 #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
 	      if (! have_c)
 		{
@@ -4201,6 +4218,7 @@
 	      else
 		argv[i] = convert_filename (argv[i], ! have_c, 0);
 #endif
+#endif
 	      /* Save the output name in case -save-temps=obj was used.  */
 	      if ((p[1] == 0) && argv[i + 1])
 		save_temps_prefix = xstrdup(argv[i + 1]);
@@ -4322,14 +4340,12 @@
      configured-in locations.  */
   if (!gcc_exec_prefix)
     {
-#ifndef OS2
       add_prefix (&exec_prefixes, standard_libexec_prefix, "GCC",
 		  PREFIX_PRIORITY_LAST, 1, 0);
       add_prefix (&exec_prefixes, standard_libexec_prefix, "BINUTILS",
 		  PREFIX_PRIORITY_LAST, 2, 0);
       add_prefix (&exec_prefixes, standard_exec_prefix, "BINUTILS",
 		  PREFIX_PRIORITY_LAST, 2, 0);
-#endif
       add_prefix (&startfile_prefixes, standard_exec_prefix, "BINUTILS",
 		  PREFIX_PRIORITY_LAST, 1, 0);
     }
@@ -4579,7 +4595,7 @@
           char *fname;
 	  long offset;
 	  int consumed;
-#ifdef HAVE_TARGET_OBJECT_SUFFIX
+#ifdef HAVE_TARGET_OBJECT_SUFFIX && !defined (NO_FORCE_EXEOBJ_SUFFIX)
 	  argv[i] = convert_filename (argv[i], 0, access (argv[i], F_OK));
 #endif
 	  /* For LTO static archive support we handle input file
@@ -7304,7 +7320,11 @@
     }
 
   if (n_infiles == added_libraries)
+#ifdef CLH
+    fatal ("no input files, try \"%s --help\"", programname);
+#else
     fatal ("no input files");
+#endif
 
   /* Make a place to record the compiler output file names
      that correspond to the input files.  */
@@ -7529,6 +7549,7 @@
      with %b in LINK_SPEC. We use the first input file that we can find
      a compiler to compile it instead of using infiles.language since for
      languages other than C we use aliases that we then lookup later.  */
+#ifndef __EMX__ /* This code fails on OS/2 - revert to the GCC 3.4.6 code */
   if (n_infiles > 0)
     {
       int i;
@@ -7540,6 +7561,10 @@
 	    break;
 	  }
     }
+#else
+  if (n_infiles > 0)
+    set_input (infiles[0].name);
+#endif
 
   if (error_count == 0)
     {
diff -ur gcc-4.5.2-o/gcc/genattrtab.c gcc-4.5.2/gcc/genattrtab.c
--- gcc-4.5.2-o/gcc/genattrtab.c	2009-11-25 21:25:54.000000000 +1030
+++ gcc-4.5.2/gcc/genattrtab.c	2010-12-20 08:04:34.000000000 +1030
@@ -4444,6 +4444,11 @@
   rtx tem;
   int i;
 
+#ifdef EMX
+  /* Otherwise we can't use more than 32Mb memory and genattrtab uses a lot */
+  _uflags (_UF_SBRK_MODEL, _UF_SBRK_ARBITRARY);
+#endif
+
   progname = "genattrtab";
 
   if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
diff -ur gcc-4.5.2-o/gcc/gengtype.c gcc-4.5.2/gcc/gengtype.c
--- gcc-4.5.2-o/gcc/gengtype.c	2009-11-25 21:25:54.000000000 +1030
+++ gcc-4.5.2/gcc/gengtype.c	2010-12-20 08:04:34.000000000 +1030
@@ -335,7 +335,11 @@
       /* No space for a lang_bitmap is necessary.  Discard the '['. */
       c = getc (list);
       line = here;
+#ifndef __EMX__
       while (c != ']' && c != '\n' && c != EOF)
+#else
+      while (c != ']' && c != '\n' && c != EOF && c != '\r')
+#endif
 	{
 	  *here++ = c;
 	  c = getc (list);
@@ -345,7 +349,11 @@
       if (c == ']')
 	{
 	  c = getc (list);  /* eat what should be a newline */
+#ifndef __EMX__
 	  if (c != '\n' && c != EOF)
+#else
+	  if (c != '\n' && c != EOF && c != '\r' )
+#endif
 	    error_at_line (pos, "junk on line after language tag [%s]", line);
 	}
       else
diff -ur gcc-4.5.2-o/gcc/genmultilib gcc-4.5.2/gcc/genmultilib
--- gcc-4.5.2-o/gcc/genmultilib	2007-07-26 18:07:00.000000000 +0930
+++ gcc-4.5.2/gcc/genmultilib	2010-12-20 08:04:34.000000000 +1030
@@ -40,6 +40,9 @@
 # elements in the second list are separated by spaces.  If the second
 # argument is empty, the option names will be used as the directory
 # names.
+# If number of elements in second argument is bigger than number of options
+# in the first argument, the n+1'th element is used as default directory
+# name (i.e. when no one of options specified in argument 1 was used)
 
 # The optional third argument is a list of options which are
 # identical.  The elements in the list are separated by spaces.  Each
@@ -261,6 +264,12 @@
   fi
 fi
 
+# See if default directory was specified
+if [ -n "$1" ]; then
+  defaultdir="$1"
+else
+  defaultdir="."
+fi
 # We need another recursive shell script to correctly handle positive
 # matches.  If we are invoked as
 #   genmultilib "opt1 opt2" "" "opt1=nopt1 opt2=nopt2"
diff -ur gcc-4.5.2-o/gcc/ggc-page.c gcc-4.5.2/gcc/ggc-page.c
--- gcc-4.5.2-o/gcc/ggc-page.c	2009-12-03 12:34:16.000000000 +1030
+++ gcc-4.5.2/gcc/ggc-page.c	2011-01-22 12:50:02.000000000 +1030
@@ -36,6 +36,7 @@
 
 /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
    file open.  Prefer either to valloc.  */
+
 #ifdef HAVE_MMAP_ANON
 # undef HAVE_MMAP_DEV_ZERO
 
Only in gcc-4.5.2/gcc: gthr-os2.h
diff -ur gcc-4.5.2-o/gcc/gthr.h gcc-4.5.2/gcc/gthr.h
--- gcc-4.5.2-o/gcc/gthr.h	2009-11-25 21:25:54.000000000 +1030
+++ gcc-4.5.2/gcc/gthr.h	2010-12-20 08:04:34.000000000 +1030
@@ -137,6 +137,7 @@
      POSIX/Unix95 threads with -D_PTHREADS95
      DCE threads with -D_DCE_THREADS
      Solaris/UI threads with -D_SOLARIS_THREADS
+     OS/2 threads with -D_OS2_THREADS
 
 */
 
@@ -151,6 +152,8 @@
 #include "gthr-dce.h"
 #elif _SOLARIS_THREADS
 #include "gthr-solaris.h"
+#elif _OS2_THREADS 
+#include "gthr-os2.h"
 
 /* Include GTHREAD_FILE if one is defined.  */
 #elif defined(HAVE_GTHR_DEFAULT)
diff -ur gcc-4.5.2-o/gcc/incpath.c gcc-4.5.2/gcc/incpath.c
--- gcc-4.5.2-o/gcc/incpath.c	2009-11-25 21:25:54.000000000 +1030
+++ gcc-4.5.2/gcc/incpath.c	2010-12-20 08:04:34.000000000 +1030
@@ -37,7 +37,11 @@
 # define INO_T_EQ(A, B) (!memcmp (&(A), &(B), sizeof (A)))
 # define INO_T_COPY(DEST, SRC) memcpy(&(DEST), &(SRC), sizeof (SRC))
 #elif !defined (HOST_LACKS_INODE_NUMBERS)
-# define INO_T_EQ(A, B) ((A) == (B))
+# if defined __EMX__
+#  define INO_T_EQ(A, B) 0
+# else
+#  define INO_T_EQ(A, B) ((A) == (B))
+# endif
 # define INO_T_COPY(DEST, SRC) (DEST) = (SRC)
 #endif
 
diff -ur gcc-4.5.2-o/gcc/langhooks.c gcc-4.5.2/gcc/langhooks.c
--- gcc-4.5.2-o/gcc/langhooks.c	2009-12-17 09:37:10.000000000 +1030
+++ gcc-4.5.2/gcc/langhooks.c	2010-12-20 08:04:34.000000000 +1030
@@ -40,6 +40,12 @@
 #include "cgraph.h"
 #include "output.h"
 
+/* Provide a dummy target-specific name mangling hook */
+#ifndef TARGET_C_SET_DECL_ASSEMBLER_NAME
+#define TARGET_C_SET_DECL_ASSEMBLER_NAME(decl) 0
+#endif
+
+
 /* Do nothing; in many cases the default hook.  */
 
 void
@@ -163,6 +169,9 @@
 		      || DECL_EXTERNAL (decl)
 		      || TREE_PUBLIC (decl))));
 
+     /* GCCOS2: Some targets may want to apply special mangling
+        depending on certain attributes etc (e.g. stdcall). */
+     if (!TARGET_C_SET_DECL_ASSEMBLER_NAME (decl)) {
   /* By default, assume the name to use in assembly code is the same
      as that used in the source language.  (That's correct for C, and
      GCC used to set DECL_ASSEMBLER_NAME to the same value as
@@ -186,7 +195,7 @@
       id = get_identifier (label);
     }
   SET_DECL_ASSEMBLER_NAME (decl, id);
-
+ } /* os2 */
 }
 
 /* Type promotion for variable arguments.  */
diff -ur gcc-4.5.2-o/gcc/libgcc2.c gcc-4.5.2/gcc/libgcc2.c
--- gcc-4.5.2-o/gcc/libgcc2.c	2009-09-25 04:32:44.000000000 +0930
+++ gcc-4.5.2/gcc/libgcc2.c	2010-12-20 08:04:34.000000000 +1030
@@ -1284,7 +1284,7 @@
 UDWtype
 __fixunssfDI (SFtype a)
 {
-#if LIBGCC2_HAS_DF_MODE
+#if (LIBGCC2_HAS_DF_MODE) 
   /* Convert the SFtype to a DFtype, because that is surely not going
      to lose any bits.  Some day someone else can write a faster version
      that avoids converting to DFtype, and verify it really works right.  */
@@ -1302,7 +1302,7 @@
 
   /* Assemble result from the two parts.  */
   return ((UDWtype) hi << W_TYPE_SIZE) | lo;
-#elif FLT_MANT_DIG < W_TYPE_SIZE
+#elif (FLT_MANT_DIG < W_TYPE_SIZE) || defined(__EMX__)
   if (a < 1)
     return 0;
   if (a < Wtype_MAXp1_F)
@@ -2139,7 +2139,7 @@
       (*(p-1)) ();
     }
 #endif
-#if defined (EH_FRAME_SECTION_NAME) && !defined (HAS_INIT_SECTION)
+#if defined (EH_FRAME_SECTION_NAME) && !defined (HAS_INIT_SECTION) && !defined (DONT_AUTOREGISTER_FRAME_INFO)
   {
     static int completed = 0;
     if (! completed)
@@ -2158,7 +2158,7 @@
 void
 __do_global_ctors (void)
 {
-#ifdef EH_FRAME_SECTION_NAME
+#if defined (EH_FRAME_SECTION_NAME) && !defined (DONT_AUTOREGISTER_FRAME_INFO)
   {
     static struct object object;
     __register_frame_info (__EH_FRAME_BEGIN__, &object);
diff -ur gcc-4.5.2-o/gcc/Makefile.in gcc-4.5.2/gcc/Makefile.in
--- gcc-4.5.2-o/gcc/Makefile.in	2010-09-02 22:35:30.000000000 +0930
+++ gcc-4.5.2/gcc/Makefile.in	2010-12-20 08:04:34.000000000 +1030
@@ -237,6 +237,9 @@
 # -------------------------------------------
 
 SHELL = @SHELL@
+# "mkdir cp; cp something cp" doesn't work ash on OS/2.
+CP = cp@host_exeext@
+
 # pwd command to use.  Allow user to override default by setting PWDCMD in
 # the environment to account for automounters.  The make variable must not
 # be called PWDCMD, otherwise the value set here is passed to make
@@ -1031,6 +1034,16 @@
 	    build/min-insn-modes.o build/gensupport.o build/print-rtl.o
 BUILD_ERRORS = build/errors.o
 
+# GCC-OS2: help
+# This gets linked into gcc if command-line help was enabled
+#CLH_LIBS = @gcc_clh_libs@
+# These definitions enables --help for gcc
+#CLH_CFLAGS = @gcc_clh_cflags@
+#CLH_GCC = @gcc_clh_gcc@
+#CLH_CPP = @gcc_clh_cpp@
+#CLH_G77 = @gcc_clh_g77@
+#CLH_GCJ = @gcc_clh_gcj@
+
 # Specify the directories to be searched for header files.
 # Both . and srcdir are used, in that order,
 # so that *config.h will be found in the compilation
@@ -1785,7 +1798,7 @@
 # compile libgcc2.a.
 # Also create gcc-cross, so that install-common will install properly.
 gcc-cross$(exeext): xgcc$(exeext)
-	cp xgcc$(exeext) gcc-cross$(exeext)
+	$(CP) xgcc$(exeext) gcc-cross$(exeext)
 
 dummy-checksum.o : dummy-checksum.c $(CONFIG_H) $(SYSTEM_H)
 
@@ -1802,6 +1815,16 @@
 	$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \
 	  cc1-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
 
+# GCC-OS2: help.
+clh.o: clh.c $(CONFIG_H)
+	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $(srcdir)/clh.c
+
+clh_gcc.c: $(srcdir)/doc/invoke.texi $(srcdir)/mkoptdesc.sh
+	$(srcdir)/mkoptdesc.sh $(srcdir)/doc/invoke.texi gcc > clh_gcc.c
+
+clh_cpp.c: $(srcdir)/doc/invoke.texi $(srcdir)/mkoptdesc.sh
+	$(srcdir)/mkoptdesc.sh $(srcdir)/doc/invoke.texi cpp > clh_cpp.c
+
 #
 # Build libgcc.a.
 
@@ -3834,22 +3857,22 @@
 	    realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`; \
 	    $(STAMP) include/$$realfile; \
 	    rm -f include/$$realfile; \
-	    cp $$file include; \
+	    $(CP) $$file include; \
 	    chmod a+r include/$$realfile; \
 	  fi; \
 	done
 	rm -f include/unwind.h
-	cp $(UNWIND_H) include/unwind.h
+	$(CP) $(UNWIND_H) include/unwind.h
 	chmod a+r include/unwind.h
 	rm -f include/stdint.h
 	if [ $(USE_GCC_STDINT) = wrap ]; then \
 	  rm -f include/stdint-gcc.h; \
-	  cp $(srcdir)/ginclude/stdint-gcc.h include/stdint-gcc.h; \
+	  $(CP) $(srcdir)/ginclude/stdint-gcc.h include/stdint-gcc.h; \
 	  chmod a+r include/stdint-gcc.h; \
-	  cp $(srcdir)/ginclude/stdint-wrap.h include/stdint.h; \
+	  $(CP) $(srcdir)/ginclude/stdint-wrap.h include/stdint.h; \
 	  chmod a+r include/stdint.h; \
 	elif [ $(USE_GCC_STDINT) = provide ]; then \
-	  cp $(srcdir)/ginclude/stdint-gcc.h include/stdint.h; \
+	  $(CP) $(srcdir)/ginclude/stdint-gcc.h include/stdint.h; \
 	  chmod a+r include/stdint.h; \
 	fi
 	set -e; for ml in `cat fixinc_list`; do \
@@ -3869,7 +3892,7 @@
 	done
 # Install the README
 	rm -f include-fixed/README
-	cp $(srcdir)/../fixincludes/README-fixinc include-fixed/README
+	$(CP) $(srcdir)/../fixincludes/README-fixinc include-fixed/README
 	chmod a+r include-fixed/README
 	$(STAMP) $@
 
@@ -3959,7 +3982,7 @@
 	    if [ -f $${fix_dir}/limits.h ]; then \
 	      mv $${fix_dir}/limits.h $${fix_dir}/syslimits.h; \
 	    else \
-	      cp $(srcdir)/gsyslimits.h $${fix_dir}/syslimits.h; \
+	      $(CP) $(srcdir)/gsyslimits.h $${fix_dir}/syslimits.h; \
 	    fi; \
 	    chmod a+r $${fix_dir}/syslimits.h; \
 	  done; \
diff -ur gcc-4.5.2-o/gcc/opts.c gcc-4.5.2/gcc/opts.c
--- gcc-4.5.2-o/gcc/opts.c	2010-05-17 19:43:28.000000000 +0930
+++ gcc-4.5.2/gcc/opts.c	2011-03-04 19:02:38.000000000 +1030
@@ -2307,7 +2307,7 @@
 int
 option_enabled (int opt_idx)
 {
-  const struct cl_option *option = &(cl_options[opt_idx]);
+ const struct cl_option *option = &(cl_options[opt_idx]);
 
   if (option->flag_var)
     switch (option->var_type)
diff -ur gcc-4.5.2-o/gcc/prefix.c gcc-4.5.2/gcc/prefix.c
--- gcc-4.5.2-o/gcc/prefix.c	2007-09-04 02:39:20.000000000 +0930
+++ gcc-4.5.2/gcc/prefix.c	2010-12-20 08:04:34.000000000 +1030
@@ -352,5 +352,7 @@
 void
 set_std_prefix (const char *prefix, int len)
 {
+#ifndef __EMX__
   std_prefix = save_string (prefix, len);
+#endif
 }
diff -ur gcc-4.5.2-o/gcc/reg-stack.c gcc-4.5.2/gcc/reg-stack.c
--- gcc-4.5.2-o/gcc/reg-stack.c	2010-10-25 07:23:26.000000000 +1030
+++ gcc-4.5.2/gcc/reg-stack.c	2010-12-20 08:04:34.000000000 +1030
@@ -2628,6 +2628,21 @@
   edge e;
   edge_iterator ei;
 
+  /* GCC-OS2: fp regs passing
+     Figure out the arguments passed in stack registers.  */
+  tree parm = DECL_ARGUMENTS (current_function_decl);
+  int incoming_arg [REG_STACK_SIZE];
+  int i;
+
+  memset (incoming_arg, 0, sizeof (incoming_arg));
+  while (parm)
+    {
+      rtx x = DECL_INCOMING_RTL (parm);
+      if (STACK_REG_P (x))
+	incoming_arg[REGNO (x) - FIRST_STACK_REG] = x;
+      parm = TREE_CHAIN (parm);
+    }
+
   /* Load something into each stack register live at function entry.
      Such live registers can be caused by uninitialized variables or
      functions not returning values on all paths.  In order to keep
@@ -2642,9 +2657,17 @@
       basic_block block = e->dest;
       block_info bi = BLOCK_INFO (block);
       int reg, top = -1;
+      int dead_arguments = 0; /* GCC-OS2: fp regs passing */ 
+
+      /* GCC-OS2: fp regs passing
+         Put the incoming arguments to the stack. */
+      for (i = LAST_STACK_REG; i >= FIRST_STACK_REG; i--)
+	if (incoming_arg [i - FIRST_STACK_REG])
+	  bi->stack_in.reg[++top] = i;
 
       for (reg = LAST_STACK_REG; reg >= FIRST_STACK_REG; --reg)
-	if (TEST_HARD_REG_BIT (bi->stack_in.reg_set, reg))
+	if (TEST_HARD_REG_BIT (bi->stack_in.reg_set, reg)
+	    && !incoming_arg [reg - FIRST_STACK_REG]) /* GCC-OS2: fp regs passing */
 	  {
 	    rtx init;
 
@@ -2658,6 +2681,42 @@
 	  }
 
       bi->stack_in.top = top;
+
+      /* GCC-OS2: fp regs passing */
+
+      /* Check whether there are any dead arguments that needs
+         to be popped.  */
+      for (i = LAST_STACK_REG; i >= FIRST_STACK_REG; i--)
+	if (incoming_arg [i - FIRST_STACK_REG]
+	    && !TEST_HARD_REG_BIT (bi->stack_in.reg_set, i))
+          {
+	    dead_arguments = 1;
+	    break;
+          }
+
+      if (dead_arguments)
+	{
+	  rtx seq;
+	  rtx after;
+	  start_sequence ();
+		  
+	  /* ??? pop_stack needs some point to emit insns after.
+	     Also needed to keep gen_sequence from returning a 
+	     pattern as opposed to a sequence, which would lose
+	     REG_DEAD notes.  */
+	  after = emit_note (NOTE_INSN_DELETED);
+
+	  for (i = LAST_STACK_REG; i >= FIRST_STACK_REG; i--)
+	    if (incoming_arg [i - FIRST_STACK_REG]
+		&& !TEST_HARD_REG_BIT (bi->stack_in.reg_set,i))
+	      after = emit_pop_insn (after, &bi->stack_in,
+				     FP_MODE_REG (i, DFmode), EMIT_AFTER);
+
+	  seq = get_insns ();
+	  end_sequence ();
+	  inserted = 1;
+	  insert_insn_on_edge (seq, e);
+	}
     }
 
   return inserted;
diff -ur gcc-4.5.2-o/gcc/target-def.h gcc-4.5.2/gcc/target-def.h
--- gcc-4.5.2-o/gcc/target-def.h	2010-06-25 06:36:36.000000000 +0930
+++ gcc-4.5.2/gcc/target-def.h	2010-12-20 08:04:34.000000000 +1030
@@ -95,7 +95,9 @@
 #define TARGET_ASM_FUNCTION_PROLOGUE default_function_pro_epilogue
 #define TARGET_ASM_FUNCTION_EPILOGUE default_function_pro_epilogue
 #define TARGET_ASM_FUNCTION_END_PROLOGUE no_asm_to_stream
+#ifndef TARGET_ASM_FUNCTION_BEGIN_EPILOGUE /* GCC-OS2 */
 #define TARGET_ASM_FUNCTION_BEGIN_EPILOGUE no_asm_to_stream
+#endif                                     /* GCC-OS2 */
 
 #ifndef TARGET_ASM_RELOC_RW_MASK
 #define TARGET_ASM_RELOC_RW_MASK default_reloc_rw_mask
diff -ur gcc-4.5.2-o/gcc/toplev.c gcc-4.5.2/gcc/toplev.c
--- gcc-4.5.2-o/gcc/toplev.c	2010-03-31 13:14:10.000000000 +1030
+++ gcc-4.5.2/gcc/toplev.c	2010-12-20 08:04:34.000000000 +1030
@@ -1696,9 +1696,11 @@
   pp_format_decoder (global_dc->printer) = &default_tree_printer;
 
   /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
+#ifndef __OS2__ /* On OS/2 we'd rather see the registers to help understand where the crash occured */
 #ifdef SIGSEGV
   signal (SIGSEGV, crash_signal);
 #endif
+#endif
 #ifdef SIGILL
   signal (SIGILL, crash_signal);
 #endif
diff -ur gcc-4.5.2-o/gcc/tree.c gcc-4.5.2/gcc/tree.c
--- gcc-4.5.2-o/gcc/tree.c	2010-07-08 00:54:26.000000000 +0930
+++ gcc-4.5.2/gcc/tree.c	2010-12-20 08:04:34.000000000 +1030
@@ -5425,7 +5425,6 @@
 
   return NULL_TREE;
 }
-
 #endif /* TARGET_DLLIMPORT_DECL_ATTRIBUTES  */
 
 /* Set the type qualifiers for TYPE to TYPE_QUALS, which is a bitmask
@@ -8336,7 +8335,6 @@
      the program) rather than the file name (which imposes extra
      constraints).  */
   sprintf (buf, FILE_FUNCTION_FORMAT, type, p);
-
   return get_identifier (buf);
 }
 
diff -ur gcc-4.5.2-o/gcc/tsystem.h gcc-4.5.2/gcc/tsystem.h
--- gcc-4.5.2-o/gcc/tsystem.h	2009-04-10 00:30:18.000000000 +0930
+++ gcc-4.5.2/gcc/tsystem.h	2010-12-20 08:04:34.000000000 +1030
@@ -92,6 +92,11 @@
 /* All systems have this header.  */
 #include <errno.h>
 
+#ifdef __OS2__ /* not finding these definitions for some reason */
+#define BOOL_BITFIELD unsigned int
+#include "hwint.h"
+#endif
+
 #ifndef errno
 extern int errno;
 #endif
diff -ur gcc-4.5.2-o/gcc/unwind-compat.c gcc-4.5.2/gcc/unwind-compat.c
--- gcc-4.5.2-o/gcc/unwind-compat.c	2009-11-25 21:25:54.000000000 +1030
+++ gcc-4.5.2/gcc/unwind-compat.c	2010-12-20 08:04:34.000000000 +1030
@@ -23,7 +23,7 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#if defined (USE_GAS_SYMVER) && defined (USE_LIBUNWIND_EXCEPTIONS)
+#if defined (USE_GAS_SYMVER) && defined (USE_LIBUNWIND_EXCEPTIONS) 
 #include "tconfig.h"
 #include "tsystem.h"
 #include "unwind.h"
diff -ur gcc-4.5.2-o/gcc/unwind-dw2.c gcc-4.5.2/gcc/unwind-dw2.c
--- gcc-4.5.2-o/gcc/unwind-dw2.c	2010-04-27 19:11:30.000000000 +0930
+++ gcc-4.5.2/gcc/unwind-dw2.c	2010-12-20 08:04:34.000000000 +1030
@@ -27,6 +27,9 @@
 #include "tsystem.h"
 #include "coretypes.h"
 #include "tm.h"
+#ifdef __EMX__
+#define FIRST_PSEUDO_REGISTER 53
+#endif
 #include "dwarf2.h"
 #include "unwind.h"
 #ifdef __USING_SJLJ_EXCEPTIONS__
@@ -146,6 +149,7 @@
   return context->flags & EXTENDED_CONTEXT_BIT;
 }
 
+#ifndef __KLIBC__xx /* KLIBC already defines these in libc063.dll */
 /* Get the value of register INDEX as saved in CONTEXT.  */
 
 inline _Unwind_Word
@@ -176,6 +180,7 @@
       return * (_Unwind_Word *) ptr;
     }
 }
+#endif
 
 static inline void *
 _Unwind_GetPtr (struct _Unwind_Context *context, int index)
@@ -183,6 +188,7 @@
   return (void *)(_Unwind_Ptr) _Unwind_GetGR (context, index);
 }
 
+#ifndef __KLIBC__xx /* KLIBC already defines these in libc063.dll */
 /* Get the value of the CFA as saved in CONTEXT.  */
 
 _Unwind_Word
@@ -219,6 +225,7 @@
       * (_Unwind_Word *) ptr = val;
     }
 }
+#endif
 
 /* Get the pointer to a register INDEX as saved in CONTEXT.  */
 
@@ -266,6 +273,7 @@
   return context->by_value[index];
 }
 
+#ifndef __KLIBC__xx /* KLIBC already defines these in libc063.dll */
 /* Retrieve the return address for CONTEXT.  */
 
 inline _Unwind_Ptr
@@ -273,6 +281,7 @@
 {
   return (_Unwind_Ptr) context->ra;
 }
+#endif
 
 /* Retrieve the return address and flag whether that IP is before
    or after first not yet fully executed instruction.  */
@@ -284,6 +293,7 @@
   return (_Unwind_Ptr) context->ra;
 }
 
+#ifndef __KLIBC__xx /* KLIBC already defines these in libc063.dll */
 /* Overwrite the return address for CONTEXT with VAL.  */
 
 inline void
@@ -328,7 +338,7 @@
   return (_Unwind_Ptr) context->bases.tbase;
 }
 #endif
-
+#endif /* __KLIBC__ */
 #ifdef MD_UNWIND_SUPPORT
 #include MD_UNWIND_SUPPORT
 #endif
diff -ur gcc-4.5.2-o/gcc/unwind.inc gcc-4.5.2/gcc/unwind.inc
--- gcc-4.5.2-o/gcc/unwind.inc	2009-04-10 00:30:18.000000000 +0930
+++ gcc-4.5.2/gcc/unwind.inc	2010-12-20 08:04:34.000000000 +1030
@@ -76,6 +76,7 @@
   return code;
 }
 
+#ifndef __KLIBC__xx /* KLIBC already defines these in libc063.dll */
 /* Raise an exception, passing along the given exception object.  */
 
 _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
@@ -134,7 +135,7 @@
 
   uw_install_context (&this_context, &cur_context);
 }
-
+#endif
 
 /* Subroutine of _Unwind_ForcedUnwind also invoked from _Unwind_Resume.  */
 
@@ -212,6 +213,7 @@
 }
 
 
+#ifndef __KLIBC__xx /* KLIBC already defines these in libc063.dll */
 /* Resume propagation of an existing exception.  This is used after
    e.g. executing cleanup code, and not to implement rethrowing.  */
 
@@ -261,7 +263,6 @@
   uw_install_context (&this_context, &cur_context);
 }
 
-
 /* A convenience function that calls the exception_cleanup field.  */
 
 void
@@ -270,7 +271,7 @@
   if (exc->exception_cleanup)
     (*exc->exception_cleanup) (_URC_FOREIGN_EXCEPTION_CAUGHT, exc);
 }
-
+#endif /* __KLIBC__xx */
 
 /* Perform stack backtrace through unwind data.  */
 
diff -ur gcc-4.5.2-o/gcc/varasm.c gcc-4.5.2/gcc/varasm.c
--- gcc-4.5.2-o/gcc/varasm.c	2010-03-27 22:26:30.000000000 +1030
+++ gcc-4.5.2/gcc/varasm.c	2010-12-20 08:04:34.000000000 +1030
@@ -1579,7 +1579,6 @@
 default_named_section_asm_out_destructor (rtx symbol, int priority)
 {
   section *sec;
-
   if (priority != DEFAULT_INIT_PRIORITY)
     sec = get_cdtor_priority_section (priority,
 				      /*constructor_p=*/false);
@@ -2516,6 +2515,20 @@
 	name = IDENTIFIER_POINTER (id);
       gcc_assert (! TREE_CHAIN (id));
     }
+#if 0
+  /* Some code assume that this is the identifier returned 
+     by DECL_ASSEMBLER_NAME (). However, for GCC-OS2 it's not
+     since the calling conventions _Optlink, __stdcall, and
+     _System name encodings are included in the identifier
+     returned by DECL_ASSEMBLER_NAME ().
+     Therefore we need this extra little cludge here. */
+  if (name != real_name)
+    {
+      id = maybe_get_identifier (name);
+      if (id)
+	mark_referenced (id);
+   }
+#endif
 
   assemble_name_raw (file, name);
 }
diff -ur gcc-4.5.2-o/include/filenames.h gcc-4.5.2/include/filenames.h
--- gcc-4.5.2-o/include/filenames.h	2008-03-22 10:05:06.000000000 +1030
+++ gcc-4.5.2/include/filenames.h	2010-12-20 08:04:34.000000000 +1030
@@ -30,7 +30,7 @@
 extern "C" {
 #endif
 
-#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
+#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__) || defined(__EMX__)
 
 #ifndef HAVE_DOS_BASED_FILE_SYSTEM
 #define HAVE_DOS_BASED_FILE_SYSTEM 1
Only in gcc-4.5.2/libgcc/config/i386: t-emx
diff -ur gcc-4.5.2-o/libgcc/config.host gcc-4.5.2/libgcc/config.host
--- gcc-4.5.2-o/libgcc/config.host	2010-09-12 12:57:08.000000000 +0930
+++ gcc-4.5.2/libgcc/config.host	2010-12-20 08:04:34.000000000 +1030
@@ -338,6 +338,9 @@
 	;;
 x86_64-*-mingw*)
 	;;
+i*86-pc-*emx)		# i?86 running OS/2
+    host_exeext=.exe
+    ;;
 i[34567]86-*-interix3*)
 	;;
 ia64*-*-elf*)
diff -ur gcc-4.5.2-o/libgomp/config/posix/lock.c gcc-4.5.2/libgomp/config/posix/lock.c
--- gcc-4.5.2-o/libgomp/config/posix/lock.c	2009-04-10 00:30:18.000000000 +0930
+++ gcc-4.5.2/libgomp/config/posix/lock.c	2010-12-20 08:04:34.000000000 +1030
@@ -243,6 +243,7 @@
 void
 gomp_init_nest_lock_25 (omp_nest_lock_25_t *lock)
 {
+#ifndef __EMX__
   pthread_mutexattr_t attr;
 
   pthread_mutexattr_init (&attr);
@@ -250,6 +251,7 @@
   pthread_mutex_init (&lock->lock, &attr);
   lock->count = 0;
   pthread_mutexattr_destroy (&attr);
+#endif
 }
 
 void
diff -ur gcc-4.5.2-o/libgomp/config/posix/omp-lock.h gcc-4.5.2/libgomp/config/posix/omp-lock.h
--- gcc-4.5.2-o/libgomp/config/posix/omp-lock.h	2008-06-06 22:31:54.000000000 +0930
+++ gcc-4.5.2/libgomp/config/posix/omp-lock.h	2010-12-20 08:04:34.000000000 +1030
@@ -8,11 +8,13 @@
    thread than the one that called pthread_mutex_lock.  */
 
 #include <pthread.h>
+#ifndef __EMX__
 #include <semaphore.h>
+#endif
 
 typedef pthread_mutex_t omp_lock_25_t;
 typedef struct { pthread_mutex_t lock; int count; } omp_nest_lock_25_t;
-#ifdef HAVE_BROKEN_POSIX_SEMAPHORES
+#if defined(HAVE_BROKEN_POSIX_SEMAPHORES) || defined(__EMX__)
 /* If we don't have working semaphores, we'll make all explicit tasks
    tied to the creating thread.  */
 typedef pthread_mutex_t omp_lock_t;
diff -ur gcc-4.5.2-o/libgomp/config/posix/sem.h gcc-4.5.2/libgomp/config/posix/sem.h
--- gcc-4.5.2-o/libgomp/config/posix/sem.h	2009-04-10 00:30:18.000000000 +0930
+++ gcc-4.5.2/libgomp/config/posix/sem.h	2010-12-20 08:04:34.000000000 +1030
@@ -37,7 +37,11 @@
 # pragma GCC visibility push(default)
 #endif
 
+#ifndef __EMX__
 #include <semaphore.h>
+#else
+#define HAVE_BROKEN_POSIX_SEMAPHORES 1
+#endif 
 
 #ifdef HAVE_ATTRIBUTE_VISIBILITY
 # pragma GCC visibility pop
diff -ur gcc-4.5.2-o/libiberty/argv.c gcc-4.5.2/libiberty/argv.c
--- gcc-4.5.2-o/libiberty/argv.c	2009-10-09 01:44:40.000000000 +1030
+++ gcc-4.5.2/libiberty/argv.c	2010-12-20 08:04:34.000000000 +1030
@@ -239,10 +239,12 @@
 		      bsquote = 0;
 		      *arg++ = *input;
 		    }
+#ifndef __OS2__ /* skip this due to use of backslash in drive paths */
 		  else if (*input == '\\')
 		    {
 		      bsquote = 1;
 		    }
+#endif
 		  else if (squote)
 		    {
 		      if (*input == '\'')
@@ -496,7 +498,6 @@
   "arg 'Jack said \\'hi\\'' has single quotes",
   "arg 'Jack said \\\"hi\\\"' has double quotes",
   "a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9",
-  
   /* This should be expanded into only one argument.  */
   "trailing-whitespace ",
 
diff -ur gcc-4.5.2-o/libiberty/basename.c gcc-4.5.2/libiberty/basename.c
--- gcc-4.5.2-o/libiberty/basename.c	2005-04-16 10:10:08.000000000 +0930
+++ gcc-4.5.2/libiberty/basename.c	2010-12-20 08:04:34.000000000 +1030
@@ -24,7 +24,7 @@
 #endif
 
 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
-  defined (__OS2__)
+  defined (__OS2__) || defined (__EMX__)
 #define HAVE_DOS_BASED_FILE_SYSTEM
 #ifndef DIR_SEPARATOR_2 
 #define DIR_SEPARATOR_2 '\\'
Only in gcc-4.5.2/libiberty/config: mh-emx
diff -ur gcc-4.5.2-o/libiberty/configure gcc-4.5.2/libiberty/configure
--- gcc-4.5.2-o/libiberty/configure	2010-01-05 10:16:56.000000000 +1030
+++ gcc-4.5.2/libiberty/configure	2010-12-20 08:04:34.000000000 +1030
@@ -3465,13 +3465,13 @@
   CFLAGS=$ac_save_CFLAGS
 elif test $ac_cv_prog_cc_g = yes; then
   if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
+    CFLAGS="-g"
   else
     CFLAGS="-g"
   fi
 else
   if test "$GCC" = yes; then
-    CFLAGS="-O2"
+    CFLAGS=""
   else
     CFLAGS=
   fi
@@ -4844,6 +4844,7 @@
 if [ "${shared}" = "yes" ]; then
   case "${host}" in
     *-*-cygwin*)	;;
+    i*86-pc-*emx)	;;
     alpha*-*-linux*)	PICFLAG=-fPIC ;;
     arm*-*-*)		PICFLAG=-fPIC ;;
     hppa*-*-*)		PICFLAG=-fPIC ;;
diff -ur gcc-4.5.2-o/libiberty/configure.ac gcc-4.5.2/libiberty/configure.ac
--- gcc-4.5.2-o/libiberty/configure.ac	2010-01-05 10:16:56.000000000 +1030
+++ gcc-4.5.2/libiberty/configure.ac	2010-12-20 08:04:34.000000000 +1030
@@ -201,6 +201,7 @@
 if [[ "${shared}" = "yes" ]]; then
   case "${host}" in
     *-*-cygwin*)	;;
+    i*86-pc-*emx)	;;
     alpha*-*-linux*)	PICFLAG=-fPIC ;;
     arm*-*-*)		PICFLAG=-fPIC ;;
     hppa*-*-*)		PICFLAG=-fPIC ;;
diff -ur gcc-4.5.2-o/libiberty/getpwd.c gcc-4.5.2/libiberty/getpwd.c
--- gcc-4.5.2-o/libiberty/getpwd.c	2005-05-25 06:18:24.000000000 +0930
+++ gcc-4.5.2/libiberty/getpwd.c	2010-12-20 08:04:34.000000000 +1030
@@ -57,7 +57,7 @@
 #define GUESSPATHLEN 100
 #endif
 
-#if !(defined (VMS) || (defined(_WIN32) && !defined(__CYGWIN__)))
+#if !(defined (VMS) || (defined(_WIN32) && !defined(__CYGWIN__)) || defined(__EMX__))
 
 /* Get the working directory.  Use the PWD environment variable if it's
    set correctly, since this is faster and gives more uniform answers
@@ -105,7 +105,7 @@
   return p;
 }
 
-#else	/* VMS || _WIN32 && !__CYGWIN__ */
+#else	/* VMS || _WIN32 && !__CYGWIN__ || __EMX__ */
 
 #ifndef MAXPATHLEN
 #define MAXPATHLEN 255
@@ -125,4 +125,4 @@
   return pwd;
 }
 
-#endif	/* VMS || _WIN32 && !__CYGWIN__ */
+#endif	/* VMS || _WIN32 && !__CYGWIN__ || __EMX__ */
diff -ur gcc-4.5.2-o/libiberty/make-relative-prefix.c gcc-4.5.2/libiberty/make-relative-prefix.c
--- gcc-4.5.2-o/libiberty/make-relative-prefix.c	2008-03-25 03:41:20.000000000 +1030
+++ gcc-4.5.2/libiberty/make-relative-prefix.c	2010-12-20 08:04:34.000000000 +1030
@@ -74,7 +74,7 @@
 #endif
 
 #if defined (_WIN32) || defined (__MSDOS__) \
-    || defined (__DJGPP__) || defined (__OS2__)
+    || defined (__DJGPP__) || defined (__OS2__) || defined (__EMX__)
 #  define HAVE_DOS_BASED_FILE_SYSTEM
 #  define HAVE_HOST_EXECUTABLE_SUFFIX
 #  define HOST_EXECUTABLE_SUFFIX ".exe"
diff -ur gcc-4.5.2-o/libiberty/make-temp-file.c gcc-4.5.2/libiberty/make-temp-file.c
--- gcc-4.5.2-o/libiberty/make-temp-file.c	2009-07-30 05:00:12.000000000 +0930
+++ gcc-4.5.2/libiberty/make-temp-file.c	2010-12-20 08:04:34.000000000 +1030
@@ -137,7 +137,14 @@
       len = strlen (base);
       tmpdir = XNEWVEC (char, len + 2);
       strcpy (tmpdir, base);
+#ifdef __EMX__
+  if (tmpdir[len - 1] == '\\' || tmpdir[len - 1] == '/')
+    tmpdir[--len] = DIR_SEPARATOR;
+  else
+    tmpdir[len] = DIR_SEPARATOR;
+#else
       tmpdir[len] = DIR_SEPARATOR;
+#endif
       tmpdir[len+1] = '\0';
       memoized_tmpdir = tmpdir;
 #else /* defined(_WIN32) && !defined(__CYGWIN__) */
diff -ur gcc-4.5.2-o/libiberty/Makefile.in gcc-4.5.2/libiberty/Makefile.in
--- gcc-4.5.2-o/libiberty/Makefile.in	2010-03-02 16:39:56.000000000 +1030
+++ gcc-4.5.2/libiberty/Makefile.in	2010-12-20 08:04:34.000000000 +1030
@@ -71,7 +71,7 @@
 
 # A configuration can specify extra .o files that should be included,
 # even if they are in libc. (Perhaps the libc version is buggy.)
-EXTRA_OFILES = 
+EXTRA_OFILES =
 
 # Flags to pass to a recursive make.
 FLAGS_TO_PASS = \
diff -ur gcc-4.5.2-o/libiberty/pex-unix.c gcc-4.5.2/libiberty/pex-unix.c
--- gcc-4.5.2-o/libiberty/pex-unix.c	2009-12-08 17:35:34.000000000 +1030
+++ gcc-4.5.2/libiberty/pex-unix.c	2010-12-20 08:04:34.000000000 +1030
@@ -115,7 +115,7 @@
 
 static pid_t pex_wait (struct pex_obj *, pid_t, int *, struct pex_time *);
 
-#ifdef HAVE_WAIT4
+#if defined(HAVE_WAIT4) && !defined(__EMX__)
 
 static pid_t
 pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status,
diff -ur gcc-4.5.2-o/libstdc++-v3/include/bits/stringfwd.h gcc-4.5.2/libstdc++-v3/include/bits/stringfwd.h
--- gcc-4.5.2-o/libstdc++-v3/include/bits/stringfwd.h	2010-05-07 05:33:34.000000000 +0930
+++ gcc-4.5.2/libstdc++-v3/include/bits/stringfwd.h	2010-12-20 08:04:34.000000000 +1030
@@ -66,6 +66,8 @@
   template<> struct char_traits<wchar_t>;
 
   typedef basic_string<wchar_t> wstring;   ///< A string of @c wchar_t
+#elif defined(__OS2__)
+  typedef basic_string<wchar_t> wstring;
 #endif
 
 #if (defined(__GXX_EXPERIMENTAL_CXX0X__) \
diff -ur gcc-4.5.2-o/libstdc++-v3/include/parallel/compatibility.h gcc-4.5.2/libstdc++-v3/include/parallel/compatibility.h
--- gcc-4.5.2-o/libstdc++-v3/include/parallel/compatibility.h	2010-03-17 09:31:28.000000000 +1030
+++ gcc-4.5.2/libstdc++-v3/include/parallel/compatibility.h	2010-12-20 08:04:34.000000000 +1030
@@ -39,7 +39,7 @@
 #include <sys/atomic.h>
 #endif
 
-#if !defined(_WIN32) || defined (__CYGWIN__)
+#if (!defined(_WIN32) && !defined(__OS2__)) || defined (__CYGWIN__)
 #include <sched.h>
 #endif
 
@@ -355,6 +355,9 @@
   {
 #if defined (_WIN32) && !defined (__CYGWIN__)
     Sleep(0);
+#elif defined (__OS2__)
+    unsigned long _System DosSleep (unsigned long ulInterval);
+    DosSleep(0);
 #else
     sched_yield();
 #endif
diff -ur gcc-4.5.2-o/libstdc++-v3/libsupc++/typeinfo gcc-4.5.2/libstdc++-v3/libsupc++/typeinfo
--- gcc-4.5.2-o/libstdc++-v3/libsupc++/typeinfo	2010-02-19 04:28:52.000000000 +1030
+++ gcc-4.5.2/libstdc++-v3/libsupc++/typeinfo	2010-12-20 08:04:34.000000000 +1030
@@ -69,7 +69,7 @@
 
 // By default follow the old inline rules to avoid ABI changes.
 #ifndef __GXX_TYPEINFO_EQUALITY_INLINE
-  #if !__GXX_WEAK__
+  #if !__GXX_WEAK__ || (defined(__OS2__) && defined(__EMX__)) /* bird */
     #define __GXX_TYPEINFO_EQUALITY_INLINE 0
   #else
     #define __GXX_TYPEINFO_EQUALITY_INLINE 1
Only in gcc-4.5.2: libtool.gcc
Only in gcc-4.5.2: Makefile
diff -ur gcc-4.5.2-o/Makefile.in gcc-4.5.2/Makefile.in
--- gcc-4.5.2-o/Makefile.in	2010-06-11 02:35:58.000000000 +0930
+++ gcc-4.5.2/Makefile.in	2010-12-20 08:04:34.000000000 +1030
@@ -535,7 +535,7 @@
 
 LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
 LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
-LDFLAGS_FOR_TARGET = 
+LDFLAGS_FOR_TARGET = @LDFLAGS_FOR_BUILD@
 
 FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@
 SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
Only in gcc-4.5.2: patch.log
Only in gcc-4.5.2: serdep.tmp
diff -ur gcc-4.5.2-o/symlink-tree gcc-4.5.2/symlink-tree
--- gcc-4.5.2-o/symlink-tree	2005-07-14 10:38:12.000000000 +0930
+++ gcc-4.5.2/symlink-tree	2010-12-20 08:04:36.000000000 +1030
@@ -71,7 +71,8 @@
   else
     echo "$f		..linked"
     rm -f $f
-    ln -s ${srcdir}/$f .
+#    ln -s ${srcdir}/$f .
+    cp -p ${srcdir}/$f .
   fi
 done
 
Only in gcc-4.5.2: t
Only in gcc-4.5.2: TOP.LOG
gcc-4.5.2.diff (79,419 bytes)   
regex.pp.c (244,256 bytes)

Activities

dmik

2011-03-03 13:00

reporter   ~0001846

And here's the command line:

gcc -s -O3 -W -Wall -Wno-unused -Wno-parentheses -Wno-sign-compare -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -march=i486 -mtune=generic -Zomf -DJDK_MAJOR_VERSION='"1"' -DJDK_MINOR_VERSION='"6"' -DJDK_MICRO_VERSION='"0"' -DJDK_BUILD_NUMBER='"b19"' -I. -ID:/Coding/javaos2/openjdk/build-product-release/tmp/java/java.lang/java/CClassHeaders -I../../../src/windows/javavm/export -I../../../src/share/javavm/export -I../../../src/share/javavm/include -I../../../src/windows/javavm/include -I../../../src/share/native/java/lang/fdlibm/include -I../../../src/share/native/java/io -I../../../src/windows/native/java/io -I../../../src/windows/native/java/util -I../../../src/os2/native/common -I../../../src/os2/native/java/lang -I../../../src/share/native/common -I../../../src/windows/native/common -I../../../src/share/native/java/lang -I../../../src/windows/native/java/lang -Di586 -DARCH='"i586"' -DOS2 -D_LITTLE_ENDIAN -DRELEASE='"1.6.0-rc"' -D__WIN32OS2__ -D__i386__ -DSTRICT -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112 -D_EMX_SOURCE -D_XOPEN_SOURCE=600 -D_SVID_SOURCE -ID:/Coding/odin32/include/Win -ID:/Coding/odin32/include -DWINE_LARGE_INTEGER -DRELEASE='"1.6.0-rc"' -DARCHPROPNAME='"x86"' -c -o D:/Coding/javaos2/openjdk/build-product-release/tmp/java/java.lang/java/obj/java_props_md.obj ../../../src/windows/native/java/lang/java_props_md.c

dmik

2011-03-03 13:44

reporter   ~0001847

Note that in r269 (java SVN) I fixed all the above warnings and the crash still persists (the very same location). I'm attaching a preprocessed file here which you can compile to reproduce the problem on your own with just:

  gcc -c -Zomf java_props_md.pp.c

psmedley

2011-03-04 08:33

administrator   ~0001848

will see if I can find some time over the weekend to investigate the crash... according to the map file, the crash is happening in gcc's opts.c in function option_enabled()

psmedley

2011-03-06 05:25

administrator   ~0001850

As I'm not 100% sure when I'll have time to look at this, perhaps the updated GCC 4.4.5 (http://smedley.info/gcc-4.4.5-os2-20110122.zip) will help you get a Java release out - as this also has fixed exceptions suport (but requires the _new_ gcc445.dll)

tellerbop

2011-03-10 22:46

reporter   ~0001853

Hi,

tried just the ne editor to port, and i also get the error:

Killed by SIGSEGV
pid=0x76b2 ppid=0x76b0 tid=0x0001 slot=0x00c2 pri=0x0200 mc=0x0001
O:\USR\LOCAL445\LIBEXEC\GCC\I386-PC-OS2-EMX\4.4.5\CC1.EXE
CC1 0:001f9915
cs:eip=005b:00209915 ss:esp=0053:009bfa08 ebp=009bfa08
 ds=0053 es=0053 fs=150b gs=150b efl=00010206
eax=03142500 ebx=009bfad4 ecx=00000008 edx=00000000 edi=001718ab esi=00859fc0
Process dumping was disabled, use DUMPPROC / PROCDUMP to enable it.
gcc: Internal error: Segmentation fault (program cc1)
Please submit a full bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[1]: *** [regex.o] Error 1
make[1]: Leaving directory `O:/ne-2.2/src'
make.exe: *** [build] Error 2

But if i use the 4.4.5 i get not that error...

psmedley

2011-03-11 13:29

administrator   ~0001854

tellie, i'm confused by your report.

The crash you show indicated gcc 4.4.5, but then you say "But if i use the 4.4.5 i get not that error... "

tellerbop

2011-03-11 13:46

reporter   ~0001857

Hi Paul,

Sorry for the confusion, i have the 4.5.2 in the 4.4.5 thats cause otherwise i need to change my *.cmd file. So thats why it's says it's in the 4.4.5
So when i need the 4.4.5 i rename the 4.4.5 dir to 4.4.5_4.5.2
And then i rename the 4.4.5_4.4.5 to 4.4.5
I know it looks funny, but this works for me :)

psmedley

2011-03-12 08:25

administrator   ~0001858

Appears to be a problem with stdcall

Tellie's example is a little smaller/simpler.

The preprocessed code for regex.c has lots of:
     __attribute__ ((regparm (3), stdcall))

Removing these from the code stops gcc crashing.

Obviously, stdcall should be working, but at least it's a clue :)

Attaching gcc-4.4.5.diff gcc-4.5.2.diff and regex.pp.c to this ticket

psmedley

2011-03-12 08:27

administrator   ~0001859

Most stdcall handling is in gcc/config/i386/i386.c IIRC so starting there

psmedley

2011-03-12 08:38

administrator   ~0001860

Found some bad/old stuff in i386.c - rebuilding now

psmedley

2011-03-12 09:05

administrator   ~0001861

Please test new cc1.exe & cc1plus.exe - http://smedley.info/gcc452-fix-20110312.zip

tellerbop

2011-03-12 12:05

reporter   ~0001862

Hi Paul,

I tried it,and now no crash :P

Thankz i had a other program that had also this kind of crash with cc1, but cannot find that prog, have to look, and let you know, but thankz for fixing this :)

dmik

2011-03-14 10:12

reporter   ~0001863

Paul, great work! I will report back when I try to perform the full JDK build with the patched version to make sure it works on all files (this will take some time).

dmik

2011-03-26 17:45

reporter   ~0001867

I must confirm that the patched GCC works well. I could successfully build the whole JDK with it.

psmedley

2011-04-22 23:19

administrator   ~0001896

Resolved in latest GCC 4.5.2 drop

Issue History

Date Modified Username Field Change
2011-03-03 12:57 dmik New Issue
2011-03-03 13:00 dmik Note Added: 0001846
2011-03-03 13:44 dmik Note Added: 0001847
2011-03-03 13:46 dmik File Added: java_props_md.pp.c.zip
2011-03-04 08:33 psmedley Note Added: 0001848
2011-03-06 05:25 psmedley Note Added: 0001850
2011-03-10 22:46 tellerbop Note Added: 0001853
2011-03-11 13:29 psmedley Note Added: 0001854
2011-03-11 13:46 tellerbop Note Added: 0001857
2011-03-12 08:25 psmedley Note Added: 0001858
2011-03-12 08:25 psmedley File Added: gcc-4.4.5.diff
2011-03-12 08:26 psmedley File Added: gcc-4.5.2.diff
2011-03-12 08:26 psmedley File Added: regex.pp.c
2011-03-12 08:27 psmedley Note Added: 0001859
2011-03-12 08:38 psmedley Note Added: 0001860
2011-03-12 09:05 psmedley Note Added: 0001861
2011-03-12 09:05 psmedley Assigned To => psmedley
2011-03-12 09:05 psmedley Status new => feedback
2011-03-12 12:05 tellerbop Note Added: 0001862
2011-03-14 10:12 dmik Note Added: 0001863
2011-03-14 10:12 dmik Status feedback => assigned
2011-03-26 17:45 dmik Note Added: 0001867
2011-04-22 23:19 psmedley Note Added: 0001896
2011-04-22 23:19 psmedley Status assigned => closed
2011-04-22 23:19 psmedley Resolution open => fixed