diff mbox

RFC: Interix resurrection

Message ID 4F00C9C4.8090601@gnat.com
State New
Headers show

Commit Message

Douglas B Rupp Jan. 1, 2012, 9:01 p.m. UTC
This is for 32bit, "C" language only.
Tested by cross and then cross-native from x86_64 Linux

--Doug
2012-01-01  Douglas B Rupp  <rupp@gnat.com>

	<toplevel>/config/mh-interix: Remove as unneeded.
	<toplevel>/config/picflag.m4 (i[[34567]]86-*-interix3*):
	 Change triplet to i[[34567]]86-*-interix[[3-9]]*.
	<toplevel>libgcc/config.host (i[34567]86-*-interix3*):
	 Change triplet to i[34567]86-*-interix[3-9]*.
	<toplevel>/configure.ac: Remove reference to mh-interix.
	<toplevel>/configure: Regenerate.
	<toplevel>/libada/configure: Regenerate.
	<toplevel>/libgcc/configure: Regenerate.
	<toplevel>/liberty/configure: Regenerate.

	config.gcc: (i[34567]86-*-interix3*): Remove from obsolete
	 configurations. Change triplet to i[34567]86-*-interix[3-9]*.
	(extra_options) interix.opt -> i386/interix.opt"
	(extra_objs):Add winnt-stubs.o
	configure.ac: Add interix to target_os .comm on PE check.
	configure: Regenerate.
	config/interix3.h: Delete and move bits to..
	config/interix.h: Delete and move bits to..
	config/i386/i386-interix3.h: Delete and move bits to..
	config/i386/i386-interix.h: ..here.
	(TARGET_CPU_DEFAULT): Remove redefinition.
	(TARGET_ASM_CONSTRUCTOR): Undefine.
	(SUBTARGET_SWITCHES): Define for ms-bitfields.
	(TARGET_OS_CPP_BUILTINS): Remove __OPENNT. Add __declspec.
	(PTRDIFF_TYPE): Define.
	(LONG_DOUBLE_TYPE_SIZE): Define.
	(LIBGCC2_LONG_DOUBLE_TYPE_SIZE): Define.
	(SUBTARGET_OVERRIDE_OPTIONS): Remove.
	(TARGET_SECTION_TYPE_FLAGS): Define.
	(ASM_DECLARE_FUNCTION_NAME): Define.
	(ASM_OUTPUT_EXTERNAL): Define.
	(ASM_OUTPUT_EXTERNAL_LIBCALL): Define.
	(ASM_OUTPUT_ALIGNED_BSS): Define.
	(PCC_BITFIELD_TYPE_MATTERS): Define.
	(USE_CONST_SECTION): Define.
	(SUBTARGET_ENCODE_SECTION_INFO): Remove.
	(TARGET_ASM_FUNCTION_RODATA_SECTION): Remove.
	(SUPPORTS_ONE_ONLY): Remove.
	(I386_PE_STRIP_ENCODING): Define.
	config/interix.opt: Delete and move bits to..
	config/i386/interix.opt: ..here.
	(mpe-aligned-commons): Add.
	config/i386/t-interix: Add copyright header.
	(winnt-stubs.o): Add rule.
	testsuite/gcc.dg/builtins-config.h: (HAVE_C99_RUNTIME):
	 Do not define for Interix.

Comments

Douglas B Rupp Jan. 22, 2012, 6:20 a.m. UTC | #1
Ping.
Patch retested with 1/18/2012 sources.

On 1/1/2012 1:01 PM, Douglas Rupp wrote:
> This is for 32bit, "C" language only.
> Tested by cross and then cross-native from x86_64 Linux
>
> --Doug
>
Paolo Bonzini Jan. 22, 2012, 12:41 p.m. UTC | #2
On 01/01/2012 10:01 PM, Douglas Rupp wrote:
> -    i[[34567]]86-*-interix3*)
> +    i[[34567]]86-*-interix[[3-9]]*)
>   	# Interix 3.x gcc -fpic/-fPIC options generate broken code.
>   	# Instead, we relocate shared libraries at runtime.
>   	;;

Is this still true?

Build parts are ok.

Paolo
Douglas B Rupp Jan. 22, 2012, 9:16 p.m. UTC | #3
On 1/22/2012 4:41 AM, Paolo Bonzini wrote:
> On 01/01/2012 10:01 PM, Douglas Rupp wrote:
>> -    i[[34567]]86-*-interix3*)
>> +    i[[34567]]86-*-interix[[3-9]]*)
>>       # Interix 3.x gcc -fpic/-fPIC options generate broken code.
>>       # Instead, we relocate shared libraries at runtime.
>>       ;;
>
> Is this still true?
>
> Build parts are ok.
>
> Paolo
>
Thanks.
May I regenerate libiberty/configure and check it in, or does that 
require a libiberty maintainer?

