diff --git a/lang/gcc/4.2/Makefile b/lang/gcc/4.2/Makefile
index ed810136119..46b8d6b6d15 100644
--- a/lang/gcc/4.2/Makefile
+++ b/lang/gcc/4.2/Makefile
@@ -1,6 +1,8 @@
-# $OpenBSD: Makefile,v 1.50 2010/10/18 19:20:41 espie Exp $
+# $OpenBSD: Makefile,v 1.51 2010/10/29 08:50:38 naddy Exp $
-ONLY_FOR_ARCHS = alpha i386 m68k sparc sparc64 powerpc vax amd64
+ONLY_FOR_ARCHS = i386 m68k sparc sparc64 powerpc vax amd64
+# work in progress
+#ONLY_FOR_ARCHS += alpha
#BROKEN=adjust for types changes
V = 4.2.4
diff --git a/lang/gcc/4.2/patches/patch-gcc_config_alpha_alpha_c b/lang/gcc/4.2/patches/patch-gcc_config_alpha_alpha_c
new file mode 100644
index 00000000000..450e37677a5
--- /dev/null
+++ b/lang/gcc/4.2/patches/patch-gcc_config_alpha_alpha_c
@@ -0,0 +1,237 @@
+$OpenBSD: patch-gcc_config_alpha_alpha_c,v 1.1 2010/10/29 08:50:38 naddy Exp $
+--- gcc/config/alpha/alpha.c.orig Thu Feb 7 22:58:42 2008
++++ gcc/config/alpha/alpha.c Tue Oct 26 23:19:47 2010
+@@ -225,6 +225,10 @@ alpha_handle_option (size_t code, const char *arg, int
+ target_flags |= MASK_IEEE_CONFORMANT;
+ break;
+
++ case OPT_mno_ieee:
++ target_flags &= ~(MASK_IEEE_WITH_INEXACT|MASK_IEEE_CONFORMANT);
++ break;
++
+ case OPT_mtls_size_:
+ if (value != 16 && value != 32 && value != 64)
+ error ("bad value %qs for -mtls-size switch", arg);
+@@ -481,11 +485,17 @@ override_options (void)
+ if (!g_switch_set)
+ g_switch_value = 8;
+
++#ifdef OPENBSD_NATIVE
++ /* Make -fpic behave as -fPIC unless -msmall-data is specified. */
++ if (flag_pic == 2 && TARGET_SMALL_DATA)
++ warning (0, "-fPIC used with -msmall-data");
++#else
+ /* Infer TARGET_SMALL_DATA from -fpic/-fPIC. */
+ if (flag_pic == 1)
+ target_flags |= MASK_SMALL_DATA;
+ else if (flag_pic == 2)
+ target_flags &= ~MASK_SMALL_DATA;
++#endif
+
+ /* Align labels and loops for optimal branching. */
+ /* ??? Kludge these by not doing anything if we don't optimize and also if
+@@ -7600,94 +7610,134 @@ alpha_expand_prologue (void)
+
+ Note that we are only allowed to adjust sp once in the prologue. */
+
+- if (frame_size <= 32768)
++ if (flag_stack_check || STACK_CHECK_BUILTIN)
+ {
+- if (frame_size > 4096)
++ if (frame_size <= 32768)
+ {
+- int probed;
++ if (frame_size > 4096)
++ {
++ int probed;
+
+- for (probed = 4096; probed < frame_size; probed += 8192)
+- emit_insn (gen_probe_stack (GEN_INT (TARGET_ABI_UNICOSMK
+- ? -probed + 64
+- : -probed)));
++ for (probed = 4096; probed < frame_size; probed += 8192)
++ emit_insn (gen_probe_stack (GEN_INT (TARGET_ABI_UNICOSMK
++ ? -probed + 64
++ : -probed)));
+
+- /* We only have to do this probe if we aren't saving registers. */
+- if (sa_size == 0 && frame_size > probed - 4096)
+- emit_insn (gen_probe_stack (GEN_INT (-frame_size)));
++ /* We only have to do this probe if we aren't saving
++ registers. */
++ if (sa_size == 0 && frame_size > probed - 4096)
++ emit_insn (gen_probe_stack (GEN_INT (-frame_size)));
++ }
++
++ if (frame_size != 0)
++ FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
++ GEN_INT (TARGET_ABI_UNICOSMK
++ ? -frame_size + 64
++ : -frame_size))));
+ }
++ else
++ {
++ /* Here we generate code to set R22 to SP + 4096 and set R23 to the
++ number of 8192 byte blocks to probe. We then probe each block
++ in the loop and then set SP to the proper location. If the
++ amount remaining is > 4096, we have to do one more probe if we
++ are not saving any registers. */
+
+- if (frame_size != 0)
+- FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
+- GEN_INT (TARGET_ABI_UNICOSMK
+- ? -frame_size + 64
+- : -frame_size))));
+- }
+- else
+- {
+- /* Here we generate code to set R22 to SP + 4096 and set R23 to the
+- number of 8192 byte blocks to probe. We then probe each block
+- in the loop and then set SP to the proper location. If the
+- amount remaining is > 4096, we have to do one more probe if we
+- are not saving any registers. */
++ HOST_WIDE_INT blocks = (frame_size + 4096) / 8192;
++ HOST_WIDE_INT leftover = frame_size + 4096 - blocks * 8192;
++ rtx ptr = gen_rtx_REG (DImode, 22);
++ rtx count = gen_rtx_REG (DImode, 23);
++ rtx seq;
+
+- HOST_WIDE_INT blocks = (frame_size + 4096) / 8192;
+- HOST_WIDE_INT leftover = frame_size + 4096 - blocks * 8192;
+- rtx ptr = gen_rtx_REG (DImode, 22);
+- rtx count = gen_rtx_REG (DImode, 23);
+- rtx seq;
++ emit_move_insn (count, GEN_INT (blocks));
++ emit_insn (gen_adddi3 (ptr, stack_pointer_rtx,
++ GEN_INT (TARGET_ABI_UNICOSMK
++ ? 4096 - 64 : 4096)));
+
+- emit_move_insn (count, GEN_INT (blocks));
+- emit_insn (gen_adddi3 (ptr, stack_pointer_rtx,
+- GEN_INT (TARGET_ABI_UNICOSMK ? 4096 - 64 : 4096)));
++ /* Because of the difficulty in emitting a new basic block this
++ late in the compilation, generate the loop as a single insn. */
++ emit_insn (gen_prologue_stack_probe_loop (count, ptr));
+
+- /* Because of the difficulty in emitting a new basic block this
+- late in the compilation, generate the loop as a single insn. */
+- emit_insn (gen_prologue_stack_probe_loop (count, ptr));
++ if (leftover > 4096 && sa_size == 0)
++ {
++ rtx last = gen_rtx_MEM (DImode, plus_constant (ptr, -leftover));
++ MEM_VOLATILE_P (last) = 1;
++ emit_move_insn (last, const0_rtx);
++ }
+
+- if (leftover > 4096 && sa_size == 0)
+- {
+- rtx last = gen_rtx_MEM (DImode, plus_constant (ptr, -leftover));
+- MEM_VOLATILE_P (last) = 1;
+- emit_move_insn (last, const0_rtx);
+- }
++ if (TARGET_ABI_WINDOWS_NT)
++ {
++ /* For NT stack unwind (done by 'reverse execution'), it's
++ not OK to take the result of a loop, even though the value
++ is already in ptr, so we reload it via a single operation
++ and subtract it to sp.
+
+- if (TARGET_ABI_WINDOWS_NT)
+- {
+- /* For NT stack unwind (done by 'reverse execution'), it's
+- not OK to take the result of a loop, even though the value
+- is already in ptr, so we reload it via a single operation
+- and subtract it to sp.
++ Yes, that's correct -- we have to reload the whole constant
++ into a temporary via ldah+lda then subtract from sp. */
+
+- Yes, that's correct -- we have to reload the whole constant
+- into a temporary via ldah+lda then subtract from sp. */
++ HOST_WIDE_INT lo, hi;
++ lo = ((frame_size & 0xffff) ^ 0x8000) - 0x8000;
++ hi = frame_size - lo;
+
+- HOST_WIDE_INT lo, hi;
+- lo = ((frame_size & 0xffff) ^ 0x8000) - 0x8000;
+- hi = frame_size - lo;
++ emit_move_insn (ptr, GEN_INT (hi));
++ emit_insn (gen_adddi3 (ptr, ptr, GEN_INT (lo)));
++ seq = emit_insn (gen_subdi3 (stack_pointer_rtx, stack_pointer_rtx,
++ ptr));
++ }
++ else
++ {
++ seq = emit_insn (gen_adddi3 (stack_pointer_rtx, ptr,
++ GEN_INT (-leftover)));
++ }
+
+- emit_move_insn (ptr, GEN_INT (hi));
+- emit_insn (gen_adddi3 (ptr, ptr, GEN_INT (lo)));
+- seq = emit_insn (gen_subdi3 (stack_pointer_rtx, stack_pointer_rtx,
+- ptr));
++ /* This alternative is special, because the DWARF code cannot
++ possibly intuit through the loop above. So we invent this
++ note it looks at instead. */
++ RTX_FRAME_RELATED_P (seq) = 1;
++ REG_NOTES (seq)
++ = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
++ gen_rtx_SET (VOIDmode, stack_pointer_rtx,
++ gen_rtx_PLUS (Pmode, stack_pointer_rtx,
++ GEN_INT (TARGET_ABI_UNICOSMK
++ ? -frame_size + 64
++ : -frame_size))),
++ REG_NOTES (seq));
+ }
++ }
++ else
++ {
++ if (frame_size <= 32768)
++ {
++ if (frame_size != 0)
++ FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
++ GEN_INT (TARGET_ABI_UNICOSMK
++ ? -frame_size + 64
++ : -frame_size))));
++ }
+ else
+ {
+- seq = emit_insn (gen_adddi3 (stack_pointer_rtx, ptr,
+- GEN_INT (-leftover)));
++ rtx count = gen_rtx_REG (DImode, 23);
++ rtx seq;
++
++ emit_move_insn (count, GEN_INT (TARGET_ABI_UNICOSMK
++ ? -frame_size + 64
++ : -frame_size));
++ seq = emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
++ count));
++
++ /* This alternative is special, because the DWARF code cannot
++ possibly intuit through the loop above. So we invent this
++ note it looks at instead. */
++ RTX_FRAME_RELATED_P (seq) = 1;
++ REG_NOTES (seq)
++ = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
++ gen_rtx_SET (VOIDmode, stack_pointer_rtx,
++ gen_rtx_PLUS (Pmode, stack_pointer_rtx,
++ GEN_INT (TARGET_ABI_UNICOSMK
++ ? -frame_size + 64
++ : -frame_size))),
++ REG_NOTES (seq));
+ }
+-
+- /* This alternative is special, because the DWARF code cannot
+- possibly intuit through the loop above. So we invent this
+- note it looks at instead. */
+- RTX_FRAME_RELATED_P (seq) = 1;
+- REG_NOTES (seq)
+- = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
+- gen_rtx_SET (VOIDmode, stack_pointer_rtx,
+- gen_rtx_PLUS (Pmode, stack_pointer_rtx,
+- GEN_INT (TARGET_ABI_UNICOSMK
+- ? -frame_size + 64
+- : -frame_size))),
+- REG_NOTES (seq));
+ }
+
+ if (!TARGET_ABI_UNICOSMK)
diff --git a/lang/gcc/4.2/patches/patch-gcc_config_alpha_alpha_md b/lang/gcc/4.2/patches/patch-gcc_config_alpha_alpha_md
new file mode 100644
index 00000000000..0b8cb63917e
--- /dev/null
+++ b/lang/gcc/4.2/patches/patch-gcc_config_alpha_alpha_md
@@ -0,0 +1,13 @@
+$OpenBSD: patch-gcc_config_alpha_alpha_md,v 1.1 2010/10/29 08:50:38 naddy Exp $
+--- gcc/config/alpha/alpha.md.orig Sat Sep 1 17:28:30 2007
++++ gcc/config/alpha/alpha.md Tue Oct 26 16:38:28 2010
+@@ -6717,7 +6717,8 @@
+ if (GET_CODE (operands[1]) == CONST_INT
+ && INTVAL (operands[1]) < 32768)
+ {
+- if (INTVAL (operands[1]) >= 4096)
++ if (INTVAL (operands[1]) >= 4096
++ && (flag_stack_check || STACK_CHECK_BUILTIN))
+ {
+ /* We do this the same way as in the prologue and generate explicit
+ probes. Then we update the stack by the constant. */
diff --git a/lang/gcc/4.2/patches/patch-gcc_config_alpha_alpha_opt b/lang/gcc/4.2/patches/patch-gcc_config_alpha_alpha_opt
new file mode 100644
index 00000000000..decca98ca63
--- /dev/null
+++ b/lang/gcc/4.2/patches/patch-gcc_config_alpha_alpha_opt
@@ -0,0 +1,17 @@
+$OpenBSD: patch-gcc_config_alpha_alpha_opt,v 1.1 2010/10/29 08:50:38 naddy Exp $
+--- gcc/config/alpha/alpha.opt.orig Sat Sep 1 17:28:30 2007
++++ gcc/config/alpha/alpha.opt Tue Oct 26 16:38:28 2010
+@@ -42,8 +42,13 @@ mieee
+ Target Report RejectNegative Mask(IEEE)
+ Emit IEEE-conformant code, without inexact exceptions
+
++mno-ieee
++Target Report RejectNegative InverseMask(IEEE)
++Emit non-IEEE-conformant code
++
+ mieee-with-inexact
+ Target Report RejectNegative Mask(IEEE_WITH_INEXACT)
++Emit IEEE-conformant code, with inexact exceptions
+
+ mbuild-constants
+ Target Report Mask(BUILD_CONSTANTS)
diff --git a/lang/gcc/4.2/patches/patch-gcc_config_alpha_openbsd_h b/lang/gcc/4.2/patches/patch-gcc_config_alpha_openbsd_h
index 541a4b151de..b70cda5b818 100644
--- a/lang/gcc/4.2/patches/patch-gcc_config_alpha_openbsd_h
+++ b/lang/gcc/4.2/patches/patch-gcc_config_alpha_openbsd_h
@@ -1,7 +1,7 @@
-$OpenBSD: patch-gcc_config_alpha_openbsd_h,v 1.1 2009/07/01 12:43:55 naddy Exp $
---- gcc/config/alpha/openbsd.h.orig Sat Sep 1 15:28:30 2007
-+++ gcc/config/alpha/openbsd.h Wed Jul 1 04:33:56 2009
-@@ -17,23 +17,13 @@ You should have received a copy of the GNU General Pub
+$OpenBSD: patch-gcc_config_alpha_openbsd_h,v 1.2 2010/10/29 08:50:38 naddy Exp $
+--- gcc/config/alpha/openbsd.h.orig Sat Sep 1 17:28:30 2007
++++ gcc/config/alpha/openbsd.h Tue Oct 26 16:38:28 2010
+@@ -17,82 +17,67 @@ You should have received a copy of the GNU General Pub
along with GCC; see the file COPYING3. If not see
. */
@@ -10,11 +10,29 @@ $OpenBSD: patch-gcc_config_alpha_openbsd_h,v 1.1 2009/07/01 12:43:55 naddy Exp $
-
/* Controlling the compilation driver. */
--/* alpha needs __start. */
--#undef LINK_SPEC
--#define LINK_SPEC \
++#undef TARGET_DEFAULT
++#define TARGET_DEFAULT \
++ (MASK_FPREGS | MASK_IEEE | MASK_IEEE_CONFORMANT | MASK_GAS)
++
+ /* alpha needs __start. */
+ #undef LINK_SPEC
+ #define LINK_SPEC \
- "%{!nostdlib:%{!r*:%{!e*:-e __start}}} -dc -dp %{assert*}"
--
++ "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
++ %{shared:-shared} %{R*} \
++ %{static:-Bstatic} \
++ %{!static:-Bdynamic} \
++ %{assert*} \
++ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
+
++/* As an elf system, we need crtbegin/crtend stuff. */
++#undef STARTFILE_SPEC
++#define STARTFILE_SPEC "\
++ %{!shared: %{pg:gcrt0%O%s} %{!pg:%{p:gcrt0%O%s} %{!p:crt0%O%s}} \
++ crtbegin%O%s} %{shared:crtbeginS%O%s}"
++#undef ENDFILE_SPEC
++#define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
++
/* run-time target specifications */
#define TARGET_OS_CPP_BUILTINS() \
do { \
@@ -27,18 +45,41 @@ $OpenBSD: patch-gcc_config_alpha_openbsd_h,v 1.1 2009/07/01 12:43:55 naddy Exp $
} while (0)
/* Layout of source language data types. */
-@@ -52,47 +42,4 @@ along with GCC; see the file COPYING3. If not see
+
+-/* This must agree with */
++/* This must agree with */
+ #undef SIZE_TYPE
+ #define SIZE_TYPE "long unsigned int"
+
+ #undef PTRDIFF_TYPE
+ #define PTRDIFF_TYPE "long int"
+
++#undef INTMAX_TYPE
++#define INTMAX_TYPE "long long int"
++
++#undef UINTMAX_TYPE
++#define UINTMAX_TYPE "long long unsigned int"
++
+ #undef WCHAR_TYPE
+ #define WCHAR_TYPE "int"
+
+ #undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE 32
-
+-
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
--
++#undef WINT_TYPE
++#define WINT_TYPE "int"
+
++/* Output and generation of labels. */
#define LOCAL_LABEL_PREFIX "."
--
+
-/* We don't have an init section yet. */
-#undef HAS_INIT_SECTION
--
++/* .set on alpha is not used to output labels. */
++#undef SET_ASM_OP
+
-/* collect2 support (assembler format: macros for initialization). */
-
-/* Don't tell collect2 we use COFF as we don't have (yet ?) a dynamic ld
@@ -75,3 +116,6 @@ $OpenBSD: patch-gcc_config_alpha_openbsd_h,v 1.1 2009/07/01 12:43:55 naddy Exp $
- } while (0)
-
-
++/* don't want no friggin' stack checks. */
++#undef STACK_CHECK_BUILTIN
++#define STACK_CHECK_BUILTIN 0
diff --git a/lang/gcc/4.2/patches/patch-gcc_config_gcc b/lang/gcc/4.2/patches/patch-gcc_config_gcc
index 0c94a4293a9..9ff26d54382 100644
--- a/lang/gcc/4.2/patches/patch-gcc_config_gcc
+++ b/lang/gcc/4.2/patches/patch-gcc_config_gcc
@@ -1,5 +1,5 @@
---- gcc/config.gcc.orig Thu Mar 13 19:11:43 2008
-+++ gcc/config.gcc Wed Jul 1 04:34:10 2009
+--- gcc/config.gcc.orig Thu Mar 13 20:11:43 2008
++++ gcc/config.gcc Wed Oct 27 18:39:34 2010
@@ -555,6 +555,11 @@ case ${target} in
*-*-openbsd2.*|*-*-openbsd3.[012])
tm_defines="${tm_defines} HAS_LIBC_R=1" ;;
@@ -19,7 +19,7 @@
- tm_defines="${tm_defines} OBSD_NO_DYNAMIC_LIBRARIES OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_FUNCTION_SIZE OBSD_HAS_DECLARE_OBJECT"
- tm_file="alpha/alpha.h openbsd.h alpha/openbsd.h"
+ tm_defines="${tm_defines} OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_FUNCTION_SIZE OBSD_HAS_DECLARE_OBJECT"
-+ tm_file="alpha/alpha.h alpha/elf.h alpha/openbsd.h openbsd.h openbsd-libpthread.h"
++ tm_file="alpha/alpha.h alpha/elf.h openbsd.h openbsd-libpthread.h alpha/openbsd.h"
# default x-alpha is only appropriate for dec-osf.
target_cpu_default="MASK_GAS"
- tmake_file="alpha/t-alpha alpha/t-ieee"