summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorryoon <ryoon>2014-01-25 13:38:47 +0000
committerryoon <ryoon>2014-01-25 13:38:47 +0000
commit9c56c14066fde9d245b1f0f29396ac7b000d9cb0 (patch)
treec090acb4292e36f8288d321a1f48293baede15ba /lang
parent57d14f6d56228c850ef74cbee7b427dda904f506 (diff)
downloadpkgsrc-9c56c14066fde9d245b1f0f29396ac7b000d9cb0.tar.gz
Update to 4.6.4
* Add OpenBSD/amd64 5.4 support Changelog: * Bugfixes
Diffstat (limited to 'lang')
-rw-r--r--lang/gcc46/Makefile11
-rw-r--r--lang/gcc46/distinfo46
-rw-r--r--lang/gcc46/files/patch-gcc_targhooks.c-openbsd.diff148
-rw-r--r--lang/gcc46/patches/patch-aa133
-rw-r--r--lang/gcc46/patches/patch-ab35
-rw-r--r--lang/gcc46/patches/patch-ah18
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_configure52
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_dyn__load.c51
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_include_gc__config.h.in14
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_include_gc__config__macros.h24
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_include_gc__pthread__redirects.h26
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_include_private_gcconfig.h355
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_mach__dep.c22
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_os__dep.c177
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_pthread__support.c35
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_tests_test.c14
-rw-r--r--lang/gcc46/patches/patch-boehm-gc_threadlibs.c14
-rw-r--r--lang/gcc46/patches/patch-gcc_common.opt71
-rw-r--r--lang/gcc46/patches/patch-gcc_config.host15
-rw-r--r--lang/gcc46/patches/patch-gcc_config_exec-stack.h45
-rw-r--r--lang/gcc46/patches/patch-gcc_config_host-openbsd.c112
-rw-r--r--lang/gcc46/patches/patch-gcc_config_i386_openbsd.h27
-rw-r--r--lang/gcc46/patches/patch-gcc_config_i386_openbsd64.h127
-rw-r--r--lang/gcc46/patches/patch-gcc_config_i386_openbsdelf.h25
-rw-r--r--lang/gcc46/patches/patch-gcc_config_openbsd-libpthread.h11
-rw-r--r--lang/gcc46/patches/patch-gcc_config_openbsd.h16
-rw-r--r--lang/gcc46/patches/patch-gcc_config_t-openbsd13
-rw-r--r--lang/gcc46/patches/patch-gcc_config_x-openbsd9
-rw-r--r--lang/gcc46/patches/patch-gcc_configure12
-rw-r--r--lang/gcc46/patches/patch-gcc_defaults.h15
-rw-r--r--lang/gcc46/patches/patch-gcc_gcc.c13
-rw-r--r--lang/gcc46/patches/patch-gcc_lto_lto.c15
-rw-r--r--lang/gcc46/patches/patch-gcc_opts.c13
-rw-r--r--lang/gcc46/patches/patch-gcc_unwind-dw2-fde-glibc.c13
-rw-r--r--lang/gcc46/patches/patch-gcc_unwind-dw2-fde-openbsd.c15
-rw-r--r--lang/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h16
-rw-r--r--lang/gcc46/patches/patch-libstdc++-v3_include_std_mutex13
37 files changed, 1739 insertions, 32 deletions
diff --git a/lang/gcc46/Makefile b/lang/gcc46/Makefile
index 0dce3d29af5..5f3def343d7 100644
--- a/lang/gcc46/Makefile
+++ b/lang/gcc46/Makefile
@@ -1,8 +1,7 @@
-# $NetBSD: Makefile,v 1.23 2013/05/31 12:41:11 wiz Exp $
+# $NetBSD: Makefile,v 1.24 2014/01/25 13:38:47 ryoon Exp $
DISTNAME= gcc-${GCC_VERSION}
PKGNAME= gcc46-${GCC_VERSION}
-PKGREVISION= 5
CATEGORIES= lang
MASTER_SITES= ${MASTER_SITE_GNU:=gcc/gcc-${GCC_VERSION}/}
EXTRACT_SUFX= .tar.bz2
@@ -14,7 +13,7 @@ LICENSE= gnu-gpl-v2 AND gnu-gpl-v3 AND gnu-lgpl-v2 AND gnu-lgpl-v3
USE_TOOLS+= awk:run bash:run chmod gmake:run makeinfo sed:run
-GCC_VERSION= 4.6.3
+GCC_VERSION= 4.6.4
GCC_SUBPREFIX= gcc46
GCC_PREFIX= ${PREFIX}/${GCC_SUBPREFIX}
@@ -115,6 +114,12 @@ pre-configure:
${CP} ${WRKSRC}/gcc/config/freebsd-stdint.h ${WRKSRC}/gcc/config/netbsd-stdint.h
.endif
+# gengtype does not recognize #ifdef.
+.if ${OPSYS} == "OpenBSD"
+ cd ${WRKSRC}/gcc && \
+ patch -p1 < ${FILESDIR}/patch-gcc_targhooks.c-openbsd.diff
+.endif
+
do-configure:
${MKDIR} ${WRKDIR}/obj
cd ${WRKDIR}/obj; ${SETENV} ${CONFIGURE_ENV} ${CONFIG_SHELL} ${WRKSRC}/configure ${CONFIGURE_ARGS}
diff --git a/lang/gcc46/distinfo b/lang/gcc46/distinfo
index 426362cea5a..14a7fec2976 100644
--- a/lang/gcc46/distinfo
+++ b/lang/gcc46/distinfo
@@ -1,19 +1,49 @@
-$NetBSD: distinfo,v 1.13 2013/04/30 22:24:15 joerg Exp $
+$NetBSD: distinfo,v 1.14 2014/01/25 13:38:47 ryoon Exp $
-SHA1 (gcc-4.6.3.tar.bz2) = ce317ca5c8185b58bc9300182b534608c578637f
-RMD160 (gcc-4.6.3.tar.bz2) = 9abb2f940d08fc84f2d91b6a6ce8d662ca889269
-Size (gcc-4.6.3.tar.bz2) = 71999439 bytes
-SHA1 (patch-aa) = e68232cd14d6be31dd2c45aefb454dde75d0bbba
-SHA1 (patch-ab) = 419dbd3e80b960ac391dba123d8de68abdd35355
+SHA1 (gcc-4.6.4.tar.bz2) = 63933a8a5cf725626585dbba993c8b0f6db1335d
+RMD160 (gcc-4.6.4.tar.bz2) = 6a58b053812cf75622bc4579e020cd9471f46916
+Size (gcc-4.6.4.tar.bz2) = 72006076 bytes
+SHA1 (patch-aa) = 8bb19e38cacf5dbf9e9f3cac71211d52ec8358c3
+SHA1 (patch-ab) = f25d0b276041e57dcfb00638bc4232b4e0f5abb6
SHA1 (patch-ac) = 0f708412670eca90c2c8e3fa675cffb14be768cd
SHA1 (patch-ad) = b5e17219e7b7ba158b9f3e1a67e155fb158b4484
SHA1 (patch-af) = e4e194ef29924eb986536972c5f5e9f37d98eba3
SHA1 (patch-ag) = 1753d08075de8527d8f14afc3df4afeacb10d507
-SHA1 (patch-ah) = 8df9292331e68a69481aaabc894f285199a7eb05
+SHA1 (patch-ah) = bb08426c9eca792f1af4d87f9ea8c827a452fe47
SHA1 (patch-ak) = 377d6ab5d454f0af2709680dd656f0449228aca9
SHA1 (patch-al) = 20d16fba8c1b9e578c9df6523397e29a94409990
+SHA1 (patch-boehm-gc_configure) = 65fa922741428a4a353bf1d3946090eccc0aa809
+SHA1 (patch-boehm-gc_dyn__load.c) = 2d73263d33f905f75da8cff501f5e00c0322f334
+SHA1 (patch-boehm-gc_include_gc__config.h.in) = 613d5ebbdcb92fc3cd3b04c4a643c70c9b5a7667
+SHA1 (patch-boehm-gc_include_gc__config__macros.h) = 106e09e72990591d5eea3beeea9b2c311e5fa6e5
+SHA1 (patch-boehm-gc_include_gc__pthread__redirects.h) = 5df4e69665bc69c4a53f80361ed84bc7b7ef7b6f
+SHA1 (patch-boehm-gc_include_private_gcconfig.h) = 0dfffa8af8c4a6c2f00b561e8750fb2349a5b42e
+SHA1 (patch-boehm-gc_mach__dep.c) = d91ca0d42357647ccf9fa3f4624bf8eaea2afbf9
+SHA1 (patch-boehm-gc_os__dep.c) = d50619167d76eec4ec6b8fb8e9a9ec65d1e8b69c
+SHA1 (patch-boehm-gc_pthread__support.c) = 1028b0e8604e0477dd80ec20c04ffc00278237a9
+SHA1 (patch-boehm-gc_tests_test.c) = f4f2c7a701ef166004746e5f819f7e04c4176b24
+SHA1 (patch-boehm-gc_threadlibs.c) = 62cabc51234e1ce5c60e70bef9fc4d8f92b9739d
+SHA1 (patch-gcc_common.opt) = 52cbab619bbf7df69a902b066a1d0626193f49b0
+SHA1 (patch-gcc_config.host) = 5be619aad33ee0ac05d8fb64879be5e530914122
SHA1 (patch-gcc_config_arm_elf.h) = 28c67bb698ebe9a3aa45c4cff29f028c82cc7606
SHA1 (patch-gcc_config_arm_t-netbsd) = a1682f4f8dc7e393446f19f615737ddfc98fcb7f
-SHA1 (patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h) = 7e8413cf45d49890ad7634f9276188413c8ed30a
+SHA1 (patch-gcc_config_exec-stack.h) = 2ff8a153a41638de2943c4109f38ea3a7c26c00d
+SHA1 (patch-gcc_config_host-openbsd.c) = 109ce33dbbc19c988637d77dce4d240d6bfc912c
+SHA1 (patch-gcc_config_i386_openbsd.h) = 0adb1e531eb9d773cbd6944f279e949e59035bd3
+SHA1 (patch-gcc_config_i386_openbsd64.h) = c4fdb98de196702afad36a75886967babf49a55a
+SHA1 (patch-gcc_config_i386_openbsdelf.h) = cd7afa938514dc80fb53c683fb089468c935d2ae
+SHA1 (patch-gcc_config_openbsd-libpthread.h) = 826aaae4b2dda5a49ec71510f0752aba3c1b0b91
+SHA1 (patch-gcc_config_openbsd.h) = a396d14b2df78a4c45d3e51ef7fe960bbc8d5754
+SHA1 (patch-gcc_config_t-openbsd) = 662fe8d0c4b58145fb3268bc7ac432a1616c1106
+SHA1 (patch-gcc_config_x-openbsd) = b307d75331b9a7f6271698c68f1647a03d204eb9
+SHA1 (patch-gcc_configure) = 906906aca782c75b2a053aef272a8472f0a9a9ee
+SHA1 (patch-gcc_defaults.h) = 72b145fdf9baecc061e90e9634eb5f842215a962
+SHA1 (patch-gcc_gcc.c) = 264e561efe02e1e343400ef7dff182e71b358ff5
+SHA1 (patch-gcc_lto_lto.c) = 3c7df0691d300d2915388e7ef019b9717a9673d7
+SHA1 (patch-gcc_opts.c) = e02ebec8a9de24492a3aba80ee8c742446f2c549
+SHA1 (patch-gcc_unwind-dw2-fde-glibc.c) = 704ccc2b1058344586e0ccb8bcd291f41d93ed0a
+SHA1 (patch-gcc_unwind-dw2-fde-openbsd.c) = 74b7df494848d8d52e4574bac3fa3742cd3ff0d7
+SHA1 (patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h) = eac78601d0f531c8a49c88eacc59691312f1cf25
SHA1 (patch-libstdc++-v3_config_os_bsd_netbsd_ctype__inline.h) = 830038744cbbb713ecc3f960a9509bef16176db9
SHA1 (patch-libstdc++-v3_config_os_bsd_netbsd_ctype__noninline.h) = ce481809b051cb281772a0ad4d561241731f7556
+SHA1 (patch-libstdc++-v3_include_std_mutex) = 872322df9bf7406d9fd3fc1e12dd7573c3c91bd2
diff --git a/lang/gcc46/files/patch-gcc_targhooks.c-openbsd.diff b/lang/gcc46/files/patch-gcc_targhooks.c-openbsd.diff
new file mode 100644
index 00000000000..4687dec0dda
--- /dev/null
+++ b/lang/gcc46/files/patch-gcc_targhooks.c-openbsd.diff
@@ -0,0 +1,148 @@
+--- gcc/targhooks.c.orig 2014-01-25 15:53:51.000000000 +0900
++++ gcc/targhooks.c 2014-01-25 15:38:03.000000000 +0900
+@@ -56,6 +56,7 @@
+ #include "tree.h"
+ #include "expr.h"
+ #include "output.h"
++#include "c-family/c-common.h"
+ #include "diagnostic-core.h"
+ #include "function.h"
+ #include "target.h"
+@@ -658,7 +659,7 @@
+ rtx x;
+
+ t = build_decl (UNKNOWN_LOCATION,
+- VAR_DECL, get_identifier ("__stack_chk_guard"),
++ VAR_DECL, get_identifier ("__guard_local"),
+ ptr_type_node);
+ TREE_STATIC (t) = 1;
+ TREE_PUBLIC (t) = 1;
+@@ -667,6 +668,8 @@
+ TREE_THIS_VOLATILE (t) = 1;
+ DECL_ARTIFICIAL (t) = 1;
+ DECL_IGNORED_P (t) = 1;
++ DECL_VISIBILITY (t) = VISIBILITY_HIDDEN;
++ DECL_VISIBILITY_SPECIFIED (t) = 1;
+
+ /* Do not share RTL as the declaration is visible outside of
+ current function. */
+@@ -679,67 +682,68 @@
+ return t;
+ }
+
+-static GTY(()) tree stack_chk_fail_decl;
++static GTY(()) int stack_protect_labelno;
+
+ tree
+ default_external_stack_protect_fail (void)
+ {
+- tree t = stack_chk_fail_decl;
+-
+- if (t == NULL_TREE)
+- {
+- t = build_function_type_list (void_type_node, NULL_TREE);
+- t = build_decl (UNKNOWN_LOCATION,
+- FUNCTION_DECL, get_identifier ("__stack_chk_fail"), t);
+- TREE_STATIC (t) = 1;
+- TREE_PUBLIC (t) = 1;
+- DECL_EXTERNAL (t) = 1;
+- TREE_USED (t) = 1;
+- TREE_THIS_VOLATILE (t) = 1;
+- TREE_NOTHROW (t) = 1;
+- DECL_ARTIFICIAL (t) = 1;
+- DECL_IGNORED_P (t) = 1;
+- DECL_VISIBILITY (t) = VISIBILITY_DEFAULT;
+- DECL_VISIBILITY_SPECIFIED (t) = 1;
+-
+- stack_chk_fail_decl = t;
+- }
+-
+- return build_call_expr (t, 0);
++ tree t, func, type, init, stack_smash_handler;
++ const char *name;
++ size_t length;
++ char name_buf[32];
++
++ if (NULL == (name = fname_as_string (0))) {
++ name = (char *)xmalloc(32);
++ strlcpy (name, "*unknown*", 32);
++ }
++ length = strlen (name);
++ /* Build a decl for __func__. */
++ type = build_array_type (char_type_node,
++ build_index_type (size_int (length)));
++ type = build_qualified_type (type, TYPE_QUAL_CONST);
++
++ init = build_string (length + 1, name);
++ free ((char *) name);
++ TREE_TYPE (init) = type;
++
++ func = build_decl (UNKNOWN_LOCATION, VAR_DECL, NULL_TREE, type);
++ TREE_STATIC (func) = 1;
++ TREE_READONLY (func) = 1;
++ DECL_ARTIFICIAL (func) = 1;
++ ASM_GENERATE_INTERNAL_LABEL (name_buf, "LSSH", stack_protect_labelno++);
++ DECL_NAME (func) = get_identifier (name_buf);
++ DECL_INITIAL (func) = init;
++
++ assemble_variable (func, 0, 0, 0);
++
++ /* Build a decl for __stack_smash_handler. */
++ t = build_pointer_type (TREE_TYPE (func));
++ t = build_function_type_list (void_type_node, t, NULL_TREE);
++ t = build_decl (UNKNOWN_LOCATION,
++ FUNCTION_DECL, get_identifier ("__stack_smash_handler"), t);
++ /* t = build_fn_decl ("__stack_smash_handler", t); */
++ TREE_STATIC (t) = 1;
++ TREE_PUBLIC (t) = 1;
++ DECL_EXTERNAL (t) = 1;
++ TREE_USED (t) = 1;
++ TREE_THIS_VOLATILE (t) = 1;
++ TREE_NOTHROW (t) = 1;
++ DECL_ARTIFICIAL (t) = 1;
++ DECL_IGNORED_P (t) = 1;
++ DECL_VISIBILITY (t) = VISIBILITY_DEFAULT;
++ DECL_VISIBILITY_SPECIFIED (t) = 1;
++
++ stack_smash_handler = t;
++
++ /* Generate a call to __stack_smash_handler(__func__). */
++ t = build_fold_addr_expr (func);
++ return build_call_expr (stack_smash_handler, 1, t);
+ }
+
+ tree
+ default_hidden_stack_protect_fail (void)
+ {
+-#ifndef HAVE_GAS_HIDDEN
+ return default_external_stack_protect_fail ();
+-#else
+- tree t = stack_chk_fail_decl;
+-
+- if (!flag_pic)
+- return default_external_stack_protect_fail ();
+-
+- if (t == NULL_TREE)
+- {
+- t = build_function_type_list (void_type_node, NULL_TREE);
+- t = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
+- get_identifier ("__stack_chk_fail_local"), t);
+- TREE_STATIC (t) = 1;
+- TREE_PUBLIC (t) = 1;
+- DECL_EXTERNAL (t) = 1;
+- TREE_USED (t) = 1;
+- TREE_THIS_VOLATILE (t) = 1;
+- TREE_NOTHROW (t) = 1;
+- DECL_ARTIFICIAL (t) = 1;
+- DECL_IGNORED_P (t) = 1;
+- DECL_VISIBILITY_SPECIFIED (t) = 1;
+- DECL_VISIBILITY (t) = VISIBILITY_HIDDEN;
+-
+- stack_chk_fail_decl = t;
+- }
+-
+- return build_call_expr (t, 0);
+-#endif
+ }
+
+ bool
diff --git a/lang/gcc46/patches/patch-aa b/lang/gcc46/patches/patch-aa
index d01f1a2a9f7..96753434c9e 100644
--- a/lang/gcc46/patches/patch-aa
+++ b/lang/gcc46/patches/patch-aa
@@ -1,4 +1,4 @@
-$NetBSD: patch-aa,v 1.3 2012/04/17 07:48:13 sbd Exp $
+$NetBSD: patch-aa,v 1.4 2014/01/25 13:38:48 ryoon Exp $
* Add t-crtstuff to tmake_file on NetBSD.
* Add netbsd-stdint.h to tm_file on NetBSD.
@@ -6,9 +6,9 @@ $NetBSD: patch-aa,v 1.3 2012/04/17 07:48:13 sbd Exp $
* Add Dragonfly support.
---- gcc/config.gcc.orig 2011-07-22 18:44:50.000000000 +0200
-+++ gcc/config.gcc 2012-03-13 13:40:05.000000000 +0100
-@@ -561,6 +561,33 @@
+--- gcc/config.gcc.orig 2013-03-06 17:40:07.000000000 +0000
++++ gcc/config.gcc
+@@ -561,6 +561,33 @@ case ${target} in
# need_64bit_hwint=yes # system compiler has this for all arch!
use_gcc_stdint=wrap
;;
@@ -42,7 +42,7 @@ $NetBSD: patch-aa,v 1.3 2012/04/17 07:48:13 sbd Exp $
*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu)
extra_options="$extra_options gnu-user.opt"
extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
-@@ -655,6 +682,7 @@
+@@ -655,6 +682,7 @@ case ${target} in
default_use_cxa_atexit=yes
;;
esac
@@ -50,7 +50,50 @@ $NetBSD: patch-aa,v 1.3 2012/04/17 07:48:13 sbd Exp $
;;
*-*-openbsd*)
tmake_file="t-libc-ok t-openbsd t-libgcc-pic"
-@@ -1219,19 +1247,26 @@
+@@ -668,6 +696,14 @@ case ${target} in
+ *-*-openbsd2.*|*-*-openbsd3.[012])
+ tm_defines="${tm_defines} HAS_LIBC_R=1" ;;
+ esac
++ case ${target} in
++ *-*-openbsd[0-3].*|*-*-openbsd4.[012])
++ # keep default of no cxa_atexit support for these older releases
++ ;;
++ *)
++ default_use_cxa_atexit=yes
++ ;;
++ esac
+ ;;
+ *-*-rtems*)
+ case ${enable_threads} in
+@@ -741,7 +777,7 @@ alpha*-*-netbsd*)
+ tmake_file="${tmake_file} alpha/t-alpha alpha/t-ieee"
+ ;;
+ alpha*-*-openbsd*)
+- tm_defines="${tm_defines} OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_FUNCTION_SIZE OBSD_HAS_DECLARE_OBJECT"
++ tm_defines="${tm_defines} OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_FUNCTION_SIZE OBSD_HAS_DECLARE_OBJECT PIE_DEFAULT=2"
+ tm_file="alpha/alpha.h alpha/elf.h openbsd.h openbsd-stdint.h alpha/openbsd.h openbsd-libpthread.h"
+ extra_options="${extra_options} openbsd.opt alpha/elf.opt"
+ # default x-alpha is only appropriate for dec-osf.
+@@ -1057,10 +1093,14 @@ hppa*-*-linux*)
+ tmake_file="$tmake_file pa/t-slibgcc-dwarf-ver"
+ fi
+ ;;
+-# port not yet contributed.
+-#hppa*-*-openbsd*)
+-# target_cpu_default="MASK_PA_11"
+-# ;;
++hppa*-*-openbsd*)
++ target_cpu_default="MASK_PA_11"
++ tm_defines="${tm_defines} PIE_DEFAULT=1"
++ tm_file="${tm_file} dbxelf.h elfos.h openbsd-libpthread.h \
++ pa/pa32-regs.h pa/openbsd.h openbsd.h"
++ tmake_file="${tmake_file} pa/t-openbsd"
++ extra_options="${extra_options} openbsd.opt"
++ ;;
+ hppa[12]*-*-hpux10*)
+ case ${target} in
+ hppa1.1-*-* | hppa2*-*-*)
+@@ -1223,19 +1263,26 @@ x86_64-*-freebsd*)
tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${fbsd_tm_file} i386/x86-64.h i386/freebsd.h i386/freebsd64.h"
tmake_file="${tmake_file} i386/t-crtstuff"
;;
@@ -80,3 +123,81 @@ $NetBSD: patch-aa,v 1.3 2012/04/17 07:48:13 sbd Exp $
extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
tmake_file="${tmake_file} i386/t-crtstuff"
;;
+@@ -1248,12 +1295,19 @@ i[34567]86-*-openbsd2.*|i[34567]86-*open
+ use_collect2=yes
+ ;;
+ i[34567]86-*-openbsd*)
++ tm_defines="${tm_defines} PIE_DEFAULT=1"
+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h"
+ tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h i386/openbsdelf.h"
+ extra_options="${extra_options} openbsd.opt"
+ gas=yes
+ gnu_ld=yes
+ ;;
++x86_64-*-openbsd*)
++ tm_defines="${tm_defines} PIE_DEFAULT=1"
++ tm_file="i386/biarch64.h i386/i386.h i386/unix.h i386/att.h dbxelf.h elfos.h openbsd.h openbsd-libpthread.h i386/x86-64.h i386/openbsd64.h"
++ tm_file="${tm_file} exec-stack.h"
++ tmake_file="t-libc-ok t-openbsd i386/t-openbsd"
++ ;;
+ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i[34567]86-*-gnu* | i[34567]86-*-kopensolaris*-gnu)
+ # Intel 80386's running GNU/*
+ # with ELF format using glibc 2
+@@ -1914,14 +1968,15 @@ mips*-*-linux*) # Linux MIPS, either
+ test x$with_llsc != x || with_llsc=yes
+ ;;
+ mips*-*-openbsd*)
+- tm_defines="${tm_defines} OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_OBJECT OBSD_HAS_CORRECT_SPECS"
+- target_cpu_default="MASK_ABICALLS"
+- tm_file="mips/mips.h openbsd.h openbsd-stdint.h openbsd-libpthread.h mips/openbsd.h mips/sdb.h"
++ tm_defines="${tm_defines} OBSD_HAS_DECLARE_FUNCTION_NAME OBSD_HAS_DECLARE_OBJECT OBSD_HAS_CORRECT_SPECS MIPS_ISA_DEFAULT=3 MIPS_ABI_DEFAULT=ABI_64 PIE_DEFAULT=1"
++ tm_file="dbxelf.h elfos.h openbsd.h openbsd-stdint.h openbsd-libpthread.h mips/mips.h mips/openbsd64.h"
+ extra_options="${extra_options} openbsd.opt"
+ case ${target} in
+ mips*el-*-openbsd*)
+- tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=0";;
+- *) tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=MASK_BIG_ENDIAN";;
++ tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=0"
++ target_cpu_default="MASK_ABICALLS";;
++ *) tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=MASK_BIG_ENDIAN"
++ target_cpu_default="MASK_ABICALLS|MASK_FIX_R4000|MASK_FIX_R4400";;
+ esac
+ ;;
+ mips*-sde-elf*)
+@@ -2061,10 +2116,11 @@ picochip-*)
+ tmake_file="picochip/t-picochip t-pnt16-warn"
+ ;;
+ # port not yet contributed
+-#powerpc-*-openbsd*)
+-# tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-fprules-fpbit "
+-# extra_headers=
+-# ;;
++powerpc-*-openbsd*)
++ tm_file="${tm_file} dbxelf.h elfos.h openbsd.h openbsd-libpthread.h freebsd-spec.h rs6000/sysv4.h rs6000/openbsd.h"
++ tmake_file="${tmake_file} rs6000/t-openbsd"
++ extra_options="${extra_options} rs6000/sysv4.opt"
++ ;;
+ powerpc-*-darwin*)
+ extra_options="${extra_options} rs6000/darwin.opt"
+ extra_parts="crt2.o"
+@@ -2665,6 +2721,7 @@ sparc64-*-netbsd*)
+ tmake_file="${tmake_file} sparc/t-netbsd64"
+ ;;
+ sparc64-*-openbsd*)
++ tm_defines="${tm_defines} PIE_DEFAULT=2"
+ tm_file="sparc/openbsd1-64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h sparc/sp64-elf.h"
+ tm_file="${tm_file} openbsd.h openbsd-stdint.h openbsd-libpthread.h sparc/openbsd64.h"
+ extra_options="${extra_options} openbsd.opt"
+@@ -2830,6 +2887,12 @@ case ${target} in
+ arch_without_sse2=yes
+ arch_without_64bit=yes
+ ;;
++ i386-*-openbsd*)
++ arch=i486
++ cpu=generic
++ arch_without_sse2=yes
++ arch_without_64bit=yes
++ ;;
+ i386-*-*)
+ arch=i386
+ cpu=i386
diff --git a/lang/gcc46/patches/patch-ab b/lang/gcc46/patches/patch-ab
index 7418997a29c..1b4d1792e02 100644
--- a/lang/gcc46/patches/patch-ab
+++ b/lang/gcc46/patches/patch-ab
@@ -1,10 +1,10 @@
-$NetBSD: patch-ab,v 1.2 2012/04/17 07:48:13 sbd Exp $
+$NetBSD: patch-ab,v 1.3 2014/01/25 13:38:48 ryoon Exp $
* Add Dragonfly support.
---- libgcc/config.host.orig 2011-03-14 06:06:23.000000000 +0000
+--- libgcc/config.host.orig 2011-11-23 22:15:54.000000000 +0000
+++ libgcc/config.host
-@@ -159,6 +159,8 @@ case ${host} in
+@@ -150,6 +150,8 @@ case ${host} in
# machine-specific sections may refine and add to this
# configuration.
;;
@@ -13,7 +13,16 @@ $NetBSD: patch-ab,v 1.2 2012/04/17 07:48:13 sbd Exp $
*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu*)
extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
;;
-@@ -287,6 +289,10 @@ i[34567]86-*-freebsd*)
+@@ -257,6 +259,8 @@ hppa*64*-*-linux*)
+ ;;
+ hppa*-*-linux*)
+ ;;
++hppa-*-openbsd*)
++ ;;
+ hppa[12]*-*-hpux10*)
+ ;;
+ hppa*64*-*-hpux11*)
+@@ -278,6 +282,10 @@ i[34567]86-*-freebsd*)
x86_64-*-freebsd*)
tmake_file="${tmake_file} i386/t-freebsd"
;;
@@ -24,3 +33,21 @@ $NetBSD: patch-ab,v 1.2 2012/04/17 07:48:13 sbd Exp $
i[34567]86-*-netbsdelf*)
;;
i[34567]86-*-netbsd*)
+@@ -288,6 +296,8 @@ i[34567]86-*-openbsd2.*|i[34567]86-*open
+ ;;
+ i[34567]86-*-openbsd*)
+ ;;
++x86_64-*-openbsd*)
++ ;;
+ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i[34567]86-*-gnu*)
+ extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
+ tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm"
+@@ -459,6 +469,8 @@ powerpc-*-freebsd*)
+ ;;
+ powerpc-*-netbsd*)
+ ;;
++powerpc-*-openbsd*)
++ ;;
+ powerpc-*-eabispe*)
+ tmake_file="${tmake_file} rs6000/t-ppccomm"
+ ;;
diff --git a/lang/gcc46/patches/patch-ah b/lang/gcc46/patches/patch-ah
index 1e67840cc9d..1e12b255926 100644
--- a/lang/gcc46/patches/patch-ah
+++ b/lang/gcc46/patches/patch-ah
@@ -1,11 +1,11 @@
-$NetBSD: patch-ah,v 1.2 2012/04/17 07:48:13 sbd Exp $
+$NetBSD: patch-ah,v 1.3 2014/01/25 13:38:48 ryoon Exp $
On NetBSD the 'cabs' and 'cabsf' functions are are __RENAME so that
thay have '__c99_' prefixes.
---- gcc/fortran/f95-lang.c.orig 2011-02-24 09:53:26.000000000 +0000
+--- gcc/fortran/f95-lang.c.orig 2011-04-05 08:13:16.000000000 +0000
+++ gcc/fortran/f95-lang.c
-@@ -824,10 +824,17 @@ gfc_init_builtin_functions (void)
+@@ -823,10 +823,17 @@ gfc_init_builtin_functions (void)
gfc_define_builtin ("__builtin_cabsl", func_clongdouble_longdouble,
BUILT_IN_CABSL, "cabsl", ATTR_CONST_NOTHROW_LEAF_LIST);
@@ -23,3 +23,15 @@ thay have '__c99_' prefixes.
gfc_define_builtin ("__builtin_copysignl", mfunc_longdouble[1],
BUILT_IN_COPYSIGNL, "copysignl",
+@@ -1163,6 +1170,11 @@ gfc_maybe_initialize_eh (void)
+ using_eh_for_cleanups ();
+ }
+
++const char *
++fname_as_string(int pretty_p)
++{
++ return NULL;
++}
+
+ #include "gt-fortran-f95-lang.h"
+ #include "gtype-fortran.h"
diff --git a/lang/gcc46/patches/patch-boehm-gc_configure b/lang/gcc46/patches/patch-boehm-gc_configure
new file mode 100644
index 00000000000..eea4be39403
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_configure
@@ -0,0 +1,52 @@
+$NetBSD: patch-boehm-gc_configure,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/configure.orig 2013-04-12 09:58:00.000000000 +0000
++++ boehm-gc/configure
+@@ -10756,7 +10756,7 @@ netbsd*)
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
++ #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+@@ -14480,7 +14480,7 @@ openbsd*)
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
++ #finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+@@ -14855,6 +14855,11 @@ $as_echo "#define _REENTRANT 1" >>confde
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"Only HP-UX 11 POSIX threads are supported.\"" >&5
+ $as_echo "$as_me: WARNING: \"Only HP-UX 11 POSIX threads are supported.\"" >&2;}
+ ;;
++ *-*-openbsd*)
++ $as_echo "#define GC_OPENBSD_THREADS 1" >>confdefs.h
++ THREADLIBS=-pthread
++ INCLUDES="$INCLUDES -pthread"
++ ;;
+ *-*-kfreebsd*-gnu)
+ $as_echo "#define GC_FREEBSD_THREADS 1" >>confdefs.h
+
+@@ -14995,7 +15000,6 @@ else
+ POWERPC_DARWIN_FALSE=
+ fi
+
+-
+ # Darwin needs a few extra special tests to deal with variation in the
+ # system headers.
+ case "$host" in
+@@ -15306,6 +15310,9 @@ $as_echo "#define DATASTART_IS_ETEXT 1"
+ sparc-*-netbsd*)
+ machdep="sparc_netbsd_mach_dep.lo"
+ ;;
++ sparc*-*-openbsd*)
++ machdep="sparc_mach_dep.lo"
++ ;;
+ sparc-sun-solaris2.3)
+ machdep="sparc_mach_dep.lo"
+
diff --git a/lang/gcc46/patches/patch-boehm-gc_dyn__load.c b/lang/gcc46/patches/patch-boehm-gc_dyn__load.c
new file mode 100644
index 00000000000..564014f6903
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_dyn__load.c
@@ -0,0 +1,51 @@
+$NetBSD: patch-boehm-gc_dyn__load.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/dyn_load.c.orig 2010-11-29 14:58:16.000000000 +0000
++++ boehm-gc/dyn_load.c
+@@ -60,6 +60,7 @@
+ !defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \
+ !defined(RS6000) && !defined(SCO_ELF) && !defined(DGUX) && \
+ !(defined(FREEBSD) && defined(__ELF__)) && \
++ !(defined(OPENBSD) && defined(__ELF__)) && \
+ !(defined(NETBSD) && defined(__ELF__)) && !defined(HURD) && \
+ !defined(DARWIN)
+ --> We only know how to find data segments of dynamic libraries for the
+@@ -90,9 +91,9 @@
+
+ #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \
+ (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \
++ (defined(OPENBSD) && defined(__ELF__)) || \
+ (defined(NETBSD) && defined(__ELF__)) || defined(HURD)
+ # include <stddef.h>
+-# include <elf.h>
+ # include <link.h>
+ #endif
+
+@@ -106,7 +107,7 @@
+ # define ElfW(type) Elf64_##type
+ # endif
+ # else
+-# ifdef NETBSD
++# if defined(NETBSD) || defined(OPENBSD)
+ # if ELFSIZE == 32
+ # define ElfW(type) Elf32_##type
+ # else
+@@ -301,6 +302,7 @@ void GC_register_dynamic_libraries()
+
+ #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \
+ (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \
++ (defined(OPENBSD) && defined(__ELF__)) || \
+ (defined(NETBSD) && defined(__ELF__)) || defined(HURD)
+
+
+@@ -412,6 +414,10 @@ GC_bool GC_register_main_static_data()
+ #define HAVE_DL_ITERATE_PHDR
+ #endif
+
++#if defined(OPENBSD)
++#define HAVE_DL_ITERATE_PHDR
++#endif
++
+ #if defined(HAVE_DL_ITERATE_PHDR)
+
+ static int GC_register_dynlib_callback(info, size, ptr)
diff --git a/lang/gcc46/patches/patch-boehm-gc_include_gc__config.h.in b/lang/gcc46/patches/patch-boehm-gc_include_gc__config.h.in
new file mode 100644
index 00000000000..d5787fd0da2
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_include_gc__config.h.in
@@ -0,0 +1,14 @@
+$NetBSD: patch-boehm-gc_include_gc__config.h.in,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/include/gc_config.h.in.orig 2012-03-02 18:21:41.000000000 +0000
++++ boehm-gc/include/gc_config.h.in
+@@ -30,6 +30,9 @@
+ /* support FreeBSD threads */
+ #undef GC_FREEBSD_THREADS
+
++/* support OpenBSD threads */
++#undef GC_OPENBSD_THREADS
++
+ /* include support for gcj */
+ #undef GC_GCJ_SUPPORT
+
diff --git a/lang/gcc46/patches/patch-boehm-gc_include_gc__config__macros.h b/lang/gcc46/patches/patch-boehm-gc_include_gc__config__macros.h
new file mode 100644
index 00000000000..599cda1ddee
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_include_gc__config__macros.h
@@ -0,0 +1,24 @@
+$NetBSD: patch-boehm-gc_include_gc__config__macros.h,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/include/gc_config_macros.h.orig 2012-02-10 16:32:36.000000000 +0000
++++ boehm-gc/include/gc_config_macros.h
+@@ -20,7 +20,7 @@
+ defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) || \
+ defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) || \
+ defined(GC_DGUX386_THREADS) || defined(GC_DARWIN_THREADS) || \
+- defined(GC_AIX_THREADS) || \
++ defined(GC_AIX_THREADS) || defined(GC_OPENBSD_THREADS) || \
+ (defined(GC_WIN32_THREADS) && defined(__CYGWIN32__))
+ # define GC_PTHREADS
+ # endif
+@@ -55,6 +55,10 @@
+ # define GC_FREEBSD_THREADS
+ # define GC_PTHREADS
+ # endif
++# if !defined(GC_PTHREADS) && defined(__OpenBSD__)
++# define GC_OPENBSD_THREADS
++# define GC_PTHREADS
++# endif
+ # if defined(DGUX) && (defined(i386) || defined(__i386__))
+ # define GC_DGUX386_THREADS
+ # define GC_PTHREADS
diff --git a/lang/gcc46/patches/patch-boehm-gc_include_gc__pthread__redirects.h b/lang/gcc46/patches/patch-boehm-gc_include_gc__pthread__redirects.h
new file mode 100644
index 00000000000..acf74082295
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_include_gc__pthread__redirects.h
@@ -0,0 +1,26 @@
+$NetBSD: patch-boehm-gc_include_gc__pthread__redirects.h,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/include/gc_pthread_redirects.h.orig 2006-08-21 22:07:30.000000000 +0000
++++ boehm-gc/include/gc_pthread_redirects.h
+@@ -52,7 +52,7 @@
+ int GC_pthread_create(pthread_t *new_thread,
+ const pthread_attr_t *attr,
+ void *(*start_routine)(void *), void *arg);
+-#ifndef GC_DARWIN_THREADS
++#if !defined(GC_DARWIN_THREADS) && !defined(GC_OPENBSD_THREADS)
+ int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset);
+ #endif
+ int GC_pthread_join(pthread_t thread, void **retval);
+@@ -72,8 +72,11 @@
+ # define pthread_join GC_pthread_join
+ # define pthread_detach GC_pthread_detach
+
+-#ifndef GC_DARWIN_THREADS
++#if !defined(GC_DARWIN_THREADS) && !defined(GC_OPENBSD_THREADS)
+ # define pthread_sigmask GC_pthread_sigmask
++#endif
++
++#ifndef GC_DARWIN_THREADS
+ # define dlopen GC_dlopen
+ #endif
+
diff --git a/lang/gcc46/patches/patch-boehm-gc_include_private_gcconfig.h b/lang/gcc46/patches/patch-boehm-gc_include_private_gcconfig.h
new file mode 100644
index 00000000000..4817c745fe6
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_include_private_gcconfig.h
@@ -0,0 +1,355 @@
+$NetBSD: patch-boehm-gc_include_private_gcconfig.h,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/include/private/gcconfig.h.orig 2012-03-02 18:21:41.000000000 +0000
++++ boehm-gc/include/private/gcconfig.h
+@@ -62,7 +62,7 @@
+ /* Determine the machine type: */
+ # if defined(__arm__) || defined(__thumb__)
+ # define ARM32
+-# if !defined(LINUX) && !defined(NETBSD)
++# if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD)
+ # define NOSYS
+ # define mach_type_known
+ # endif
+@@ -77,14 +77,18 @@
+ # define HP
+ # define mach_type_known
+ # endif
+-# if defined(OPENBSD) && defined(m68k)
+-# define M68K
+-# define mach_type_known
+-# endif
+ # if defined(OPENBSD) && defined(__sparc__)
+ # define SPARC
+ # define mach_type_known
+ # endif
++# if defined(OPENBSD) && defined(__arm__)
++# define ARM32
++# define mach_type_known
++# endif
++# if defined(OPENBSD) && defined(__sh__)
++# define SH
++# define mach_type_known
++# endif
+ # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
+ # define M68K
+ # define mach_type_known
+@@ -101,7 +105,7 @@
+ # define SH
+ # define mach_type_known
+ # endif
+-# if defined(vax)
++# if defined(vax) || defined(__vax__)
+ # define VAX
+ # ifdef ultrix
+ # define ULTRIX
+@@ -119,7 +123,7 @@
+ # if defined(nec_ews) || defined(_nec_ews)
+ # define EWS4800
+ # endif
+-# if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
++# if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD) && !defined(OPENBSD)
+ # if defined(ultrix) || defined(__ultrix)
+ # define ULTRIX
+ # else
+@@ -210,7 +214,7 @@
+ # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
+ || defined(hppa) || defined(__hppa__)
+ # define HP_PA
+-# if !defined(LINUX) && !defined(HPUX)
++# if !defined(LINUX) && !defined(HPUX) && !defined(OPENBSD)
+ # define HPUX
+ # endif
+ # define mach_type_known
+@@ -231,6 +235,10 @@
+ # define I386
+ # define mach_type_known
+ # endif
++# if defined(OPENBSD) && defined(__amd64)
++# define X86_64
++# define mach_type_known
++# endif
+ # if defined(LINUX) && defined(__x86_64__)
+ # define X86_64
+ # define mach_type_known
+@@ -302,6 +310,11 @@
+ # define MACOS
+ # define mach_type_known
+ # endif
++# if defined(__OpenBSD__) && defined(__powerpc__)
++# define POWERPC
++# define OPENBSD
++# define mach_type_known
++# endif
+ # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
+ # define DARWIN
+ # if defined(__ppc__) || defined(__ppc64__)
+@@ -651,18 +664,6 @@
+ # ifdef M68K
+ # define MACH_TYPE "M68K"
+ # define ALIGNMENT 2
+-# ifdef OPENBSD
+-# define OS_TYPE "OPENBSD"
+-# define HEURISTIC2
+-# ifdef __ELF__
+-# define DATASTART GC_data_start
+-# define DYNAMIC_LOADING
+-# else
+- extern char etext[];
+-# define DATASTART ((ptr_t)(etext))
+-# endif
+-# define USE_GENERIC_PUSH_REGS
+-# endif
+ # ifdef NETBSD
+ # define OS_TYPE "NETBSD"
+ # define HEURISTIC2
+@@ -836,6 +837,24 @@
+ should be looked into some more */
+ # define NO_PTHREAD_TRYLOCK
+ # endif
++# ifdef OPENBSD
++# define OS_TYPE "OPENBSD"
++# define ALIGNMENT 4
++# define SIG_SUSPEND SIGXFSZ
++# define SIG_THR_RESTART SIGXCPU
++# ifndef GC_OPENBSD_THREADS
++# include <sys/param.h>
++# include <uvm/uvm_extern.h>
++# define STACKBOTTOM USRSTACK
++# endif
++ extern int __data_start[];
++# define DATASTART ((ptr_t)(__data_start))
++ extern char _end[];
++# define DATAEND ((ptr_t)(&_end))
++# define DYNAMIC_LOADING
++# define USE_MMAP
++# define USE_MMAP_ANON
++# endif
+ # ifdef FREEBSD
+ # define ALIGNMENT 4
+ # define OS_TYPE "FREEBSD"
+@@ -994,9 +1013,20 @@
+ # endif
+ # ifdef OPENBSD
+ # define OS_TYPE "OPENBSD"
+-# define STACKBOTTOM ((ptr_t) 0xf8000000)
+- extern int etext[];
+-# define DATASTART ((ptr_t)(etext))
++# define SIG_SUSPEND SIGXFSZ
++# define SIG_THR_RESTART SIGXCPU
++# ifndef GC_OPENBSD_THREADS
++# include <sys/param.h>
++# include <uvm/uvm_extern.h>
++# define STACKBOTTOM USRSTACK
++# endif
++ extern int __data_start[];
++# define DATASTART ((ptr_t)(__data_start))
++ extern char _end[];
++# define DATAEND ((ptr_t)(&_end))
++# define DYNAMIC_LOADING
++# define USE_MMAP
++# define USE_MMAP_ANON
+ # endif
+ # ifdef NETBSD
+ # define OS_TYPE "NETBSD"
+@@ -1250,6 +1280,20 @@
+ # endif
+ # ifdef OPENBSD
+ # define OS_TYPE "OPENBSD"
++# define SIG_SUSPEND SIGXFSZ
++# define SIG_THR_RESTART SIGXCPU
++# ifndef GC_OPENBSD_THREADS
++# include <sys/param.h>
++# include <uvm/uvm_extern.h>
++# define STACKBOTTOM USRSTACK
++# endif
++ extern int __data_start[];
++# define DATASTART ((ptr_t)(__data_start))
++ extern char _end[];
++# define DATAEND ((ptr_t)(&_end))
++# define DYNAMIC_LOADING
++# define USE_MMAP
++# define USE_MMAP_ANON
+ # endif
+ # ifdef FREEBSD
+ # define OS_TYPE "FREEBSD"
+@@ -1285,7 +1329,7 @@
+ # ifdef BSDI
+ # define OS_TYPE "BSDI"
+ # endif
+-# if defined(OPENBSD) || defined(NETBSD) \
++# if defined(NETBSD) \
+ || defined(THREE86BSD) || defined(BSDI)
+ # define HEURISTIC2
+ extern char etext[];
+@@ -1475,6 +1519,24 @@
+ # define STACKBOTTOM ((ptr_t) 0x7ffff000)
+ # endif /* _ELF_ */
+ # endif
++# ifdef OPENBSD
++# define OS_TYPE "OPENBSD"
++# define ALIGNMENT 4
++# define SIG_SUSPEND SIGXFSZ
++# define SIG_THR_RESTART SIGXCPU
++# ifndef GC_OPENBSD_THREADS
++# include <sys/param.h>
++# include <uvm/uvm_extern.h>
++# define STACKBOTTOM USRSTACK
++# endif
++ extern int _fdata[];
++# define DATASTART ((ptr_t)(_fdata))
++ extern char _end[];
++# define DATAEND ((ptr_t)(&_end))
++# define DYNAMIC_LOADING
++# define USE_MMAP
++# define USE_MMAP_ANON
++# endif
+ # endif
+
+ # ifdef RS6000
+@@ -1522,7 +1584,7 @@
+ # define ALIGNMENT 4
+ # define ALIGN_DOUBLE
+ # endif
+-# if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
++# if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS) && !defined(OPENBSD)
+ # ifndef LINUX /* For now. */
+ # define MPROTECT_VDB
+ # endif
+@@ -1574,6 +1636,23 @@
+ extern int _end[];
+ # define DATAEND (&_end)
+ # endif /* LINUX */
++# ifdef OPENBSD
++# define OS_TYPE "OPENBSD"
++# define SIG_SUSPEND SIGXFSZ
++# define SIG_THR_RESTART SIGXCPU
++# ifndef GC_OPENBSD_THREADS
++# include <sys/param.h>
++# include <uvm/uvm_extern.h>
++# define STACKBOTTOM USRSTACK
++# endif
++ extern int __data_start[];
++# define DATASTART ((ptr_t)(__data_start))
++ extern char _end[];
++# define DATAEND ((ptr_t)(&_end))
++# define DYNAMIC_LOADING
++# define USE_MMAP
++# define USE_MMAP_ANON
++# endif
+ # endif /* HP_PA */
+
+ # ifdef ALPHA
+@@ -1598,15 +1677,21 @@
+ # endif
+ # ifdef OPENBSD
+ # define OS_TYPE "OPENBSD"
+-# define HEURISTIC2
+-# ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
+-# define DATASTART GC_data_start
+-# define ELFCLASS32 32
+-# define ELFCLASS64 64
+-# define ELF_CLASS ELFCLASS64
+-# else /* ECOFF, until OpenBSD/Alpha 2.7 */
+-# define DATASTART ((ptr_t) 0x140000000)
+-# endif
++# define ELF_CLASS ELFCLASS64
++# define SIG_SUSPEND SIGXFSZ
++# define SIG_THR_RESTART SIGXCPU
++# ifndef GC_OPENBSD_THREADS
++# include <sys/param.h>
++# include <uvm/uvm_extern.h>
++# define STACKBOTTOM USRSTACK
++# endif
++ extern int __data_start[];
++# define DATASTART ((ptr_t)(__data_start))
++ extern char _end[];
++# define DATAEND ((ptr_t)(&_end))
++# define DYNAMIC_LOADING
++# define USE_MMAP
++# define USE_MMAP_ANON
+ # endif
+ # ifdef FREEBSD
+ # define OS_TYPE "FREEBSD"
+@@ -1786,6 +1871,7 @@
+ # ifdef CX_UX
+ # define OS_TYPE "CX_UX"
+ # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
++# define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
+ # endif
+ # ifdef DGUX
+ # define OS_TYPE "DGUX"
+@@ -1896,6 +1982,24 @@
+ # define OS_TYPE "MSWINCE"
+ # define DATAEND /* not needed */
+ # endif
++# ifdef OPENBSD
++# define ALIGNMENT 4
++# define OS_TYPE "OPENBSD"
++# define SIG_SUSPEND SIGXFSZ
++# define SIG_THR_RESTART SIGXCPU
++# ifndef GC_OPENBSD_THREADS
++# include <sys/param.h>
++# include <uvm/uvm_extern.h>
++# define STACKBOTTOM USRSTACK
++# endif
++ extern int __data_start[];
++# define DATASTART ((ptr_t)(__data_start))
++ extern char _end[];
++# define DATAEND ((ptr_t)(&_end))
++# define DYNAMIC_LOADING
++# define USE_MMAP
++# define USE_MMAP_ANON
++# endif
+ # ifdef NOSYS
+ /* __data_start is usually defined in the target linker script. */
+ extern int __data_start[];
+@@ -1943,6 +2047,23 @@
+ # define USE_GENERIC_PUSH_REGS
+ # define DYNAMIC_LOADING
+ # endif
++# ifdef OPENBSD
++# define OS_TYPE "OPENBSD"
++# define SIG_SUSPEND SIGXFSZ
++# define SIG_THR_RESTART SIGXCPU
++# ifndef GC_OPENBSD_THREADS
++# include <sys/param.h>
++# include <uvm/uvm_extern.h>
++# define STACKBOTTOM USRSTACK
++# endif
++ extern int __data_start[];
++# define DATASTART ((ptr_t)(__data_start))
++ extern char _end[];
++# define DATAEND ((ptr_t)(&_end))
++# define DYNAMIC_LOADING
++# define USE_MMAP
++# define USE_MMAP_ANON
++# endif
+ # endif
+
+ # ifdef SH4
+@@ -1976,6 +2097,24 @@
+ # ifndef HBLKSIZE
+ # define HBLKSIZE 4096
+ # endif
++# ifdef OPENBSD
++# define OS_TYPE "OPENBSD"
++# define ELF_CLASS ELFCLASS64
++# define SIG_SUSPEND SIGXFSZ
++# define SIG_THR_RESTART SIGXCPU
++# ifndef GC_OPENBSD_THREADS
++# include <sys/param.h>
++# include <uvm/uvm_extern.h>
++# define STACKBOTTOM USRSTACK
++# endif
++ extern int __data_start[];
++# define DATASTART ((ptr_t)(__data_start))
++ extern char _end[];
++# define DATAEND ((ptr_t)(&_end))
++# define DYNAMIC_LOADING
++# define USE_MMAP
++# define USE_MMAP_ANON
++# endif
+ # define CACHE_LINE_SIZE 64
+ # define USE_GENERIC_PUSH_REGS
+ # ifdef LINUX
diff --git a/lang/gcc46/patches/patch-boehm-gc_mach__dep.c b/lang/gcc46/patches/patch-boehm-gc_mach__dep.c
new file mode 100644
index 00000000000..4f6d32fc648
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_mach__dep.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-boehm-gc_mach__dep.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/mach_dep.c.orig 2006-01-25 03:03:14.000000000 +0000
++++ boehm-gc/mach_dep.c
+@@ -27,7 +27,7 @@
+ # endif
+ # endif
+
+-#if defined(RS6000) || defined(POWERPC)
++#if (defined(RS6000) || defined(POWERPC)) && !defined(OPENBSD)
+ # include <ucontext.h>
+ #endif
+
+@@ -417,7 +417,7 @@ ptr_t arg;
+ /* the stack. */
+ __builtin_unwind_init();
+ # else /* !HAVE_BUILTIN_UNWIND_INIT */
+-# if defined(RS6000) || defined(POWERPC)
++# if (defined(RS6000) || defined(POWERPC)) && !defined(OPENBSD)
+ /* FIXME: RS6000 means AIX. */
+ /* This should probably be used in all Posix/non-gcc */
+ /* settings. We defer that change to minimize risk. */
diff --git a/lang/gcc46/patches/patch-boehm-gc_os__dep.c b/lang/gcc46/patches/patch-boehm-gc_os__dep.c
new file mode 100644
index 00000000000..7ac3811e0e1
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_os__dep.c
@@ -0,0 +1,177 @@
+$NetBSD: patch-boehm-gc_os__dep.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/os_dep.c.orig 2010-03-21 19:34:19.000000000 +0000
++++ boehm-gc/os_dep.c
+@@ -380,7 +380,7 @@ static void *tiny_sbrk(ptrdiff_t increme
+ #define sbrk tiny_sbrk
+ # endif /* ECOS */
+
+-#if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__)
++#if defined(NETBSD) && defined(__ELF__)
+ ptr_t GC_data_start;
+
+ void GC_init_netbsd_elf()
+@@ -393,6 +393,86 @@ static void *tiny_sbrk(ptrdiff_t increme
+ }
+ #endif
+
++#if defined(OPENBSD)
++ static struct sigaction old_segv_act;
++ sigjmp_buf GC_jmp_buf_openbsd;
++
++ /*ARGSUSED*/
++ void GC_fault_handler_openbsd(int sig)
++ {
++ siglongjmp(GC_jmp_buf_openbsd, 1);
++ }
++
++ /* Return the first nonaddressible location > p or bound */
++ /* Requires allocation lock. */
++ ptr_t GC_find_limit_openbsd(ptr_t p, ptr_t bound)
++ {
++ static volatile ptr_t result;
++ /* Safer if static, since otherwise it may not be */
++ /* preserved across the longjmp. Can safely be */
++ /* static since it's only called with the */
++ /* allocation lock held. */
++ struct sigaction act;
++ size_t pgsz = (size_t)sysconf(_SC_PAGESIZE);
++
++ GC_ASSERT(I_HOLD_LOCK());
++
++ act.sa_handler = GC_fault_handler_openbsd;
++ sigemptyset(&act.sa_mask);
++ act.sa_flags = SA_NODEFER | SA_RESTART;
++ sigaction(SIGSEGV, &act, &old_segv_act);
++
++ if (sigsetjmp(GC_jmp_buf_openbsd, 1) == 0) {
++ result = (ptr_t)(((word)(p)) & ~(pgsz-1));
++ for (;;) {
++ result += pgsz;
++ if (result >= bound) {
++ result = bound;
++ break;
++ }
++ GC_noop1((word)(*result));
++ }
++ }
++
++ sigaction(SIGSEGV, &old_segv_act, 0);
++
++ return(result);
++ }
++
++ /* Return first addressable location > p or bound */
++ /* Requires allocation lock. */
++ ptr_t GC_skip_hole_openbsd(ptr_t p, ptr_t bound)
++ {
++ static volatile ptr_t result;
++ struct sigaction act;
++ size_t pgsz = (size_t)sysconf(_SC_PAGESIZE);
++ static volatile int firstpass;
++
++ GC_ASSERT(I_HOLD_LOCK());
++
++ act.sa_handler = GC_fault_handler_openbsd;
++ sigemptyset(&act.sa_mask);
++ act.sa_flags = SA_NODEFER | SA_RESTART;
++ sigaction(SIGSEGV, &act, &old_segv_act);
++
++ firstpass = 1;
++ result = (ptr_t)(((word)(p)) & ~(pgsz-1));
++ if (sigsetjmp(GC_jmp_buf_openbsd, 1) != 0 || firstpass) {
++ firstpass = 0;
++ result += pgsz;
++ if (result >= bound) {
++ result = bound;
++ } else
++ GC_noop1((word)(*result));
++ }
++
++ sigaction(SIGSEGV, &old_segv_act, 0);
++
++ return(result);
++ }
++#endif
++
++
+ # ifdef OS2
+
+ # include <stddef.h>
+@@ -1009,7 +1089,8 @@ ptr_t GC_get_stack_base()
+ #endif /* FREEBSD_STACKBOTTOM */
+
+ #if !defined(BEOS) && !defined(AMIGA) && !defined(MSWIN32) \
+- && !defined(MSWINCE) && !defined(OS2) && !defined(NOSYS) && !defined(ECOS)
++ && !defined(MSWINCE) && !defined(OS2) && !defined(NOSYS) && !defined(ECOS) \
++ && !defined(GC_OPENBSD_THREADS)
+
+ ptr_t GC_get_stack_base()
+ {
+@@ -1069,6 +1150,25 @@ ptr_t GC_get_stack_base()
+
+ # endif /* ! AMIGA, !OS 2, ! MS Windows, !BEOS, !NOSYS, !ECOS */
+
++#if defined(GC_OPENBSD_THREADS)
++
++/* Find the stack using pthread_stackseg_np() */
++
++# include <sys/signal.h>
++# include <pthread.h>
++# include <pthread_np.h>
++
++#define HAVE_GET_STACK_BASE
++
++ptr_t GC_get_stack_base()
++{
++ stack_t stack;
++ pthread_stackseg_np(pthread_self(), &stack);
++ return stack.ss_sp;
++}
++#endif /* GC_OPENBSD_THREADS */
++
++
+ /*
+ * Register static data segment(s) as roots.
+ * If more data segments are added later then they need to be registered
+@@ -1440,6 +1540,32 @@ int * etext_addr;
+
+ #else /* !OS2 && !Windows && !AMIGA */
+
++#if defined(OPENBSD)
++
++/*
++ * Depending on arch alignment there can be multiple holes
++ * between DATASTART & DATAEND. Scan from DATASTART - DATAEND
++ * and register each region.
++ */
++void GC_register_data_segments(void)
++{
++ ptr_t region_start, region_end;
++
++ region_start = DATASTART;
++
++ for(;;) {
++ region_end = GC_find_limit_openbsd(region_start, DATAEND);
++ GC_add_roots_inner(region_start, region_end, FALSE);
++ if (region_end < DATAEND)
++ region_start = GC_skip_hole_openbsd(region_end, DATAEND);
++ else
++ break;
++ }
++}
++
++# else /* !OS2 && !Windows && !AMIGA && !OPENBSD */
++
++
+ void GC_register_data_segments()
+ {
+ # if !defined(PCR) && !defined(SRC_M3) && !defined(MACOS)
+@@ -1497,6 +1623,7 @@ void GC_register_data_segments()
+ /* change. */
+ }
+
++# endif /* ! OPENBSD */
+ # endif /* ! AMIGA */
+ # endif /* ! MSWIN32 && ! MSWINCE*/
+ # endif /* ! OS2 */
diff --git a/lang/gcc46/patches/patch-boehm-gc_pthread__support.c b/lang/gcc46/patches/patch-boehm-gc_pthread__support.c
new file mode 100644
index 00000000000..677fd95ef33
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_pthread__support.c
@@ -0,0 +1,35 @@
+$NetBSD: patch-boehm-gc_pthread__support.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/pthread_support.c.orig 2010-12-10 10:09:10.000000000 +0000
++++ boehm-gc/pthread_support.c
+@@ -118,6 +118,10 @@
+ # include <fcntl.h>
+ # include <signal.h>
+
++#if defined(GC_OPENBSD_THREADS)
++# include <pthread_np.h>
++#endif
++
+ #if defined(GC_DARWIN_THREADS)
+ # include "private/darwin_semaphore.h"
+ #else
+@@ -884,7 +888,7 @@ void GC_thr_init()
+ GC_nprocs = pthread_num_processors_np();
+ # endif
+ # if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS) \
+- || defined(GC_SOLARIS_PTHREADS)
++ || defined(GC_SOLARIS_PTHREADS) || defined(GC_OPENBSD_THREADS)
+ GC_nprocs = sysconf(_SC_NPROCESSORS_ONLN);
+ if (GC_nprocs <= 0) GC_nprocs = 1;
+ # endif
+@@ -1156,6 +1160,10 @@ GC_PTR GC_get_thread_stack_base()
+ return stack_addr;
+ # endif
+
++# elif defined(GC_OPENBSD_THREADS)
++ stack_t stack;
++ pthread_stackseg_np(pthread_self(), &stack);
++ return stack.ss_sp;
+ # else
+ # ifdef DEBUG_THREADS
+ GC_printf0("Can not determine stack base for attached thread");
diff --git a/lang/gcc46/patches/patch-boehm-gc_tests_test.c b/lang/gcc46/patches/patch-boehm-gc_tests_test.c
new file mode 100644
index 00000000000..0e5283af02b
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_tests_test.c
@@ -0,0 +1,14 @@
+$NetBSD: patch-boehm-gc_tests_test.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/tests/test.c.orig 2010-12-10 10:09:10.000000000 +0000
++++ boehm-gc/tests/test.c
+@@ -1804,7 +1804,8 @@ main()
+
+ pthread_attr_init(&attr);
+ # if defined(GC_IRIX_THREADS) || defined(GC_FREEBSD_THREADS) \
+- || defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)
++ || defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS) \
++ || defined(GC_OPENBSD_THREADS)
+ pthread_attr_setstacksize(&attr, 1000000);
+ # endif
+ n_tests = 0;
diff --git a/lang/gcc46/patches/patch-boehm-gc_threadlibs.c b/lang/gcc46/patches/patch-boehm-gc_threadlibs.c
new file mode 100644
index 00000000000..7ccee53b9c1
--- /dev/null
+++ b/lang/gcc46/patches/patch-boehm-gc_threadlibs.c
@@ -0,0 +1,14 @@
+$NetBSD: patch-boehm-gc_threadlibs.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- boehm-gc/threadlibs.c.orig 2006-01-25 03:03:14.000000000 +0000
++++ boehm-gc/threadlibs.c
+@@ -15,6 +15,9 @@ int main()
+ || defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)
+ printf("-lpthread\n");
+ # endif
++# if defined(GC_OPENBSD_THREADS)
++ printf("-pthread\n");
++# endif
+ # if defined(GC_FREEBSD_THREADS)
+ # if (__FREEBSD_version >= 500000)
+ printf("-lpthread\n");
diff --git a/lang/gcc46/patches/patch-gcc_common.opt b/lang/gcc46/patches/patch-gcc_common.opt
new file mode 100644
index 00000000000..528e52293c5
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_common.opt
@@ -0,0 +1,71 @@
+$NetBSD: patch-gcc_common.opt,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/common.opt.orig 2013-01-14 16:35:23.000000000 +0000
++++ gcc/common.opt
+@@ -546,6 +546,10 @@ Wlarger-than=
+ Common RejectNegative Joined UInteger Warning
+ -Wlarger-than=<number> Warn if an object is larger than <number> bytes
+
++Wstack-larger-than-
++Common RejectNegative Joined UInteger
++-Wstack-larger-than-<number> Warn if a function is using more than <number> bytes of stack space for its local variables.
++
+ Wunsafe-loop-optimizations
+ Common Var(warn_unsafe_loop_optimizations) Warning
+ Warn if the loop cannot be optimized due to nontrivial assumptions.
+@@ -619,7 +623,7 @@ Common Var(warn_switch_enum) Warning
+ Warn about all enumerated switches missing a specific case
+
+ Wsystem-headers
+-Common Var(warn_system_headers) Warning
++Common Var(warn_system_headers) Init(1) Warning
+ Do not suppress warnings from system headers
+
+ Wtrampolines
+@@ -670,6 +674,10 @@ Wunused-variable
+ Common Var(warn_unused_variable) Init(-1) Warning
+ Warn when a variable is unused
+
++Wvariable-decl
++Common Var(warn_variable_decl)
++Warn about variable-sized declarations
++
+ Wcoverage-mismatch
+ Common Var(warn_coverage_mismatch) Init(1) Warning
+ Warn in case profiles in -fprofile-use do not match
+@@ -941,7 +949,7 @@ Common Report Var(flag_delayed_branch) O
+ Attempt to fill delay slots of branch instructions
+
+ fdelete-null-pointer-checks
+-Common Report Var(flag_delete_null_pointer_checks) Init(1) Optimization
++Common Report Var(flag_delete_null_pointer_checks)
+ Delete useless null pointer checks
+
+ fdevirtualize
+@@ -1164,7 +1172,7 @@ Enable guessing of branch probabilities
+ ; On SVR4 targets, it also controls whether or not to emit a
+ ; string identifying the compiler.
+ fident
+-Common Report Var(flag_no_ident,0)
++Common Report Var(flag_no_ident,0) Init(1)
+ Process #ident directives
+
+ fif-conversion
+@@ -1492,7 +1500,7 @@ Common Report Var(flag_pic,2)
+ Generate position-independent code if possible (large mode)
+
+ fPIE
+-Common Report Var(flag_pie,2)
++Common Report Var(flag_pie,2) Init(PIE_DEFAULT)
+ Generate position-independent code for executables if possible (large mode)
+
+ fpic
+@@ -1782,7 +1790,7 @@ Common RejectNegative Joined Var(common_
+ -fstack-limit-symbol=<name> Trap if the stack goes past symbol <name>
+
+ fstack-protector
+-Common Report Var(flag_stack_protect, 1)
++Common Report Var(flag_stack_protect, 1) Init(-1)
+ Use propolice as a stack protection method
+
+ fstack-protector-all
diff --git a/lang/gcc46/patches/patch-gcc_config.host b/lang/gcc46/patches/patch-gcc_config.host
new file mode 100644
index 00000000000..c0ff78e16d4
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_config.host
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_config.host,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/config.host.orig 2011-02-15 09:49:14.000000000 +0000
++++ gcc/config.host
+@@ -268,6 +268,10 @@ case ${host} in
+ out_host_hook_obj=host-solaris.o
+ host_xmake_file="${host_xmake_file} x-solaris"
+ ;;
++ *-*-openbsd*)
++ out_host_hook_obj=host-openbsd.o
++ host_xmake_file="${host_xmake_file} x-openbsd"
++ ;;
+ *-*-linux*)
+ out_host_hook_obj=host-linux.o
+ host_xmake_file="${host_xmake_file} x-linux"
diff --git a/lang/gcc46/patches/patch-gcc_config_exec-stack.h b/lang/gcc46/patches/patch-gcc_config_exec-stack.h
new file mode 100644
index 00000000000..7e89a4c25ab
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_config_exec-stack.h
@@ -0,0 +1,45 @@
+$NetBSD: patch-gcc_config_exec-stack.h,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/config/exec-stack.h.orig 2014-01-25 06:53:23.000000000 +0000
++++ gcc/config/exec-stack.h
+@@ -0,0 +1,40 @@
++/* Enable stack execute around trampoline address.
++ Copyright (C) 2002 Free Software Foundation, Inc.
++
++This file is part of GNU CC.
++
++GNU CC is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2, or (at your option)
++any later version.
++
++GNU CC 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 GNU CC; see the file COPYING. If not, write to
++the Free Software Foundation, 59 Temple Place - Suite 330,
++Boston, MA 02111-1307, USA. */
++
++#undef FINALIZE_TRAMPOLINE
++#define FINALIZE_TRAMPOLINE(TRAMP) \
++ emit_library_call(gen_rtx_SYMBOL_REF (Pmode, "__enable_execute_stack"), \
++ 0, VOIDmode, 1, memory_address (SImode, (TRAMP)), Pmode)
++
++#undef TRANSFER_FROM_TRAMPOLINE
++#define TRANSFER_FROM_TRAMPOLINE \
++extern void __enable_execute_stack (void *); \
++void \
++__enable_execute_stack (addr) \
++ void *addr; \
++{ \
++ long size = getpagesize (); \
++ long mask = ~(size-1); \
++ char *page = (char *) (((long) addr) & mask); \
++ char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
++ \
++ if (mprotect (page, end - page, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) \
++ perror ("mprotect of trampoline code"); \
++}
diff --git a/lang/gcc46/patches/patch-gcc_config_host-openbsd.c b/lang/gcc46/patches/patch-gcc_config_host-openbsd.c
new file mode 100644
index 00000000000..e6b769e8e56
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_config_host-openbsd.c
@@ -0,0 +1,112 @@
+$NetBSD: patch-gcc_config_host-openbsd.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/config/host-openbsd.c.orig 2014-01-25 06:53:23.000000000 +0000
++++ gcc/config/host-openbsd.c
+@@ -0,0 +1,107 @@
++/* OpenBSD host-specific hook definitions.
++ Copyright (C) 2005 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 2, 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 COPYING. If not, write to the
++ Free Software Foundation, 59 Temple Place - Suite 330, Boston,
++ MA 02111-1307, USA. */
++
++#include <limits.h>
++#include <unistd.h>
++
++#include "config.h"
++#include "system.h"
++#include "coretypes.h"
++#include "hosthooks.h"
++#include "hosthooks-def.h"
++
++#undef HOST_HOOKS_GT_PCH_GET_ADDRESS
++#define HOST_HOOKS_GT_PCH_GET_ADDRESS openbsd_gt_pch_get_address
++
++#undef HOST_HOOKS_GT_PCH_USE_ADDRESS
++#define HOST_HOOKS_GT_PCH_USE_ADDRESS openbsd_gt_pch_use_address
++
++/* Return the address of the PCH address space, if the PCH will fit in it. */
++
++void *
++openbsd_gt_pch_get_address (size_t size, int fd ATTRIBUTE_UNUSED)
++{
++ void *base, *addr;
++ size_t pgsz;
++
++ if (size > INT_MAX)
++ return NULL;
++
++ pgsz = sysconf(_SC_PAGESIZE);
++ if (pgsz == (size_t)-1)
++ return NULL;
++
++ base = sbrk(0);
++
++ /* round up to nearest page */
++ base = (void *)(((long)base + (pgsz - 1)) & ~(pgsz - 1));
++ if (brk(base) != 0)
++ return NULL;
++
++ /* attempt to allocate size */
++ addr = sbrk(size);
++ if (addr == (void *)-1)
++ return NULL;
++
++ /* deallocate the memory */
++ if (brk(base) != 0)
++ return NULL;
++
++ /* confirm addr is as expected */
++ if (addr != base)
++ return NULL;
++
++ return base;
++}
++
++/* Return 0 if we can reserve the PCH address space. */
++
++int
++openbsd_gt_pch_use_address (void *base, size_t size, int fd ATTRIBUTE_UNUSED, size_t off ATTRIBUTE_UNUSED)
++{
++ void *addr;
++
++ if (size == 0)
++ return -1;
++
++ /* sanity check base address */
++ addr = sbrk(0);
++ if (addr == (void *)-1 || base < addr)
++ return -1;
++
++ /* set base for sbrk */
++ if (brk(base) != 0)
++ return -1;
++
++ /* attempt to get the memory */
++ addr = sbrk(size);
++ if (addr == (void *)-1)
++ return -1;
++
++ /* sanity check the result */
++ if (addr != base) {
++ brk(base);
++ return -1;
++ }
++
++ return 0;
++}
++
++const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
diff --git a/lang/gcc46/patches/patch-gcc_config_i386_openbsd.h b/lang/gcc46/patches/patch-gcc_config_i386_openbsd.h
new file mode 100644
index 00000000000..e586905700b
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_config_i386_openbsd.h
@@ -0,0 +1,27 @@
+$NetBSD: patch-gcc_config_i386_openbsd.h,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/config/i386/openbsd.h.orig 2007-08-02 10:49:31.000000000 +0000
++++ gcc/config/i386/openbsd.h
+@@ -40,10 +40,10 @@ along with GCC; see the file COPYING3.
+
+ /* This must agree with <machine/ansi.h> */
+ #undef SIZE_TYPE
+-#define SIZE_TYPE "unsigned int"
++#define SIZE_TYPE "long unsigned int"
+
+ #undef PTRDIFF_TYPE
+-#define PTRDIFF_TYPE "int"
++#define PTRDIFF_TYPE "long int"
+
+ #undef WCHAR_TYPE
+ #define WCHAR_TYPE "int"
+@@ -51,6 +51,9 @@ along with GCC; see the file COPYING3.
+ #undef WCHAR_TYPE_SIZE
+ #define WCHAR_TYPE_SIZE 32
+
++#undef WINT_TYPE
++#define WINT_TYPE "int"
++
+ /* Assembler format: overall framework. */
+
+ #undef ASM_APP_ON
diff --git a/lang/gcc46/patches/patch-gcc_config_i386_openbsd64.h b/lang/gcc46/patches/patch-gcc_config_i386_openbsd64.h
new file mode 100644
index 00000000000..e478588a29b
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_config_i386_openbsd64.h
@@ -0,0 +1,127 @@
+$NetBSD: patch-gcc_config_i386_openbsd64.h,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/config/i386/openbsd64.h.orig 2014-01-25 06:53:23.000000000 +0000
++++ gcc/config/i386/openbsd64.h
+@@ -0,0 +1,122 @@
++/* Configuration for an OpenBSD x86-64 target.
++
++ Copyright (C) 2003 Free Software Foundation, Inc.
++
++This file is part of GNU CC.
++
++GNU CC is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 2, or (at your option)
++any later version.
++
++GNU CC 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 GNU CC; see the file COPYING. If not, write to
++the Free Software Foundation, 59 Temple Place - Suite 330,
++Boston, MA 02111-1307, USA. */
++
++#undef TARGET_VERSION
++#define TARGET_VERSION fprintf (stderr, " (OpenBSD/x86-64 ELF)")
++
++/* This gets defined in tm.h->linux.h->svr4.h, and keeps us from using
++ libraries compiled with the native cc, so undef it. */
++#undef NO_DOLLAR_IN_LABEL
++
++/* Override the default comment-starter of "/". */
++#undef ASM_COMMENT_START
++#define ASM_COMMENT_START "#"
++
++/* Run-time target specifications */
++
++#define TARGET_OS_CPP_BUILTINS() \
++ do \
++ { \
++ OPENBSD_OS_CPP_BUILTINS_ELF(); \
++ if (TARGET_64BIT) \
++ OPENBSD_OS_CPP_BUILTINS_LP64(); \
++ } \
++ while (0)
++
++/* 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}"
++
++/* Layout of source language data types. */
++
++/* This must agree with <machine/_types.h> */
++#undef SIZE_TYPE
++#define SIZE_TYPE "long unsigned int"
++
++#undef PTRDIFF_TYPE
++#define PTRDIFF_TYPE "long int"
++
++#undef WCHAR_TYPE
++#define WCHAR_TYPE "int"
++
++#undef WCHAR_TYPE_SIZE
++#define WCHAR_TYPE_SIZE 32
++
++/* Assembler format: overall framework. */
++
++#undef ASM_APP_ON
++#define ASM_APP_ON "#APP\n"
++
++#undef ASM_APP_OFF
++#define ASM_APP_OFF "#NO_APP\n"
++
++#undef SET_ASM_OP
++#define SET_ASM_OP "\t.set\t"
++
++/* The following macros were originally stolen from i386v4.h.
++ These have to be defined to get PIC code correct. */
++
++/* Assembler format: dispatch tables. */
++
++/* Assembler format: sections. */
++
++/* Stack & calling: aggregate returns. */
++
++/* Don't default to pcc-struct-return, because gcc is the only compiler, and
++ we want to retain compatibility with older gcc versions. */
++#define DEFAULT_PCC_STRUCT_RETURN 0
++
++/* Assembler format: alignment output. */
++
++/* Stack & calling: profiling. */
++
++/* OpenBSD's profiler recovers all information from the stack pointer.
++ The icky part is not here, but in machine/profile.h. */
++#undef FUNCTION_PROFILER
++#define FUNCTION_PROFILER(FILE, LABELNO) \
++ fputs (flag_pic ? "\tcall __mcount@PLT\n": "\tcall __mcount\n", FILE);
++
++/* Assembler format: exception region output. */
++
++/* Assembler format: alignment output. */
++
++/* Note that we pick up ASM_OUTPUT_MAX_SKIP_ALIGN from i386/gas.h */
++
++/* Note that we pick up ASM_OUTPUT_MI_THUNK from unix.h. */
++
++#undef LINK_SPEC
++#define LINK_SPEC \
++ "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e __start}}}} \
++ %{shared:-shared} %{R*} \
++ %{static:-Bstatic} \
++ %{!static:-Bdynamic} \
++ %{rdynamic:-export-dynamic} \
++ %{assert*} \
++ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.so}"
++
++#define OBSD_HAS_CORRECT_SPECS
++
++#undef JUMP_TABLES_IN_TEXT_SECTION
++#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic)
diff --git a/lang/gcc46/patches/patch-gcc_config_i386_openbsdelf.h b/lang/gcc46/patches/patch-gcc_config_i386_openbsdelf.h
new file mode 100644
index 00000000000..c8f13bab12d
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_config_i386_openbsdelf.h
@@ -0,0 +1,25 @@
+$NetBSD: patch-gcc_config_i386_openbsdelf.h,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/config/i386/openbsdelf.h.orig 2010-12-22 12:06:01.000000000 +0000
++++ gcc/config/i386/openbsdelf.h
+@@ -113,9 +113,6 @@ along with GCC; see the file COPYING3.
+
+ /* Assembler format: exception region output. */
+
+-/* our configuration still doesn't handle dwarf2 correctly */
+-#define DWARF2_UNWIND_INFO 0
+-
+ /* Assembler format: alignment output. */
+
+ /* Note that we pick up ASM_OUTPUT_MAX_SKIP_ALIGN from i386/gas.h */
+@@ -128,7 +125,10 @@ along with GCC; see the file COPYING3.
+ %{shared:-shared} %{R*} \
+ %{static:-Bstatic} \
+ %{!static:-Bdynamic} \
++ %{rdynamic:-export-dynamic} \
+ %{assert*} \
+ -dynamic-linker /usr/libexec/ld.so"
+
+ #define OBSD_HAS_CORRECT_SPECS
++
++#define SUBTARGET32_DEFAULT_CPU "i486"
diff --git a/lang/gcc46/patches/patch-gcc_config_openbsd-libpthread.h b/lang/gcc46/patches/patch-gcc_config_openbsd-libpthread.h
new file mode 100644
index 00000000000..1c946a22204
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_config_openbsd-libpthread.h
@@ -0,0 +1,11 @@
+$NetBSD: patch-gcc_config_openbsd-libpthread.h,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/config/openbsd-libpthread.h.orig 2009-09-27 13:20:23.000000000 +0000
++++ gcc/config/openbsd-libpthread.h
+@@ -18,5 +18,5 @@
+ along with GCC; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+-#define OBSD_LIB_SPEC "%{!shared:%{pthread:-lpthread} -lc}"
++#define OBSD_LIB_SPEC "%{pthread:-lpthread%{!shared:%{p|pg:_p}}} %{!shared:-lc%{p:_p}%{!p:%{pg:_p}}}"
+
diff --git a/lang/gcc46/patches/patch-gcc_config_openbsd.h b/lang/gcc46/patches/patch-gcc_config_openbsd.h
new file mode 100644
index 00000000000..b4666636cba
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_config_openbsd.h
@@ -0,0 +1,16 @@
+$NetBSD: patch-gcc_config_openbsd.h,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/config/openbsd.h.orig 2010-12-22 12:06:01.000000000 +0000
++++ gcc/config/openbsd.h
+@@ -109,9 +109,9 @@ while (0)
+ This two-stage defines makes it easy to pick that for targets that
+ have subspecs. */
+ #ifdef CPP_CPU_SPEC
+-#define OBSD_CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
++#define OBSD_CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+ #else
+-#define OBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_POSIX_THREADS}"
++#define OBSD_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+ #endif
+
+ #undef LIB_SPEC
diff --git a/lang/gcc46/patches/patch-gcc_config_t-openbsd b/lang/gcc46/patches/patch-gcc_config_t-openbsd
new file mode 100644
index 00000000000..2e938738162
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_config_t-openbsd
@@ -0,0 +1,13 @@
+$NetBSD: patch-gcc_config_t-openbsd,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/config/t-openbsd.orig 2003-09-23 18:56:00.000000000 +0000
++++ gcc/config/t-openbsd
+@@ -1,2 +1,7 @@
+ # We don't need GCC's own include files.
+-USER_H =
++USER_H = $(EXTRA_HEADERS)
++# Use unwind-dw2-fde-glibc
++LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde-openbsd.c \
++ $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
++LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h unwind-dw2-fde.c \
++ unwind-dw2-fde-glibc.c
diff --git a/lang/gcc46/patches/patch-gcc_config_x-openbsd b/lang/gcc46/patches/patch-gcc_config_x-openbsd
new file mode 100644
index 00000000000..5f7038f67dc
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_config_x-openbsd
@@ -0,0 +1,9 @@
+$NetBSD: patch-gcc_config_x-openbsd,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/config/x-openbsd.orig 2014-01-25 06:53:23.000000000 +0000
++++ gcc/config/x-openbsd
+@@ -0,0 +1,4 @@
++host-openbsd.o : $(srcdir)/config/host-openbsd.c $(CONFIG_H) $(SYSTEM_H) \
++ coretypes.h hosthooks.h hosthooks-def.h $(HOOKS_H)
++ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
++ $(srcdir)/config/host-openbsd.c
diff --git a/lang/gcc46/patches/patch-gcc_configure b/lang/gcc46/patches/patch-gcc_configure
new file mode 100644
index 00000000000..f005b932637
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_configure
@@ -0,0 +1,12 @@
+$NetBSD: patch-gcc_configure,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/configure.orig 2013-01-14 16:35:23.000000000 +0000
++++ gcc/configure
+@@ -25814,6 +25814,7 @@ else
+ fi
+
+ ;;
++ *-*-openbsd*) gcc_cv_libc_provides_ssp=no ;;
+ *) gcc_cv_libc_provides_ssp=no ;;
+ esac
+ fi
diff --git a/lang/gcc46/patches/patch-gcc_defaults.h b/lang/gcc46/patches/patch-gcc_defaults.h
new file mode 100644
index 00000000000..6584da59df0
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_defaults.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_defaults.h,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/defaults.h.orig 2010-11-29 14:09:41.000000000 +0000
++++ gcc/defaults.h
+@@ -1337,6 +1337,10 @@ see the files COPYING3 and COPYING.RUNTI
+ #define SWITCHABLE_TARGET 0
+ #endif
+
++#ifndef PIE_DEFAULT
++#define PIE_DEFAULT 0
++#endif
++
+ #endif /* GCC_INSN_FLAGS_H */
+
+ #endif /* ! GCC_DEFAULTS_H */
diff --git a/lang/gcc46/patches/patch-gcc_gcc.c b/lang/gcc46/patches/patch-gcc_gcc.c
new file mode 100644
index 00000000000..abdde3e1fb5
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_gcc.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-gcc_gcc.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/gcc.c.orig 2013-01-14 16:35:23.000000000 +0000
++++ gcc/gcc.c
+@@ -609,7 +609,7 @@ proper position among the other output f
+
+ #ifndef LINK_PIE_SPEC
+ #ifdef HAVE_LD_PIE
+-#define LINK_PIE_SPEC "%{pie:-pie} "
++#define LINK_PIE_SPEC "%{pie:-pie} %{p|pg|nopie:-nopie} "
+ #else
+ #define LINK_PIE_SPEC "%{pie:} "
+ #endif
diff --git a/lang/gcc46/patches/patch-gcc_lto_lto.c b/lang/gcc46/patches/patch-gcc_lto_lto.c
new file mode 100644
index 00000000000..c9353fc0250
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_lto_lto.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_lto_lto.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/lto/lto.c.orig 2012-04-23 12:44:46.000000000 +0000
++++ gcc/lto/lto.c
+@@ -2486,4 +2486,10 @@ lto_main (void)
+ }
+ }
+
++const char *
++fname_as_string(int pretty_p)
++{
++ return NULL;
++}
++
+ #include "gt-lto-lto.h"
diff --git a/lang/gcc46/patches/patch-gcc_opts.c b/lang/gcc46/patches/patch-gcc_opts.c
new file mode 100644
index 00000000000..a86c53d2dd2
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_opts.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-gcc_opts.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/opts.c.orig 2011-02-17 22:51:57.000000000 +0000
++++ gcc/opts.c
+@@ -691,6 +691,8 @@ finish_options (struct gcc_options *opts
+
+ if (!opts->x_flag_opts_finished)
+ {
++ if (opts->x_flag_pic || opts->x_profile_flag)
++ opts->x_flag_pie = 0;
+ if (opts->x_flag_pie)
+ opts->x_flag_pic = opts->x_flag_pie;
+ if (opts->x_flag_pic && !opts->x_flag_pie)
diff --git a/lang/gcc46/patches/patch-gcc_unwind-dw2-fde-glibc.c b/lang/gcc46/patches/patch-gcc_unwind-dw2-fde-glibc.c
new file mode 100644
index 00000000000..f61823a62d3
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_unwind-dw2-fde-glibc.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-gcc_unwind-dw2-fde-glibc.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/unwind-dw2-fde-glibc.c.orig 2010-12-23 12:08:21.000000000 +0000
++++ gcc/unwind-dw2-fde-glibc.c
+@@ -33,7 +33,7 @@
+
+ #include "tconfig.h"
+ #include "tsystem.h"
+-#ifndef inhibit_libc
++#if !defined(inhibit_libc) && !defined(__OpenBSD__)
+ #include <elf.h> /* Get DT_CONFIG. */
+ #endif
+ #include "coretypes.h"
diff --git a/lang/gcc46/patches/patch-gcc_unwind-dw2-fde-openbsd.c b/lang/gcc46/patches/patch-gcc_unwind-dw2-fde-openbsd.c
new file mode 100644
index 00000000000..b77e0a3115b
--- /dev/null
+++ b/lang/gcc46/patches/patch-gcc_unwind-dw2-fde-openbsd.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_unwind-dw2-fde-openbsd.c,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- gcc/unwind-dw2-fde-openbsd.c.orig 2014-01-25 06:53:23.000000000 +0000
++++ gcc/unwind-dw2-fde-openbsd.c
+@@ -0,0 +1,10 @@
++/* XXX This file provides a few defines such that we can compile the
++ source from unwind-dw2-fde-glibc.c on OpenBSD. Hopefully we can
++ integrate these defines in that file and rename it to something
++ like unwind-de2-fde-phdr.c in the up-stream sources. */
++
++#define ElfW(type) Elf_##type
++
++#define __GLIBC__ 3 /* Fool unwind-dw2-fde-glibc.c. */
++#include "unwind-dw2-fde-glibc.c"
++
diff --git a/lang/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h b/lang/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h
index 14a36d29990..b54d2d5dec0 100644
--- a/lang/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h
+++ b/lang/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h
@@ -1,17 +1,17 @@
-$NetBSD: patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h,v 1.2 2013/04/30 22:24:16 joerg Exp $
+$NetBSD: patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h,v 1.3 2014/01/25 13:38:48 ryoon Exp $
---- libstdc++-v3/config/os/bsd/netbsd/ctype_base.h.orig 2011-01-30 22:39:36.000000000 +0000
+--- libstdc++-v3/config/os/bsd/netbsd/ctype_base.h.orig 2012-06-20 08:30:55.000000000 +0000
+++ libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
-@@ -30,8 +30,6 @@
+@@ -30,7 +30,7 @@
// Full details can be found from the CVS files at:
// anoncvs@anoncvs.netbsd.org:/cvsroot/basesrc/include/ctype.h
// See www.netbsd.org for details of access.
-
--#include <sys/param.h>
-
++
namespace std _GLIBCXX_VISIBILITY(default)
{
-@@ -45,21 +43,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+@@ -43,21 +43,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// NB: Offsets into ctype<char>::_M_table force a particular size
// on the mask type. Because of this, we don't use an enum.
@@ -31,7 +31,7 @@ $NetBSD: patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h,v 1.2 2013/04/30
+#elif defined(_CTYPE_U)
typedef unsigned char mask;
-
--#if __NetBSD_Version__ < 599004100
+-#ifndef _CTYPE_U
- static const mask upper = _U;
- static const mask lower = _L;
- static const mask alpha = _U | _L;
@@ -47,7 +47,7 @@ $NetBSD: patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h,v 1.2 2013/04/30
static const mask upper = _CTYPE_U;
static const mask lower = _CTYPE_L;
static const mask alpha = _CTYPE_U | _CTYPE_L;
-@@ -71,6 +69,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+@@ -69,6 +69,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static const mask cntrl = _CTYPE_C;
static const mask punct = _CTYPE_P;
static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N;
diff --git a/lang/gcc46/patches/patch-libstdc++-v3_include_std_mutex b/lang/gcc46/patches/patch-libstdc++-v3_include_std_mutex
new file mode 100644
index 00000000000..500e80d532d
--- /dev/null
+++ b/lang/gcc46/patches/patch-libstdc++-v3_include_std_mutex
@@ -0,0 +1,13 @@
+$NetBSD: patch-libstdc++-v3_include_std_mutex,v 1.1 2014/01/25 13:38:48 ryoon Exp $
+
+--- libstdc++-v3/include/std/mutex.orig 2012-07-07 18:35:52.000000000 +0000
++++ libstdc++-v3/include/std/mutex
+@@ -789,7 +789,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+ __get_once_mutex();
+ #endif
+
+- extern "C" void __once_proxy();
++ extern "C" void __once_proxy(void);
+
+ /// call_once
+ template<typename _Callable, typename... _Args>