Regarding your question(s)
I believe -fpic/PIC is still broken on Interix but I'll have to dig into 
some old notes to clarify the reason.
The comment about shared library relocation is still true.
Paolo Bonzini Jan. 23, 2012, 7:31 a.m. UTC | #4
On 01/22/2012 10:16 PM, Douglas Rupp wrote:
>
> May I regenerate libiberty/configure and check it in, or does that
> require a libiberty maintainer?

Yes, regenerate everything that is affected.

Paolo
diff mbox

Patch

--- gcc.old/config/mh-interix	2011-12-10 12:49:59.000000000 -0800
+++ gcc/config/mh-interix	1969-12-31 16:00:00.000000000 -0800
@@ -1,2 +0,0 @@ 
-# The shell may not be in /bin. 
-SHELL = sh
--- gcc.old/config/picflag.m4	2011-12-10 12:49:59.000000000 -0800
+++ gcc/config/picflag.m4	2011-12-31 18:32:37.000000000 -0800
@@ -19,7 +19,7 @@  case "${$2}" in
 	;;
     i[[34567]]86-*-cygwin* | i[[34567]]86-*-mingw* | x86_64-*-mingw*)
 	;;
-    i[[34567]]86-*-interix3*)
+    i[[34567]]86-*-interix[[3-9]]*)
 	# Interix 3.x gcc -fpic/-fPIC options generate broken code.
 	# Instead, we relocate shared libraries at runtime.
 	;;
--- gcc.old/libgcc/config.host	2011-12-10 12:56:00.000000000 -0800
+++ gcc/libgcc/config.host	2011-12-19 18:21:15.000000000 -0800
@@ -634,7 +634,7 @@  x86_64-*-mingw*)
 	tmake_file="${tmake_file} ${tmake_eh_file} ${tmake_dlldir_file} i386/t-slibgcc-cygming i386/t-mingw32 t-dfprules i386/t-crtfm i386/t-chkstk"
 	extra_parts="$extra_parts crtfastmath.o"
 	;;
-i[34567]86-*-interix3*)
+i[34567]86-*-interix[3-9]*)
 	tmake_file="$tmake_file i386/t-interix i386/t-chkstk"
 	;;
 ia64*-*-elf*)
--- gcc.old/configure.ac	2011-12-10 13:06:46.000000000 -0800
+++ gcc/configure.ac	2011-12-12 19:04:46.000000000 -0800
@@ -1077,9 +1079,6 @@  case "${host}" in
   *-mingw*)
     host_makefile_frag="config/mh-mingw"
     ;;
-  *-interix*)
-    host_makefile_frag="config/mh-interix"
-    ;;
   hppa*-hp-hpux10*)
     host_makefile_frag="config/mh-pa-hpux10"
     ;;
--- gcc.old/gcc/config.gcc	2011-12-10 13:05:49.000000000 -0800
+++ gcc/gcc/config.gcc	2011-12-31 18:25:02.000000000 -0800
@@ -243,7 +243,6 @@  md_file=
 # Obsolete configurations.
 case ${target} in
    alpha*-dec-osf5.1*			\
- | i[34567]86-*-interix3*		\
  | mips-sgi-irix6.5			\
  | mips*-*-openbsd*			\
  | score-*				\
@@ -1472,11 +1471,11 @@  i[34567]86-*-mingw* | x86_64-*-mingw*)
 			;;
 	esac
 	;;
-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"
+i[34567]86-*-interix[3-9]*)
+	tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/i386-interix.h"
 	tmake_file="${tmake_file} i386/t-interix"
-	extra_options="${extra_options} rpath.opt interix.opt"
-	extra_objs=winnt.o
+	extra_options="${extra_options} rpath.opt i386/interix.opt"
+	extra_objs="winnt.o winnt-stubs.o"
 	target_gtfiles="\$(srcdir)/config/i386/winnt.c"
 	if test x$enable_threads = xyes ; then
 		thread_file='posix'
--- gcc.old/gcc/configure.ac	2011-12-10 13:05:49.000000000 -0800
+++ gcc/gcc/configure.ac	2011-12-12 18:55:08.000000000 -0800
@@ -3537,7 +3537,7 @@  changequote([,])dnl
 	   Cygwin DLL exports wrappers to support libstdc++ function replacement.])
     esac
     case $target_os in
-      cygwin* | pe | mingw32*)
+      cygwin* | pe | mingw32* | interix*)
 	# Recent binutils allows the three-operand form of ".comm" on PE.  This
 	# definition is used unconditionally to initialise the default state of
 	# the target option variable that governs usage of the feature.
--- gcc.old/gcc/config/interix3.h	2011-12-10 13:05:46.000000000 -0800
+++ gcc/gcc/config/interix3.h	1969-12-31 16:00:00.000000000 -0800
@@ -1,34 +0,0 @@ 
-/* Operating system specific defines to be used when targeting GCC for
-   Interix version 3.
-   Copyright (C) 2001, 2007 Free Software Foundation, Inc.
-   Contributed by Douglas B. Rupp (rupp@gnat.com)
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-/* Interix 3.x has a single rooted file system and properly named
-   libraries, so LIB_SPEC can be simplified */
-
-#undef LIB_SPEC
-#define LIB_SPEC "\
- %{!shared:%{!dynamic:-lc -lpsxdll \
- }} \
- %{!G:%{!dynamic:-lc -lpsxdll \
- }} \
- %{dynamic:-lc -lpsxdll \
- } \
- %{v}"
-
--- gcc.old/gcc/config/interix.h	2011-12-10 13:05:46.000000000 -0800
+++ gcc/gcc/config/interix.h	1969-12-31 16:00:00.000000000 -0800
@@ -1,110 +0,0 @@ 
-/* Operating system specific defines to be used when targeting GCC for
-   Interix
-   Copyright (C) 1994, 1995, 1999, 2002, 2004, 2007, 2010
-   Free Software Foundation, Inc.
-   Donn Terry, Softway Systems, Inc. (donn@softway.com)
-   Modified from code
-      Contributed by Douglas B. Rupp (drupp@cs.washington.edu).
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-/* POSIX/Uni-thread only for now.  Look at the winnt version
-for windows/multi thread */
-
-/* We need multiple -lc -lcpsx because they mutually refer;
-   that should go away someday */
-
-#undef LIB_SPEC
-#define LIB_SPEC "\
- %{!shared:%{!dynamic:-lc -lcpsx -lc -lcpsx %$INTERIX_ROOT/usr/lib/psxdll.a \
- %$INTERIX_ROOT/usr/lib/psxdll2.a \
- }} \
- %{!G:%{!dynamic:-lc -lcpsx -lc -lcpsx %$INTERIX_ROOT/usr/lib/psxdll.a \
- %$INTERIX_ROOT/usr/lib/psxdll2.a \
- }} \
- %{dynamic:-lc %$INTERIX_ROOT/usr/lib/psxdll.a \
- %$INTERIX_ROOT/usr/lib/psxdll2.a \
- } \
- %{v}"
-
-#undef LINK_SPEC
-#define LINK_SPEC "%{!shared:-stack 0x400000,0x10000} \
- 		   -subsystem posix \
-		   %{g} \
-		   %{dynamic:-Bdynamic} \
-		   %{static:-Bstatic} \
-		   %{shared:--shared -Bdynamic} \
-		   %{G:--shared -Bdynamic} \
-		   %{symbolic:--shared -Bsymbolic -Bdynamic} \
-   		   %{rpath*:--rpath %*} \
-		   "
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC  \
-  "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}} %{shared:crti%O%s}"
-
-
-#define STDC_0_IN_SYSTEM_HEADERS 1
-
-/* Names to predefine in the preprocessor for this target machine.  */
-
-#define DBX_DEBUGGING_INFO 1
-#define SDB_DEBUGGING_INFO 1
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-
-/* TARGET_DEFAULT from configure */
-
-#undef WCHAR_TYPE
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE "short unsigned int"
-#define WCHAR_TYPE_SIZE 16
-
-/* Our strategy for finding global constructors is a bit different, although
-   not a lot.  */
-#define DO_GLOBAL_CTORS_BODY						\
-do {									\
-  int i;								\
-  unsigned long nptrs;							\
-  func_ptr *p;								\
-  asm(									\
-       "     .section .ctor_head, \"rw\"\n"				\
-       "1:\n"								\
-       "     .text \n"							\
-       ASM_LOAD_ADDR(1b,%0)						\
-       : "=r" (p) : : "cc");						\
-  for (nptrs = 0; p[nptrs] != 0; nptrs++);				\
-  for (i = nptrs-1; i >= 0; i--)					\
-    p[i] ();								\
-} while (0) 
-
-#define DO_GLOBAL_DTORS_BODY						\
-do {									\
-  func_ptr *p;								\
-  asm(									\
-       "     .section .dtor_head, \"rw\"\n"				\
-       "1:\n"								\
-       "     .text \n"							\
-       ASM_LOAD_ADDR(1b,%0)						\
-       : "=r" (p) : : "cc");						\
-  while (*p)								\
-    {									\
-      p++;								\
-      (*(p-1)) ();							\
-    }									\
-} while (0) 
--- gcc.old/gcc/config/i386/i386-interix3.h	2011-12-10 13:05:19.000000000 -0800
+++ gcc/gcc/config/i386/i386-interix3.h	1969-12-31 16:00:00.000000000 -0800
@@ -1,23 +0,0 @@ 
-/* Target definitions for GCC for Intel 80386 running Interix V3.
-   Copyright (C) 2001, 2007 Free Software Foundation, Inc.
-   Contributed by Douglas B. Rupp (rupp@gnat.com)
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-<http://www.gnu.org/licenses/>.  */
-
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
-
--- gcc.old/gcc/config/i386/i386-interix.h	2011-12-10 13:05:19.000000000 -0800
+++ gcc/gcc/config/i386/i386-interix.h	2011-12-31 18:18:09.000000000 -0800
@@ -24,31 +24,84 @@  You should have received a copy of the G
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-/* The rest must follow.  */
+/* Note: Interix doesn't support user-written DLLs (use conventional
+   shared libs (.so) instead).  Thus a lot of the stuff that might apply
+   about dllimport/dllexport and the like does not apply here. */
+
+#include <stdio.h>
+
+/* Names to predefine in the preprocessor for this target machine.  */
 
 #define DBX_DEBUGGING_INFO 1
 #define SDB_DEBUGGING_INFO 1
 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
 
-/* By default, target has a 80387, uses IEEE compatible arithmetic,
-   and returns float values in the 387 and needs stack probes
-   We also align doubles to 64-bits for MSVC default compatibility
-   We do bitfields MSVC-compatibly by default, too.  */
-#undef TARGET_SUBTARGET_DEFAULT
-#define TARGET_SUBTARGET_DEFAULT \
-   (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \
-    MASK_ALIGN_DOUBLE | MASK_MS_BITFIELD_LAYOUT)
-
-#undef TARGET_CPU_DEFAULT
-#define TARGET_CPU_DEFAULT TARGET_CPU_DEFAULT_i486
+/* Our strategy for finding global constructors is a bit different, although
+   not a lot.  */
+#define DO_GLOBAL_CTORS_BODY						\
+do {									\
+  int i;								\
+  unsigned long nptrs;							\
+  func_ptr *p;								\
+  asm(									\
+       "     .section .ctor_head, \"rw\"\n"				\
+       "1:\n"								\
+       "     .text \n"							\
+       ASM_LOAD_ADDR(1b,%0)						\
+       : "=r" (p) : : "cc");						\
+  for (nptrs = 0; p[nptrs] != 0; nptrs++);				\
+  for (i = nptrs-1; i >= 0; i--)					\
+    p[i] ();								\
+} while (0)
 
-#define WCHAR_TYPE_SIZE 16
-#define WCHAR_TYPE "short unsigned int"
+#define DO_GLOBAL_DTORS_BODY						\
+do {									\
+  func_ptr *p;								\
+  asm(									\
+       "     .section .dtor_head, \"rw\"\n"				\
+       "1:\n"								\
+       "     .text \n"							\
+       ASM_LOAD_ADDR(1b,%0)						\
+       : "=r" (p) : : "cc");						\
+  while (*p)								\
+    {									\
+      p++;								\
+      (*(p-1)) ();							\
+    }									\
+} while (0)
 
-/* WinNT (and thus Interix) use unsigned int */
-#define SIZE_TYPE "unsigned int"
+/* We don't use the "usual" push-an-address solution. */
+#undef TARGET_ASM_CONSTRUCTOR
 
-#define ASM_LOAD_ADDR(loc, reg)   "     leal " #loc "," #reg "\n"
+#undef  SUBTARGET_SWITCHES
+#define SUBTARGET_SWITCHES \
+{ "ms-bitfields", MASK_MS_BITFIELD_LAYOUT, N_("Use native (MS) bitfield layout") }, \
+{ "no-ms-bitfields", -MASK_MS_BITFIELD_LAYOUT, N_("Use gcc default bitfield layout") },
+
+#undef LIB_SPEC
+#define LIB_SPEC "\
+ %{!shared:%{!dynamic:-lc -lpsxdll \
+ }} \
+ %{!G:%{!dynamic:-lc -lpsxdll \
+ }} \
+ %{dynamic:-lc -lpsxdll \
+ } \
+ %{v}"
+
+#undef LINK_SPEC
+#define LINK_SPEC "%{!shared:-stack 0x4000000,0x10000} \
+		   %{g} \
+		   %{dynamic:-Bdynamic} \
+		   %{static:-Bstatic} \
+		   %{shared:--shared -Bdynamic} \
+		   %{G:--shared -Bdynamic} \
+		   %{symbolic:--shared -Bsymbolic -Bdynamic} \
+   		   %{rpath*:--rpath %*} \
+		   "
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC  \
+  "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}}} %{shared:crti%O%s}"
 
 #define TARGET_DECLSPEC 1
 
@@ -57,11 +110,11 @@  along with GCC; see the file COPYING3.  
   do									\
     {									\
 	builtin_define ("__INTERIX");					\
-	builtin_define ("__OPENNT");					\
 	builtin_define ("_M_IX86=300");					\
 	builtin_define ("_X86_=1");					\
 	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
 	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
+	builtin_define ("__declspec(x)=__attribute__((x))");		\
 	builtin_assert ("system=unix");					\
 	builtin_assert ("system=interix");				\
 	if (preprocessing_asm_p ())					\
@@ -78,153 +131,18 @@  along with GCC; see the file COPYING3.  
   while (0)
 
 #undef CPP_SPEC
-/* Write out the correct language type definition for the header files.  
-   Unless we have assembler language, write out the symbols for C.
-   mieee is an Alpha specific variant.  Cross pollination a bad idea.
-   */
-#define CPP_SPEC "-remap %{posix:-D_POSIX_SOURCE} \
--isystem %$INTERIX_ROOT/usr/include"
-
-/* The global __fltused is necessary to cause the printf/scanf routines
-   for outputting/inputting floating point numbers to be loaded.  Since this
-   is kind of hard to detect, we just do it all the time.  */
-#undef X86_FILE_START_FLTUSED
-#define X86_FILE_START_FLTUSED 1
-
-/* A table of bytes codes used by the ASM_OUTPUT_ASCII and
-   ASM_OUTPUT_LIMITED_STRING macros.  Each byte in the table
-   corresponds to a particular byte value [0..255].  For any
-   given byte value, if the value in the corresponding table
-   position is zero, the given character can be output directly.
-   If the table value is 1, the byte must be output as a \ooo
-   octal escape.  If the tables value is anything else, then the
-   byte value should be output as a \ followed by the value
-   in the table.  Note that we can use standard UN*X escape
-   sequences for many control characters, but we don't use
-   \a to represent BEL because some svr4 assemblers (e.g. on
-   the i386) don't know about that.  Also, we don't use \v
-   since some versions of gas, such as 2.2 did not accept it.  */
-
-#define ESCAPES \
-"\1\1\1\1\1\1\1\1btn\1fr\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
-\0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
-\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0\
-\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\
-\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
-\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
-\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\
-\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"
-
-/* Some svr4 assemblers have a limit on the number of characters which
-   can appear in the operand of a .string directive.  If your assembler
-   has such a limitation, you should define STRING_LIMIT to reflect that
-   limit.  Note that at least some svr4 assemblers have a limit on the
-   actual number of bytes in the double-quoted string, and that they
-   count each character in an escape sequence as one byte.  Thus, an
-   escape sequence like \377 would count as four bytes.
-
-   If your target assembler doesn't support the .string directive, you
-   should define this to zero.
-*/
-
-#define STRING_LIMIT	((unsigned) 256)
-
-#define STRING_ASM_OP	"\t.string\t"
-
-/* The routine used to output NUL terminated strings.  We use a special
-   version of this for most svr4 targets because doing so makes the
-   generated assembly code more compact (and thus faster to assemble)
-   as well as more readable, especially for targets like the i386
-   (where the only alternative is to output character sequences as
-   comma separated lists of numbers).  */
-
-#define ASM_OUTPUT_LIMITED_STRING(FILE, STR)				\
-  do									\
-    {									\
-      const unsigned char *_limited_str =				\
-        (const unsigned char *) (STR);					\
-      unsigned ch;							\
-      fprintf ((FILE), "%s\"", STRING_ASM_OP);				\
-      for (; (ch = *_limited_str); _limited_str++)			\
-        {								\
-	  int escape = ESCAPES[ch];					\
-	  switch (escape)						\
-	    {								\
-	    case 0:							\
-	      putc (ch, (FILE));					\
-	      break;							\
-	    case 1:							\
-	      fprintf ((FILE), "\\%03o", ch);				\
-	      break;							\
-	    default:							\
-	      putc ('\\', (FILE));					\
-	      putc (escape, (FILE));					\
-	      break;							\
-	    }								\
-        }								\
-      fprintf ((FILE), "\"\n");						\
-    }									\
-  while (0)
-
-/* The routine used to output sequences of byte values.  We use a special
-   version of this for most svr4 targets because doing so makes the
-   generated assembly code more compact (and thus faster to assemble)
-   as well as more readable.  Note that if we find subparts of the
-   character sequence which end with NUL (and which are shorter than
-   STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING.  */
-
-#undef ASM_OUTPUT_ASCII
-#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)				\
-  do									\
-    {									\
-      const unsigned char *_ascii_bytes =				\
-        (const unsigned char *) (STR);					\
-      const unsigned char *limit = _ascii_bytes + (LENGTH);		\
-      unsigned bytes_in_chunk = 0;					\
-      for (; _ascii_bytes < limit; _ascii_bytes++)			\
-        {								\
-	  const unsigned char *p;					\
-	  if (bytes_in_chunk >= 64)					\
-	    {								\
-	      fputc ('\n', (FILE));					\
-	      bytes_in_chunk = 0;					\
-	    }								\
-	  for (p = _ascii_bytes; p < limit && *p != '\0'; p++)		\
-	    continue;							\
-	  if (p < limit && (p - _ascii_bytes) <= (long) STRING_LIMIT)	\
-	    {								\
-	      if (bytes_in_chunk > 0)					\
-		{							\
-		  fputc ('\n', (FILE));					\
-		  bytes_in_chunk = 0;					\
-		}							\
-	      ASM_OUTPUT_LIMITED_STRING ((FILE), _ascii_bytes);		\
-	      _ascii_bytes = p;						\
-	    }								\
-	  else								\
-	    {								\
-	      if (bytes_in_chunk == 0)					\
-		fputs (ASM_BYTE, (FILE));				\
-	      else							\
-		fputc (',', (FILE));					\
-	      fprintf ((FILE), "0x%02x", *_ascii_bytes);		\
-	      bytes_in_chunk += 5;					\
-	    }								\
-	}								\
-      if (bytes_in_chunk > 0)						\
-        fputc ('\n', (FILE));						\
-    }									\
-  while (0)
-
-/* Emit code to check the stack when allocating more that 4000
-   bytes in one go.  */
+#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
 
-#define CHECK_STACK_LIMIT 0x1000
+#define SIZE_TYPE "unsigned int"
+#define PTRDIFF_TYPE "int"
+#define WCHAR_TYPE "short unsigned int"
+#define WCHAR_TYPE_SIZE 16
 
-/* the following are OSF linker (not gld) specific... we don't want them */
-#undef HAS_INIT_SECTION
-#undef LD_INIT_SWITCH
-#undef LD_FINI_SWITCH
+/* Turn off long double being 96 bits.  */
+#undef LONG_DOUBLE_TYPE_SIZE
+#define LONG_DOUBLE_TYPE_SIZE 64
+#undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
+#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
 
 /* The following are needed for us to be able to use winnt.c, but are not
    otherwise meaningful to Interix.  (The functions that use these are
@@ -232,42 +150,125 @@  along with GCC; see the file COPYING3.  
 #define TARGET_NOP_FUN_DLLIMPORT 1
 #define drectve_section()  /* nothing */
 
-/* Objective-C has its own packing rules...
-   Objc tries to parallel the code in stor-layout.c at runtime	
-   (see libobjc/encoding.c).  This (compile-time) packing info isn't 
-   available at runtime, so it's hopeless to try.
-
-   And if the user tries to set the flag for objc, give an error
-   so he has some clue.  */
-
-#undef  SUBTARGET_OVERRIDE_OPTIONS
-#define SUBTARGET_OVERRIDE_OPTIONS					\
-do {									\
-  if (strcmp (lang_hooks.name, "GNU Objective-C") == 0)			\
-    {									\
-      if ((target_flags & MASK_MS_BITFIELD_LAYOUT) != 0			\
-	  && (target_flags_explicit & MASK_MS_BITFIELD_LAYOUT) != 0)	\
-	{								\
-	   error ("ms-bitfields not supported for objc");		\
-	}								\
-      target_flags &= ~MASK_MS_BITFIELD_LAYOUT;				\
-    }									\
-} while (0)
 
 #define EH_FRAME_IN_DATA_SECTION
 
 #define READONLY_DATA_SECTION_ASM_OP	"\t.section\t.rdata,\"r\""
 
+/* Define this macro if references to a symbol must be treated
+   differently depending on something about the variale or
+   function named by the symbol (such as what section it is in).  */
+
+#undef TARGET_ENCODE_SECTION_INFO
+#define TARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info
+#undef  TARGET_STRIP_NAME_ENCODING
+#define TARGET_STRIP_NAME_ENCODING  i386_pe_strip_name_encoding_full
+
+/* Emit code to check the stack when allocating more that 4000
+   bytes in one go.  */
+
+#define CHECK_STACK_LIMIT 4000
+
+/* By default, target has a 80387, uses IEEE compatible arithmetic,
+   and returns float values in the 387 and needs stack probes
+   We also align doubles to 64-bits forMSVC default compatibility
+   Ditto for bitfields. */
+#undef TARGET_SUBTARGET_DEFAULT
+#define TARGET_SUBTARGET_DEFAULT \
+   (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE | \
+    MASK_ALIGN_DOUBLE | MASK_MS_BITFIELD_LAYOUT)
+
 /* The MS compilers take alignment as a number of bytes, so we do as well */
 #undef ASM_OUTPUT_ALIGN
 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
   if ((LOG)!=0) fprintf ((FILE), "\t.balign %d\n", 1<<(LOG))
 
+
+/* Define this macro if in some cases global symbols from one translation
+   unit may not be bound to undefined symbols in another translation unit
+   without user intervention.  For instance, under Microsoft Windows
+   symbols must be explicitly imported from shared libraries (DLLs).  */
+/*
+ * Old gcc(3.3) did not have 1 here
+ */
+#define MULTIPLE_SYMBOL_SPACES	1
+
+extern void i386_pe_unique_section PARAMS ((tree, int));
+#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
+
+/* Switch into a generic section.  */
+#define TARGET_ASM_NAMED_SECTION  default_pe_asm_named_section
+
+/* Select attributes for named sections.  */
+#define TARGET_SECTION_TYPE_FLAGS  i386_pe_section_type_flags
+
+/* Write the extra assembler code needed to declare a function
+   properly.  If we are generating SDB debugging information, this
+   will happen automatically, so we only need to handle other cases.  */
+#undef ASM_DECLARE_FUNCTION_NAME
+#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)			\
+  do									\
+    {									\
+      if (write_symbols != SDB_DEBUG)					\
+       i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL));	\
+      ASM_OUTPUT_LABEL (FILE, NAME);       				\
+    }									\
+  while (0)
+
+/* Add an external function to the list of functions to be declared at
+   the end of the file.  */
+#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)				\
+  do									\
+    {									\
+      if (TREE_CODE (DECL) == FUNCTION_DECL)				\
+        i386_pe_record_external_function (DECL, NAME);			\
+    }									\
+  while (0)
+
+/* Declare the type properly for any external libcall.  */
+#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
+  i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
+
+/* This says out to put a global symbol in the BSS section.  */
+#undef ASM_OUTPUT_ALIGNED_BSS
+#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
+  asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
+
+/* Don't assume anything about the header files.  */
+#define NO_IMPLICIT_EXTERN_C
+
+/* External function declarations.  */
+extern void i386_pe_record_external_function (tree, const char *);
+extern void i386_pe_declare_function_type (FILE *, const char *, int);
+extern void i386_pe_record_exported_symbol (const char *, int);
+extern void i386_pe_asm_file_end (FILE *);
+
+/* For Win32 ABI compatibility */
+#undef DEFAULT_PCC_STRUCT_RETURN
+#define DEFAULT_PCC_STRUCT_RETURN 0
+
+/* A bitfield declared as `int' forces `int' alignment for the struct.  */
+#undef PCC_BITFIELD_TYPE_MATTERS
+#define PCC_BITFIELD_TYPE_MATTERS 1
+
+/* Enable alias attribute support.  */
+#ifndef SET_ASM_OP
+#define SET_ASM_OP "\t.set\t"
+#endif
+
+/* Note that there appears to be two different ways to support const
+   sections at the moment.  You can either #define the symbol
+   READONLY_DATA_SECTION (giving it some code which switches to the
+   readonly data section) or else you can #define the symbols
+   EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
+   SELECT_RTX_SECTION.  We do both here just to be on the safe side.  */
+
+#define USE_CONST_SECTION 1
+
 /* The linker will take care of this, and having them causes problems with
    ld -r (specifically -rU).  */
 #define CTOR_LISTS_DEFINED_EXTERNALLY 1
 
-#define SET_ASM_OP	"\t.set\t"
 /* Output a definition (implements alias) */
 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)				\
 do									\
@@ -288,68 +289,56 @@  while (0)
 
 /* Forward references to tags are allowed.  */
 #define SDB_ALLOW_FORWARD_REFERENCES
-
 /* Unknown tags are also allowed.  */
 #define SDB_ALLOW_UNKNOWN_REFERENCES
+/* DWARF2 Unwinding doesn't work with exception handling yet.  */
+#define DWARF2_UNWIND_INFO 0
+/* MSVC returns structs of up to 8 bytes via registers. */
+
+#undef SUBTARGET_RETURN_IN_MEMORY
+#define SUBTARGET_RETURN_IN_MEMORY(TYPE, FNTYPE) \
+  (TYPE_MODE (TYPE) == BLKmode || \
+     (AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes(TYPE) > 8 ))
+
+#define ASM_LOAD_ADDR(loc, reg)   "     leal " #loc "," #reg "\n"
 
 /* The integer half of this list needs to be constant.  However, there's
    a lot of disagreement about what the floating point adjustments should
    be.  We pick one that works with gdb.  (The underlying problem is
    what to do about the segment registers.  Since we have access to them
    from /proc, we'll allow them to be accessed in gdb, even tho the
-   gcc compiler can't generate them.  (There's some evidence that 
-   MSVC does, but possibly only for certain special "canned" sequences.) */
+   gcc compiler can't generate them.  (There's some evidence that
+   MSVC does, but possibly only for certain special "canned" sequences.)  */
 
 #undef DBX_REGISTER_NUMBER
 #define DBX_REGISTER_NUMBER(n) \
 (TARGET_64BIT ? dbx64_register_map[n] \
- : (n) == 0 ? 0 \
- : (n) == 1 ? 2 \
- : (n) == 2 ? 1 \
- : (n) == 3 ? 3 \
- : (n) == 4 ? 6 \
- : (n) == 5 ? 7 \
- : (n) == 6 ? 5 \
- : (n) == 7 ? 4 \
- : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+8 \
- : (-1))
-
-/* Define this macro if references to a symbol must be treated
-   differently depending on something about the variable or
-   function named by the symbol (such as what section it is in).  */
-
-#define SUBTARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info
-#undef  TARGET_STRIP_NAME_ENCODING
-#define TARGET_STRIP_NAME_ENCODING  i386_pe_strip_name_encoding_full
-
-#if 0	
-/* Turn this back on when the linker is updated to handle grouped
-   .data$ sections correctly. See corresponding note in i386/interix.c. 
-   MK.  */
+ : (n) == 0 ? (int) 0 \
+ : (n) == 1 ? (int) 2 \
+ : (n) == 2 ? (int) 1 \
+ : (n) == 3 ? (int) 3 \
+ : (n) == 4 ? (int) 6 \
+ : (n) == 5 ? (int) 7 \
+ : (n) == 6 ? (int) 5 \
+ : (n) == 7 ? (int) 4 \
+ : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (int) (n)+8 \
+ : (int) (-1))
 
-/* Interix uses explicit import from shared libraries.  */
-#define MULTIPLE_SYMBOL_SPACES 1
-
-extern void i386_pe_unique_section (tree, int);
-#define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
-#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
-
-#define SUPPORTS_ONE_ONLY 1
-#endif /* 0 */
-
-/* Switch into a generic section.  */
-#define TARGET_ASM_NAMED_SECTION  default_pe_asm_named_section
-
-/* DWARF2 Unwinding doesn't work with exception handling yet.  */
-#define DWARF2_UNWIND_INFO 0
+#define EH_FRAME_IN_DATA_SECTION
 
-/* Don't assume anything about the header files.  */
-#define NO_IMPLICIT_EXTERN_C
+/* the following are OSF linker (not gld) specific... we don't want them */
+#undef HAS_INIT_SECTION
+#undef LD_INIT_SWITCH
+#undef LD_FINI_SWITCH
 
-/* MSVC returns structs of up to 8 bytes via registers.  */
+/* The following are needed for us to be able to use winnt.c, but are not
+   otherwise meaningful to Interix.  (The functions that use these are
+   never called because we don't do DLLs.) */
+#define TARGET_NOP_FUN_DLLIMPORT 1
+#define I386_PE_STRIP_ENCODING(SYM_NAME) \
+  ((SYM_NAME) + ((SYM_NAME)[0] == '@' \
+                 ? ((SYM_NAME)[3] == '*' ? 4 : 3) : 0) \
+             + ((SYM_NAME)[0] == '*' ? 1 : 0))
 
-#define DEFAULT_PCC_STRUCT_RETURN 0
+#define drectve_section()  /* nothing */
 
-#define SUBTARGET_RETURN_IN_MEMORY(TYPE, FNTYPE) \
-	(TYPE_MODE (TYPE) == BLKmode \
-	 || (AGGREGATE_TYPE_P (TYPE) && int_size_in_bytes (TYPE) > 8 ))
--- gcc.old/gcc/config/interix.opt	2011-12-10 13:05:46.000000000 -0800
+++ gcc/gcc/config/interix.opt	1969-12-31 16:00:00.000000000 -0800
@@ -1,36 +0,0 @@ 
-; Interix options.
-
-; Copyright (C) 2010, 2011
-; Free Software Foundation, Inc.
-;
-; This file is part of GCC.
-;
-; GCC is free software; you can redistribute it and/or modify it under
-; the terms of the GNU General Public License as published by the Free
-; Software Foundation; either version 3, or (at your option) any later
-; version.
-;
-; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-; WARRANTY; without even the implied warranty of MERCHANTABILITY or
-; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-; for more details.
-;
-; You should have received a copy of the GNU General Public License
-; along with GCC; see the file COPYING3.  If not see
-; <http://www.gnu.org/licenses/>.
-
-; See the GCC internals manual (options.texi) for a description of
-; this file's format.
-
-; Please try to keep this file in ASCII collating order.
-
-dynamic
-Driver
-
-G
-Driver
-
-posix
-Driver
-
-; This comment is to ensure we retain the blank line above.
--- gcc.old/gcc/config/i386/interix.opt	1969-12-31 16:00:00.000000000 -0800
+++ gcc/gcc/config/i386/interix.opt	2011-12-23 18:35:18.000000000 -0800
@@ -0,0 +1,34 @@ 
+; Interix-specific options.
+
+; Copyright (C) 2005, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+dynamic
+Driver
+
+G
+Driver
+
+posix
+Driver
+
+mpe-aligned-commons
+Target Var(use_pe_aligned_common) Init(HAVE_GAS_ALIGNED_COMM)
+Use the GNU extension to the PE format for aligned common data
+
+; This comment is to ensure we retain the blank line above.
--- gcc.old/gcc/config/i386/t-interix	2011-12-10 13:05:19.000000000 -0800
+++ gcc/gcc/config/i386/t-interix	2011-12-31 13:39:46.000000000 -0800
@@ -1,5 +1,31 @@ 
+# Copyright (C) 2011
+# Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
 winnt.o: $(srcdir)/config/i386/winnt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
   $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \
   $(TM_P_H) $(HASHTAB_H) $(GGC_H)
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 		$(srcdir)/config/i386/winnt.c
+
+winnt-stubs.o: $(srcdir)/config/i386/winnt-stubs.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
+  $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \
+  $(TM_P_H) toplev.h $(HASHTAB_H) $(GGC_H)
+	$(COMPILER) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
+	$(srcdir)/config/i386/winnt-stubs.c
+
--- gcc.old/gcc/testsuite/gcc.dg/builtins-config.h	2011-12-10 12:59:53.000000000 -0800
+++ gcc/gcc/testsuite/gcc.dg/builtins-config.h	2011-12-19 18:17:44.000000000 -0800
@@ -11,6 +11,8 @@ 
 
 #if defined(__hppa) && defined(__hpux)
 /* PA HP-UX doesn't have the entire C99 runtime.  */
+#elif defined(__INTERIX)
+/* Interix6 doesn't have the entire C99 runtime.  */
 #elif defined(__AVR__)
 /* AVR doesn't have the entire C99 runtime.  */
 #elif defined(__FreeBSD__) && (__FreeBSD__ < 9)