pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Import gcc46-4.6.4nb5 as wip/gcc46.



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Thu Dec 22 15:02:09 2016 +0100
Changeset:	52a182beae4e68f152dd9315767fb2c5ebf5862d

Added Files:
	gcc46/DESCR
	gcc46/Makefile
	gcc46/TODO
	gcc46/buildlink3.mk
	gcc46/distinfo
	gcc46/files/dragonfly-spec.h
	gcc46/files/dragonfly.h
	gcc46/files/hello.f
	gcc46/files/hello.m
	gcc46/files/i386-dragonfly.h
	gcc46/files/i386-dragonfly64.h
	gcc46/files/patch-gcc_targhooks.c-openbsd.diff
	gcc46/files/values.c
	gcc46/hacks.mk
	gcc46/options.mk
	gcc46/patches/patch-aa
	gcc46/patches/patch-ab
	gcc46/patches/patch-ac
	gcc46/patches/patch-ad
	gcc46/patches/patch-af
	gcc46/patches/patch-ag
	gcc46/patches/patch-ah
	gcc46/patches/patch-ak
	gcc46/patches/patch-al
	gcc46/patches/patch-boehm-gc_configure
	gcc46/patches/patch-boehm-gc_dyn__load.c
	gcc46/patches/patch-boehm-gc_include_gc__config.h.in
	gcc46/patches/patch-boehm-gc_include_gc__config__macros.h
	gcc46/patches/patch-boehm-gc_include_gc__pthread__redirects.h
	gcc46/patches/patch-boehm-gc_include_private_gcconfig.h
	gcc46/patches/patch-boehm-gc_mach__dep.c
	gcc46/patches/patch-boehm-gc_os__dep.c
	gcc46/patches/patch-boehm-gc_pthread__support.c
	gcc46/patches/patch-boehm-gc_tests_test.c
	gcc46/patches/patch-boehm-gc_threadlibs.c
	gcc46/patches/patch-gcc_common.opt
	gcc46/patches/patch-gcc_config.host
	gcc46/patches/patch-gcc_config_arm_elf.h
	gcc46/patches/patch-gcc_config_arm_t-netbsd
	gcc46/patches/patch-gcc_config_exec-stack.h
	gcc46/patches/patch-gcc_config_host-netbsd.c
	gcc46/patches/patch-gcc_config_host-openbsd.c
	gcc46/patches/patch-gcc_config_i386_i386.c
	gcc46/patches/patch-gcc_config_i386_openbsd.h
	gcc46/patches/patch-gcc_config_i386_openbsd64.h
	gcc46/patches/patch-gcc_config_i386_openbsdelf.h
	gcc46/patches/patch-gcc_config_netbsd.h
	gcc46/patches/patch-gcc_config_openbsd-libpthread.h
	gcc46/patches/patch-gcc_config_openbsd.h
	gcc46/patches/patch-gcc_config_t-openbsd
	gcc46/patches/patch-gcc_config_x-netbsd
	gcc46/patches/patch-gcc_config_x-openbsd
	gcc46/patches/patch-gcc_configure
	gcc46/patches/patch-gcc_defaults.h
	gcc46/patches/patch-gcc_gcc.c
	gcc46/patches/patch-gcc_ggc-common.c
	gcc46/patches/patch-gcc_lto_lto.c
	gcc46/patches/patch-gcc_opts.c
	gcc46/patches/patch-gcc_unwind-dw2-fde-glibc.c
	gcc46/patches/patch-gcc_unwind-dw2-fde-openbsd.c
	gcc46/patches/patch-include_libiberty.h
	gcc46/patches/patch-libgcc_config_t-slibgcc-darwin
	gcc46/patches/patch-libiberty___doprnt.c
	gcc46/patches/patch-libiberty_asprintf.c
	gcc46/patches/patch-libiberty_concat.c
	gcc46/patches/patch-libiberty_snprintf.c
	gcc46/patches/patch-libiberty_vasprintf.c
	gcc46/patches/patch-libiberty_vsnprintf.c
	gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h
	gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__inline.h
	gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__noninline.h
	gcc46/patches/patch-libstdc++-v3_include_std_mutex

Log Message:
Import gcc46-4.6.4nb5 as wip/gcc46.

This is the gcc 4.6 compiler suite.

This package has a test target. For testing (only), this
package requires devel/dejagnu and devel/autogen.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=52a182beae4e68f152dd9315767fb2c5ebf5862d

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 gcc46/DESCR                                        |   4 +
 gcc46/Makefile                                     | 174 ++++++++++
 gcc46/TODO                                         |   3 +
 gcc46/buildlink3.mk                                |  33 ++
 gcc46/distinfo                                     |  63 ++++
 gcc46/files/dragonfly-spec.h                       | 215 +++++++++++++
 gcc46/files/dragonfly.h                            |  97 ++++++
 gcc46/files/hello.f                                |   5 +
 gcc46/files/hello.m                                |   6 +
 gcc46/files/i386-dragonfly.h                       | 148 +++++++++
 gcc46/files/i386-dragonfly64.h                     |  54 ++++
 gcc46/files/patch-gcc_targhooks.c-openbsd.diff     | 150 +++++++++
 gcc46/files/values.c                               |  64 ++++
 gcc46/hacks.mk                                     |   9 +
 gcc46/options.mk                                   | 128 ++++++++
 gcc46/patches/patch-aa                             | 203 ++++++++++++
 gcc46/patches/patch-ab                             |  53 +++
 gcc46/patches/patch-ac                             |  17 +
 gcc46/patches/patch-ad                             |  28 ++
 gcc46/patches/patch-af                             |  17 +
 gcc46/patches/patch-ag                             |  29 ++
 gcc46/patches/patch-ah                             |  37 +++
 gcc46/patches/patch-ak                             |  19 ++
 gcc46/patches/patch-al                             |  15 +
 gcc46/patches/patch-boehm-gc_configure             |  52 +++
 gcc46/patches/patch-boehm-gc_dyn__load.c           |  51 +++
 .../patches/patch-boehm-gc_include_gc__config.h.in |  14 +
 .../patch-boehm-gc_include_gc__config__macros.h    |  24 ++
 ...patch-boehm-gc_include_gc__pthread__redirects.h |  26 ++
 .../patch-boehm-gc_include_private_gcconfig.h      | 355 +++++++++++++++++++++
 gcc46/patches/patch-boehm-gc_mach__dep.c           |  22 ++
 gcc46/patches/patch-boehm-gc_os__dep.c             | 177 ++++++++++
 gcc46/patches/patch-boehm-gc_pthread__support.c    |  35 ++
 gcc46/patches/patch-boehm-gc_tests_test.c          |  14 +
 gcc46/patches/patch-boehm-gc_threadlibs.c          |  14 +
 gcc46/patches/patch-gcc_common.opt                 |  62 ++++
 gcc46/patches/patch-gcc_config.host                |  22 ++
 gcc46/patches/patch-gcc_config_arm_elf.h           |  14 +
 gcc46/patches/patch-gcc_config_arm_t-netbsd        |  19 ++
 gcc46/patches/patch-gcc_config_exec-stack.h        |  45 +++
 gcc46/patches/patch-gcc_config_host-netbsd.c       |  93 ++++++
 gcc46/patches/patch-gcc_config_host-openbsd.c      | 112 +++++++
 gcc46/patches/patch-gcc_config_i386_i386.c         |  32 ++
 gcc46/patches/patch-gcc_config_i386_openbsd.h      |  27 ++
 gcc46/patches/patch-gcc_config_i386_openbsd64.h    | 127 ++++++++
 gcc46/patches/patch-gcc_config_i386_openbsdelf.h   |  25 ++
 gcc46/patches/patch-gcc_config_netbsd.h            |  22 ++
 .../patches/patch-gcc_config_openbsd-libpthread.h  |  11 +
 gcc46/patches/patch-gcc_config_openbsd.h           |  16 +
 gcc46/patches/patch-gcc_config_t-openbsd           |  13 +
 gcc46/patches/patch-gcc_config_x-netbsd            |  12 +
 gcc46/patches/patch-gcc_config_x-openbsd           |   9 +
 gcc46/patches/patch-gcc_configure                  |  12 +
 gcc46/patches/patch-gcc_defaults.h                 |  15 +
 gcc46/patches/patch-gcc_gcc.c                      |  30 ++
 gcc46/patches/patch-gcc_ggc-common.c               |  86 +++++
 gcc46/patches/patch-gcc_lto_lto.c                  |  15 +
 gcc46/patches/patch-gcc_opts.c                     |  13 +
 gcc46/patches/patch-gcc_unwind-dw2-fde-glibc.c     |  13 +
 gcc46/patches/patch-gcc_unwind-dw2-fde-openbsd.c   |  15 +
 gcc46/patches/patch-include_libiberty.h            |  24 ++
 gcc46/patches/patch-libgcc_config_t-slibgcc-darwin |  26 ++
 gcc46/patches/patch-libiberty___doprnt.c           |  25 ++
 gcc46/patches/patch-libiberty_asprintf.c           |  24 ++
 gcc46/patches/patch-libiberty_concat.c             | 108 +++++++
 gcc46/patches/patch-libiberty_snprintf.c           |  25 ++
 gcc46/patches/patch-libiberty_vasprintf.c          |  24 ++
 gcc46/patches/patch-libiberty_vsnprintf.c          |  26 ++
 ...libstdc++-v3_config_os_bsd_netbsd_ctype__base.h |  69 ++++
 ...bstdc++-v3_config_os_bsd_netbsd_ctype__inline.h |  13 +
 ...dc++-v3_config_os_bsd_netbsd_ctype__noninline.h |  57 ++++
 gcc46/patches/patch-libstdc++-v3_include_std_mutex |  13 +
 72 files changed, 3649 insertions(+)

diffs:
diff --git a/gcc46/DESCR b/gcc46/DESCR
new file mode 100644
index 0000000..a1532b6
--- /dev/null
+++ b/gcc46/DESCR
@@ -0,0 +1,4 @@
+This is the gcc 4.6 compiler suite.
+
+This package has a test target. For testing (only), this
+package requires devel/dejagnu and devel/autogen.
diff --git a/gcc46/Makefile b/gcc46/Makefile
new file mode 100644
index 0000000..cf70308
--- /dev/null
+++ b/gcc46/Makefile
@@ -0,0 +1,174 @@
+# $NetBSD: Makefile,v 1.33 2016/10/19 21:09:40 sevan 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
+
+MAINTAINER=		sbd%NetBSD.org@localhost
+HOMEPAGE=		http://gcc.gnu.org/
+COMMENT=		GNU Compiler Collection 4.6
+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.4
+
+GCC_SUBPREFIX=		gcc46
+GCC_PREFIX=		${PREFIX}/${GCC_SUBPREFIX}
+FILES_SUBST+=		PKGNAME=${PKGNAME}
+MESSAGE_SUBST+=		GCC_PREFIX=${GCC_PREFIX}
+
+
+# To avoid GNU surprises
+CONFIG_SHELL=		${TOOLS_PATH.bash}
+
+NOT_FOR_PLATFORM=	Interix-*-* DragonFly-*-*
+UNLIMIT_RESOURCES+=	datasize
+UNLIMIT_RESOURCES+=	stacksize
+
+GCC_TARGET_MACHINE?=	${MACHINE_GNU_PLATFORM}
+SUBST_CLASSES+=		vars
+SUBST_STAGE.vars=	pre-configure
+SUBST_FILES.vars=	gcc/Makefile.in
+SUBST_VARS.vars=	GCC_TARGET_MACHINE
+
+.include "../../mk/bsd.prefs.mk"
+.include "options.mk"
+
+# Determine whether to use binutils
+.if ${OPSYS} == "SunOS"
+CONFIGURE_ENV+=		OBJDUMP=/usr/sfw/bin/gobjdump
+CONFIGURE_ARGS+=	--without-gnu-ld --with-ld=/usr/ccs/bin/ld
+. if !exists(/usr/sfw/bin/gas)
+CONFIGURE_ARGS+=	--without-gnu-as --with-as=/usr/ccs/bin/as
+. else
+CONFIGURE_ARGS+=	--with-gnu-as --with-as=/usr/sfw/bin/gas
+. endif
+.endif
+
+
+# REPLACE_AWK+=	gcc/testsuite/gcc.test-framework/test-framework.awk	\
+# 		gcc/mkmap-symver.awk					\
+# 		gcc/optc-gen.awk					\
+# 		gcc/mkmap-flat.awk					\
+# 		gcc/opt-gather.awk					\
+# 		gcc/opth-gen.awk					\
+# 		gcc/opt-functions.awk
+
+REPLACE_BASH+= contrib/dg-cmp-results.sh
+REPLACE_BASH+= contrib/reghunt/bin/gcc-svn-patchlist
+REPLACE_BASH+= contrib/reghunt/bin/gcc-svn-update
+REPLACE_BASH+= contrib/reghunt/bin/gcc-svn-update-fix
+REPLACE_BASH+= contrib/reghunt/bin/reg-hunt
+REPLACE_BASH+= contrib/reghunt/bin/reg-test
+REPLACE_BASH+= contrib/reghunt/date_based/reg_periodic
+REPLACE_BASH+= contrib/reghunt/date_based/reg_search
+REPLACE_BASH+= gcc/dbgcnt.def
+REPLACE_BASH+= gcc/testsuite/gcc.test-framework/gen_directive_tests
+REPLACE_BASH+= libstdc++-v3/scripts/run_doxygen
+
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-*)
+# on NetBSD, use the native SSP code in libc
+CONFIGURE_ARGS+=	--disable-libssp
+.else
+CONFIGURE_ARGS+=	--enable-libssp
+.endif
+
+CONFIGURE_ARGS+=	--prefix=${GCC_PREFIX:Q}
+CONFIGURE_ARGS+=	--enable-languages=${LANGS:Q}
+CONFIGURE_ARGS+=	--enable-shared
+CONFIGURE_ARGS+=	--enable-long-long
+CONFIGURE_ARGS+=	--with-local-prefix=${GCC_PREFIX:Q}
+CONFIGURE_ARGS+=	--enable-threads=posix
+
+CONFIGURE_ARGS.NetBSD+=	--with-gnu-ld --with-ld=/usr/bin/ld
+CONFIGURE_ARGS.NetBSD+=	--with-gnu-as --with-as=/usr/bin/as
+MAKE_ENV.NetBSD+=	ac_cv_func_clock_gettime=yes
+
+CONFIGURE_ARGS.Linux+=	--disable-libquadmath --disable-libquadmath-support
+
+# See ${WRKSRC}/libgcc/config/t-slibgcc-darwin: It uses strip(1) to
+# create a stub library, not just to remove symbols, so we must not
+# let strip(1) be a no-op regardless of ${INSTALL_UNSTRIPPED} or the
+# build fails for missing files.
+CONFIGURE_ARGS.Darwin+=	STRIP_FOR_TARGET=${TOOLS_PLATFORM.strip}
+
+.if !empty(MACHINE_PLATFORM:MDarwin-[0-8].*-*)
+CONFIGURE_ARGS+=        --with-dwarf2
+.endif
+
+.if !empty(MACHINE_PLATFORM:MDarwin-[0-8].*-powerpc)
+CONFIGURE_ARGS+=        --disable-multilib
+.endif
+
+CONFIGURE_ENV+=		CONFIG_SHELL=${CONFIG_SHELL}
+
+MAKE_ENV+=		SHELL=${CONFIG_SHELL}
+MAKE_ENV+=		ac_cv_path_ac_cv_prog_chmod=${TOOLS_CHMOD}
+
+# ${WRKSRC}/fixincludes/ looks for sed and compiles the path to sed into
+# a binary so we need to make sure we give it the installed sed and not
+# the tool wrapped one.
+MAKE_ENV+=		ac_cv_path_SED=${TOOLS_SED}
+MAKE_ENV+=		lt_cv_path_SED=${TOOLS_SED}
+
+CPPFLAGS+=		-I${BUILDLINK_DIR}/include
+CFLAGS+=		-I${BUILDLINK_DIR}/include
+
+
+# Someone should fix this so it will match the NetBSD system compiler
+#.if ${OPSYS} == "NetBSD"
+#GCC_PLATFORM=	${MACHINE_ARCH}--${LOWER_OPSYS}${APPEND_ELF}
+#CONFIGURE_ARGS+=	--host=${GCC_PLATFORM:Q}
+#MAKE_ENV+=		AR=/usr/bin/ar
+#.endif # NetBSD
+
+pre-configure:
+.if ${OPSYS} == "DragonFly"
+	${CP} ${FILESDIR}/dragonfly.h ${WRKSRC}/gcc/config/dragonfly.h
+	${CP} ${FILESDIR}/dragonfly-spec.h ${WRKSRC}/gcc/config/dragonfly-spec.h
+	${CP} ${FILESDIR}/i386-dragonfly.h ${WRKSRC}/gcc/config/i386/dragonfly.h
+	${CP} ${FILESDIR}/i386-dragonfly64.h ${WRKSRC}/gcc/config/i386/dragonfly64.h
+.endif
+
+.if ${OPSYS} == "NetBSD"
+	${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}
+
+do-build:
+	(${_ULIMIT_CMD} cd ${WRKDIR}/obj && ${SETENV} ${MAKE_ENV} ${GMAKE} -j${MAKE_JOBS:U1:Q} )
+
+do-test:
+#.if (${MACHINE_GNU_ARCH} == "x86_64")
+#	(cd ${FILESDIR} && ${CP} netbsd64macro.dfs ${WRKSRC}/gcc/testsuite/ada/acats/support/macro.dfs)
+#.endif
+	(${_ULIMIT_CMD} cd ${WRKDIR}/obj && ${GMAKE} -k check)
+
+do-install:
+	(cd ${WRKDIR}/obj && ${SETENV} ${MAKE_ENV} ${GMAKE} install DESTDIR=${DESTDIR} \
+	 && ${TEST} -f ${DESTDIR}${GCC_PREFIX}/bin/cc || ${LN} -f ${DESTDIR}${GCC_PREFIX}/bin/gcc ${DESTDIR}${GCC_PREFIX}/bin/cc)
+
+.if ${OPSYS} == "SunOS" && ${OS_VERSION} != "5.11" && !empty(MACHINE_ARCH:M*86*)
+post-install:
+	-${SH} files/values.c ${DESTDIR}${GCC_PREFIX}/bin/gcc -m32
+	-${SH} files/values.c ${DESTDIR}${GCC_PREFIX}/bin/gcc -m64
+.endif
+
+GENERATE_PLIST+=                                                        \
+	cd ${DESTDIR}${PREFIX} && ${FIND} ${GCC_SUBPREFIX} \( -type f -o -type l \) -print \
+	| ${SORT} ;
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/gcc46/TODO b/gcc46/TODO
new file mode 100644
index 0000000..a14b010
--- /dev/null
+++ b/gcc46/TODO
@@ -0,0 +1,3 @@
+
+* TODO make java target work
+* TODO Make it work on Dragonfly
diff --git a/gcc46/buildlink3.mk b/gcc46/buildlink3.mk
new file mode 100644
index 0000000..107e05f
--- /dev/null
+++ b/gcc46/buildlink3.mk
@@ -0,0 +1,33 @@
+# $NetBSD: buildlink3.mk,v 1.9 2015/11/25 12:51:16 jperkin Exp $
+
+BUILDLINK_TREE+=	gcc46
+
+.if !defined(GCC46_BUILDLINK3_MK)
+GCC46_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.gcc46+=	gcc46>=4.6
+BUILDLINK_ABI_DEPENDS.gcc46+=	gcc46>=4.6.0
+BUILDLINK_PKGSRCDIR.gcc46=	../../lang/gcc46
+BUILDLINK_DEPMETHOD.gcc46?=	build
+
+BUILDLINK_PASSTHRU_DIRS+=	${BUILDLINK_PREFIX.gcc46}/gcc46
+
+BUILDLINK_FILES.gcc46=		#empty
+BUILDLINK_AUTO_VARS.gcc46=	no
+
+# Packages that link against shared libraries need a full dependency.
+.if defined(_USE_GCC_SHLIB)
+DEPENDS+=	{gcc46,gcc46-libs}>=4.6:../../lang/gcc46-libs
+ABI_DEPENDS+=	{gcc46,gcc46-libs}>=4.6.0:../../lang/gcc46-libs
+.endif
+
+pkgbase := gcc46
+.include "../../mk/pkg-build-options.mk"
+.if !empty(PKG_BUILD_OPTIONS.gcc46:Mgcc-java)
+.include "../../devel/zlib/buildlink3.mk"
+.endif
+
+.include "../../mk/dlopen.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+.endif # GCC46_BUILDLINK3_MK
+BUILDLINK_TREE+=	-gcc46
diff --git a/gcc46/distinfo b/gcc46/distinfo
new file mode 100644
index 0000000..1038dc4
--- /dev/null
+++ b/gcc46/distinfo
@@ -0,0 +1,63 @@
+$NetBSD: distinfo,v 1.21 2016/09/06 13:57:02 maya Exp $
+
+SHA1 (gcc-4.6.4.tar.bz2) = 63933a8a5cf725626585dbba993c8b0f6db1335d
+RMD160 (gcc-4.6.4.tar.bz2) = 6a58b053812cf75622bc4579e020cd9471f46916
+SHA512 (gcc-4.6.4.tar.bz2) = b5a5395782e0b9e61cda052f6e00c8575d1aa0b7e8db9e34c06e4e45f12ff37b436018536b7fa69a04a4235b5b368895652e3ed8fab2fe11763f9782ed9161dc
+Size (gcc-4.6.4.tar.bz2) = 72006076 bytes
+SHA1 (patch-aa) = 8bb19e38cacf5dbf9e9f3cac71211d52ec8358c3
+SHA1 (patch-ab) = f25d0b276041e57dcfb00638bc4232b4e0f5abb6
+SHA1 (patch-ac) = d6853dcca81588c481ad62d4c4e9f2fbcc7cb657
+SHA1 (patch-ad) = b5e17219e7b7ba158b9f3e1a67e155fb158b4484
+SHA1 (patch-af) = e4e194ef29924eb986536972c5f5e9f37d98eba3
+SHA1 (patch-ag) = 1753d08075de8527d8f14afc3df4afeacb10d507
+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) = 561965695238afd4c41b75f20d84114adb4dd194
+SHA1 (patch-gcc_config.host) = 9458bf6bc6d16abd07c66e60b04c84106fe937fd
+SHA1 (patch-gcc_config_arm_elf.h) = 28c67bb698ebe9a3aa45c4cff29f028c82cc7606
+SHA1 (patch-gcc_config_arm_t-netbsd) = a1682f4f8dc7e393446f19f615737ddfc98fcb7f
+SHA1 (patch-gcc_config_exec-stack.h) = 2ff8a153a41638de2943c4109f38ea3a7c26c00d
+SHA1 (patch-gcc_config_host-netbsd.c) = 765295f07edb8a68f1910e3a9b4dd2a7dcd491a5
+SHA1 (patch-gcc_config_host-openbsd.c) = 109ce33dbbc19c988637d77dce4d240d6bfc912c
+SHA1 (patch-gcc_config_i386_i386.c) = 49ba75bb347a9c96606a7bef7e0f972488d881b3
+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_netbsd.h) = 086b593cf9f05e654df9e1a527485ca727ec44cc
+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-netbsd) = 6dc3d78e26df62054ea29f98ca51592858e671e3
+SHA1 (patch-gcc_config_x-openbsd) = b307d75331b9a7f6271698c68f1647a03d204eb9
+SHA1 (patch-gcc_configure) = 906906aca782c75b2a053aef272a8472f0a9a9ee
+SHA1 (patch-gcc_defaults.h) = 72b145fdf9baecc061e90e9634eb5f842215a962
+SHA1 (patch-gcc_gcc.c) = 6b9499cf22f1018c289f2a20a4487d5f5e1a1069
+SHA1 (patch-gcc_ggc-common.c) = fa577bc25260d7e6304f166686ba51c0b677d7f6
+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-include_libiberty.h) = 101c12fad8092c7eb7ba41a75ca84f9a8017589b
+SHA1 (patch-libgcc_config_t-slibgcc-darwin) = 2ddda2dd979f27c623e47db70c5abb3befdb68c9
+SHA1 (patch-libiberty___doprnt.c) = 20f839e98ca235d5a34adcad6b7ea4a77f06a9e8
+SHA1 (patch-libiberty_asprintf.c) = 39d8ca4c95aa035c4d8e9faba2e5919c13f4444c
+SHA1 (patch-libiberty_concat.c) = 07fe2982d57151579736361ca15f3edd8b0bce69
+SHA1 (patch-libiberty_snprintf.c) = 25e131f8ea4e6f8b567088f653f6a02153aec202
+SHA1 (patch-libiberty_vasprintf.c) = a8c0ec0c3e9dbfcd675a0bb02a89e8c51a885605
+SHA1 (patch-libiberty_vsnprintf.c) = 362ea0ce3f86df6548388878006db4f951aa1f09
+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/gcc46/files/dragonfly-spec.h b/gcc46/files/dragonfly-spec.h
new file mode 100644
index 0000000..ace9e19
--- /dev/null
+++ b/gcc46/files/dragonfly-spec.h
@@ -0,0 +1,215 @@
+/* $DragonFly: src/gnu/usr.bin/cc41/cc_prep/config/dragonfly-spec.h,v 1.5 2008/07/24 21:45:10 corecode Exp $ */
+
+/* Base configuration file for all DragonFly targets.
+   Copyright (C) 1999, 2000, 2001 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.  */
+
+/* Common DragonFly configuration. 
+   All DragonFly architectures should include this file, which will specify
+   their commonalities.
+
+   Adapted from gcc/config/freebsd-spec.h by
+   Joerg Sonnenberger <joerg%bec.de@localhost>
+
+   Adapted from gcc/config/freebsd.h by 
+   David O'Brien <obrien%FreeBSD.org@localhost>
+   Loren J. Rittle <ljrittle%acm.org@localhost>.  */
+
+
+/* This defines which switch letters take arguments.  On DragonFly, most of
+   the normal cases (defined in gcc.c) apply, and we also have -h* and
+   -z* options (for the linker) (coming from SVR4).
+   We also have -R (alias --rpath), no -z, --soname (-h), --assert etc.  */
+
+#define DFBSD_SWITCH_TAKES_ARG(CHAR)					\
+  (DEFAULT_SWITCH_TAKES_ARG (CHAR)					\
+    || (CHAR) == 'h'							\
+    || (CHAR) == 'z' /* ignored by ld */				\
+    || (CHAR) == 'R')
+
+/* This defines which multi-letter switches take arguments.  */
+
+#define DFBSD_WORD_SWITCH_TAKES_ARG(STR)					\
+  (DEFAULT_WORD_SWITCH_TAKES_ARG (STR)					\
+   || !strcmp ((STR), "rpath") || !strcmp ((STR), "rpath-link")		\
+   || !strcmp ((STR), "soname") || !strcmp ((STR), "defsym") 		\
+   || !strcmp ((STR), "assert") || !strcmp ((STR), "dynamic-linker"))
+
+#define DFBSD_TARGET_OS_CPP_BUILTINS()					\
+  do									\
+    {									\
+	if (DFBSD_MAJOR == 3)	       				\
+	  builtin_define ("__DragonFly__=3");			       	\
+	else if (DFBSD_MAJOR == 2)	       				\
+	  builtin_define ("__DragonFly__=2");			       	\
+	else if (DFBSD_MAJOR == 1)	       				\
+	  builtin_define ("__DragonFly__=1");			       	\
+	else								\
+	  builtin_define ("__DragonFly__");			       	\
+	builtin_define ("__DragonFly_cc_version=100001");		\
+	builtin_define_std ("unix");					\
+	builtin_define ("__KPRINTF_ATTRIBUTE__");		       	\
+	builtin_assert ("system=unix");					\
+	builtin_assert ("system=bsd");					\
+	builtin_assert ("system=DragonFly");				\
+	DFBSD_TARGET_CPU_CPP_BUILTINS();					\
+    }									\
+  while (0)
+
+/* Define the default DragonFly-specific per-CPU hook code. */
+#define DFBSD_TARGET_CPU_CPP_BUILTINS() do {} while (0)
+
+/* Provide a CPP_SPEC appropriate for DragonFly.  We just deal with the GCC 
+   option `-posix', and PIC issues.  */
+
+#define DFBSD_CPP_SPEC "							\
+  %(cpp_cpu)								\
+  %{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__}				\
+  %{posix:-D_POSIX_SOURCE}"
+
+/* Provide a STARTFILE_SPEC appropriate for DragonFly.  Here we add
+   the magical crtbegin.o file (see crtstuff.c) which provides part 
+	of the support for getting C++ file-scope static object constructed 
+	before entering `main'.  */
+   
+#define DFBSD_STARTFILE_SPEC \
+  "%{!shared: \
+     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
+		       %{!p:%{profile:gcrt1.o%s} \
+			 %{!profile:crt1.o%s}}}} \
+   crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+
+/* Provide a ENDFILE_SPEC appropriate for DragonFly.  Here we tack on
+   the magical crtend.o file (see crtstuff.c) which provides part of 
+	the support for getting C++ file-scope static object constructed 
+	before entering `main', followed by a normal "finalizer" file, 
+	`crtn.o'.  */
+
+#define DFBSD_ENDFILE_SPEC \
+  "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+
+/* Provide a LIB_SPEC appropriate for DragonFly as configured and as
+   required by the user-land thread model.  Select the appropriate libc,
+   depending on whether we're doing profiling or need threads support.
+   Make it a hard error if -pthread is provided on the command line and gcc
+   was configured with --disable-threads (this will help avoid bug
+   reports from users complaining about threading when they
+   misconfigured the gcc bootstrap but are later consulting DragonFly
+   manual pages that refer to the mythical -pthread option).  */
+
+/* Provide a LIB_SPEC appropriate for DragonFly.  Just select the appropriate
+   libc, depending on whether we're doing profiling or need threads support.
+   (simular to the default, except no -lg, and no -p).  */
+
+#ifdef DFBSD_NO_THREADS
+#define DFBSD_LIB_SPEC "						\
+  %{pthread: %eThe -pthread option is only supported on DragonFly when gcc \
+is built with the --enable-threads configure-time option.}		\
+  %{!nostdlib{!nostartfiles{!nolibc: -lc}}}				\
+  }"
+#else
+#define DFBSD_LIB_SPEC "						\
+  %{pthread:-lpthread}							\
+  %{!nostdlib: %{!nostartfiles: %{!nolibc: -lc}}}			\
+  "
+#endif
+
+#define	DFBSD_DYNAMIC_LINKER		"/usr/libexec/ld-elf.so.2"
+
+#if 0
+#define LINK_LIBGCC_SPEC ""
+#define LIBGCC_SPEC "%{shared: -lgcc_pic} %{!shared: -lgcc}"
+
+#define PRE_LIB_SPEC "							\
+  %{pg: -L"PREFIX2"/lib/gcc41/profiling 				\
+    %{!static: -rpath /usr/lib/gcc41/profiling 				\
+      -rpath-link "PREFIX2"/lib/gcc41/profiling}}			\
+  %{g: -L"PREFIX2"/lib/gcc41/debug 					\
+    %{!static: -rpath /usr/lib/gcc41/debug				\
+      -rpath-link "PREFIX2"/lib/gcc41/debug}}				\
+  -L"PREFIX2"/lib/gcc41							\
+  %{!static: -rpath /usr/lib/gcc41  -rpath-link "PREFIX2"/lib/gcc41} 	\
+  %{pg: -L"PREFIX2"/lib/profiling 					\
+    %{!static: -rpath /usr/lib/profiling				\
+      -rpath-link "PREFIX2"/lib/profiling}} 				\
+  %{g: -L"PREFIX2"/lib/debug 						\
+    %{!static: -rpath /usr/lib/debug -rpath-link "PREFIX2"/lib/debug}} 	\
+  %{!static: -rpath /usr/lib -rpath-link "PREFIX2"/lib} 		\
+  "
+
+#define DFBSD_LINK_COMMAND_SPEC "\
+%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
+    %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
+    %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
+    %{static:} %{L*} %(link_libgcc) %o \
+    %{fprofile-arcs|fprofile-generate: -lgcov}\
+    %{!nostdlib:%{!nodefaultlibs:%(pre_lib)}}\
+    %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}\
+    %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"
+
+#ifndef PREFIX2
+#define	PREFIX2		"/usr"
+#endif
+
+#ifndef STANDARD_STARTFILE_PREFIX_1
+#define	STANDARD_STARTFILE_PREFIX_1	PREFIX2"/lib/gcc41/"
+#endif
+#ifndef STANDARD_EXEC_PREFIX
+#define	STANDARD_EXEC_PREFIX		PREFIX2"/libexec/gcc41/"
+#endif
+#ifndef STANDARD_STARTFILE_PREFIX
+#define	STANDARD_STARTFILE_PREFIX	PREFIX2"/lib/"
+#endif
+#ifndef TOOLDIR_BASE_PREFIX
+#define TOOLDIR_BASE_PREFIX		PREFIX2"/libexec/gcc41"
+#endif
+#ifndef STANDARD_BINDIR_PREFIX
+#define STANDARD_BINDIR_PREFIX		PREFIX2"/libexec/gcc41"
+#endif
+#ifndef STANDARD_LIBEXEC_PREFIX
+#define STANDARD_LIBEXEC_PREFIX		PREFIX2"/libexec/gcc41"
+#endif
+
+#ifndef GPLUSPLUS_INCLUDE_DIR
+#define GPLUSPLUS_INCLUDE_DIR		PREFIX2"/include/c++"
+#endif
+#ifndef GPLUSPLUS_TOOL_INCLUDE_DIR
+#define GPLUSPLUS_TOOL_INCLUDE_DIR	PREFIX2"/include/c++/4.1"
+#endif
+#ifndef GPLUSPLUS_BACKWARD_INCLUDE_DIR
+#define	GPLUSPLUS_BACKWARD_INCLUDE_DIR	PREFIX2"/include/c++/4.1/backward"
+#endif
+#ifndef GCC_LOCAL_INCLUDE_DIR
+#define	GCC_LOCAL_INCLUDE_DIR		PREFIX2"/libdata/gcc41"
+#endif
+#ifndef GCC_INCLUDE_DIR
+#define	GCC_INCLUDE_DIR			PREFIX2"/include"
+#endif
+
+#undef INCLUDE_DEFAULTS
+#define INCLUDE_DEFAULTS				\
+  {							\
+    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },		\
+    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0 },	\
+    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0 },	\
+    { GCC_INCLUDE_DIR, "GCC", 0, 0 },			\
+    { GCC_LOCAL_INCLUDE_DIR, "GCC", 0, 0 },		\
+    { NULL, NULL, 0, 0 }				\
+  }
+#endif
diff --git a/gcc46/files/dragonfly.h b/gcc46/files/dragonfly.h
new file mode 100644
index 0000000..6274620
--- /dev/null
+++ b/gcc46/files/dragonfly.h
@@ -0,0 +1,97 @@
+/* $DragonFly: src/gnu/usr.bin/cc41/cc_prep/config/dragonfly.h,v 1.2 2008/05/19 10:46:39 corecode Exp $ */
+
+/* Base configuration file for all DragonFly targets.
+   Copyright (C) 1999, 2000, 2001 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.  */
+
+/* Common DragonFly configuration. 
+   All DragonFly architectures should include this file, which will specify
+   their commonalities.
+
+   Adapted from gcc/config/freebsd.h by
+   Joerg Sonnenberger <joerg%bec.de@localhost>
+
+   Adapted from gcc/config/i386/freebsd-elf.h by 
+   David O'Brien <obrien%FreeBSD.org@localhost>.  
+   Further work by David O'Brien <obrien%FreeBSD.org@localhost> and
+   Loren J. Rittle <ljrittle%acm.org@localhost>.  */
+
+
+/* This defines which switch letters take arguments.  On DragonFly, most of
+   the normal cases (defined in gcc.c) apply, and we also have -h* and
+   -z* options (for the linker) (coming from SVR4).
+   We also have -R (alias --rpath), no -z, --soname (-h), --assert etc.  */
+
+#undef  SWITCH_TAKES_ARG
+#define SWITCH_TAKES_ARG(CHAR) (DFBSD_SWITCH_TAKES_ARG(CHAR))
+
+#undef  WORD_SWITCH_TAKES_ARG
+#define WORD_SWITCH_TAKES_ARG(STR) (DFBSD_WORD_SWITCH_TAKES_ARG(STR))
+
+#undef  TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() DFBSD_TARGET_OS_CPP_BUILTINS()
+
+#undef  CPP_SPEC
+#define CPP_SPEC DFBSD_CPP_SPEC
+
+#undef  STARTFILE_SPEC
+#define STARTFILE_SPEC DFBSD_STARTFILE_SPEC
+
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC DFBSD_ENDFILE_SPEC
+
+#undef  LIB_SPEC
+#define LIB_SPEC DFBSD_LIB_SPEC
+
+#if 0
+#undef	LINK_COMMAND_SPEC
+#define LINK_COMMAND_SPEC DFBSD_LINK_COMMAND_SPEC 
+#endif
+
+/************************[  Target stuff  ]***********************************/
+
+/* All DragonFly Architectures support the ELF object file format.  */
+#undef  OBJECT_FORMAT_ELF
+#define OBJECT_FORMAT_ELF
+
+/* Don't assume anything about the header files.  */
+#undef  NO_IMPLICIT_EXTERN_C
+#define NO_IMPLICIT_EXTERN_C	1
+
+/* Make gcc agree with DragonFly's standard headers (<machine/stdint.h>, etc...)  */
+
+#undef  WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#define MATH_LIBRARY_PROFILE    "-lm_p"
+
+/* Code generation parameters.  */
+
+/* Use periods rather than dollar signs in special g++ assembler names.
+   This ensures the configuration knows our system correctly so we can link
+   with libraries compiled with the native cc.  */
+#undef NO_DOLLAR_IN_LABEL
+
+/* Define this so we can compile MS code for use with WINE.  */
+#define HANDLE_PRAGMA_PACK_PUSH_POP
+
+/* Used by libgcc2.c.  We support file locking with fcntl / F_SETLKW.
+   This enables the test coverage code to use file locking when exiting a
+   program, which avoids race conditions if the program has forked.  */
+#define TARGET_POSIX_IO
diff --git a/gcc46/files/hello.f b/gcc46/files/hello.f
new file mode 100644
index 0000000..4b34eed
--- /dev/null
+++ b/gcc46/files/hello.f
@@ -0,0 +1,5 @@
+
+      PROGRAM hello
+      print*, 'Hello, World!'
+      END
+
diff --git a/gcc46/files/hello.m b/gcc46/files/hello.m
new file mode 100644
index 0000000..c25ba5a
--- /dev/null
+++ b/gcc46/files/hello.m
@@ -0,0 +1,6 @@
+#import <stdio.h>
+
+int main( int argc, const char *argv[] ) {
+    printf( "hello world\n" );
+    return 0;
+}
diff --git a/gcc46/files/i386-dragonfly.h b/gcc46/files/i386-dragonfly.h
new file mode 100644
index 0000000..78b7e0c
--- /dev/null
+++ b/gcc46/files/i386-dragonfly.h
@@ -0,0 +1,148 @@
+/* $DragonFly: src/gnu/usr.bin/cc41/cc_prep/config/i386/dragonfly.h,v 1.1 2006/09/27 12:10:34 corecode Exp $ */
+
+/* Definitions for Intel 386 running DragonFly with ELF format
+   
+   Copyright (C) 1996, 2000, 2002 Free Software Foundation, Inc.
+   Contributed by Eric Youngdale.
+   Modified for stabs-in-ELF by H.J. Lu.
+   Adapted from GNU/Linux version by John Polstra.
+   Continued development by David O'Brien <obrien%freebsd.org@localhost>
+   Adapted from the FreeBSD version.
+
+   Changes:
+   - remove support for changing the dynamic linker
+
+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.  */
+
+
+#define TARGET_VERSION fprintf (stderr, " (i386 DragonFly/ELF)");
+
+/* Override the default comment-starter of "/".  */
+#undef  ASM_COMMENT_START
+#define ASM_COMMENT_START "#"
+
+#undef  ASM_APP_ON
+#define ASM_APP_ON "#APP\n"
+
+#undef  ASM_APP_OFF
+#define ASM_APP_OFF "#NO_APP\n"
+
+#undef  DBX_REGISTER_NUMBER
+#define DBX_REGISTER_NUMBER(n) \
+  (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
+
+#undef  NO_PROFILE_COUNTERS
+#define NO_PROFILE_COUNTERS	1
+
+/* Tell final.c that we don't need a label passed to mcount.  */
+
+#undef  MCOUNT_NAME
+#define MCOUNT_NAME ".mcount"
+
+/* Make gcc agree with <machine/ansi.h>.  */
+
+#undef  SIZE_TYPE
+#define SIZE_TYPE	(TARGET_64BIT ? "long unsigned int" : "unsigned int")
+ 
+#undef  PTRDIFF_TYPE
+#define PTRDIFF_TYPE	(TARGET_64BIT ? "long int" : "int")
+  
+#undef  WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE	(TARGET_64BIT ? 32 : BITS_PER_WORD)
+
+#undef  SUBTARGET_EXTRA_SPECS	/* i386.h bogusly defines it.  */
+#define SUBTARGET_EXTRA_SPECS \
+  { "dfbsd_dynamic_linker", DFBSD_DYNAMIC_LINKER }
+    
+/* Provide a STARTFILE_SPEC appropriate for DragonFly.  Here we add
+   the magical crtbegin.o file (see crtstuff.c) which provides part 
+	of the support for getting C++ file-scope static object constructed 
+	before entering `main'.  */
+   
+#undef	STARTFILE_SPEC
+#define STARTFILE_SPEC \
+  "%{!shared: \
+     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
+		       %{!p:%{profile:gcrt1.o%s} \
+			 %{!profile:crt1.o%s}}}} \
+   crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+
+/* Provide a ENDFILE_SPEC appropriate for DragonFly.  Here we tack on
+   the magical crtend.o file (see crtstuff.c) which provides part of 
+	the support for getting C++ file-scope static object constructed 
+	before entering `main', followed by a normal "finalizer" file, 
+	`crtn.o'.  */
+
+#undef	ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+
+/* Provide a LINK_SPEC appropriate for DragonFly.  Here we provide support
+   for the special GCC options -static and -shared, which allow us to
+   link things in one of these three modes by applying the appropriate
+   combinations of options at link-time. We like to support here for
+   as many of the other GNU linker options as possible. But I don't
+   have the time to search for those flags. I am sure how to add
+   support for -soname shared_object_name. H.J.
+
+   I took out %{v:%{!V:-V}}. It is too much :-(. They can use
+   -Wl,-V.
+
+   When the -shared link option is used a final link is not being
+   done.  */
+
+#undef	LINK_SPEC
+#define LINK_SPEC "\
+  %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
+  %{v:-V} \
+  %{assert*} %{R*} %{rpath*} %{defsym*} \
+  %{shared:-Bshareable %{h*} %{soname*}} \
+    %{!shared: \
+      %{!static: \
+        %{rdynamic:-export-dynamic} \
+        %{!dynamic-linker:-dynamic-linker %(dfbsd_dynamic_linker) }} \
+    %{static:-Bstatic}} \
+  %{symbolic:-Bsymbolic}"
+
+/* A C statement to output to the stdio stream FILE an assembler
+   command to advance the location counter to a multiple of 1<<LOG
+   bytes if it is within MAX_SKIP bytes.
+
+   This is used to align code labels according to Intel recommendations.  */
+
+#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
+#undef  ASM_OUTPUT_MAX_SKIP_ALIGN
+#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP)					\
+  if ((LOG) != 0) {														\
+    if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));	\
+    else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
+  }
+#endif
+
+/* Don't default to pcc-struct-return, we want to retain compatibility with
+   older gcc versions AND pcc-struct-return is nonreentrant.
+   (even though the SVR4 ABI for the i386 says that records and unions are
+   returned in memory).  */
+
+#undef  DEFAULT_PCC_STRUCT_RETURN
+#define DEFAULT_PCC_STRUCT_RETURN 0
+
+/* DragonFly sets the rounding precision of the FPU to 53 bits.  Let the
+   compiler get the contents of <float.h> and std::numeric_limits correct.  */
+#undef TARGET_96_ROUND_53_LONG_DOUBLE
+#define TARGET_96_ROUND_53_LONG_DOUBLE (!TARGET_64BIT)
diff --git a/gcc46/files/i386-dragonfly64.h b/gcc46/files/i386-dragonfly64.h
new file mode 100644
index 0000000..f423653
--- /dev/null
+++ b/gcc46/files/i386-dragonfly64.h
@@ -0,0 +1,54 @@
+/* $DragonFly: src/gnu/usr.bin/cc41/cc_prep/config/i386/dragonfly64.h,v 1.1 2007/01/15 17:53:16 corecode Exp $ */
+
+/* Definitions for AMD x86-64 running DragonFly with ELF format
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   Contributed by David O'Brien <obrien%FreeBSD.org@localhost>
+   Adapted from the FreeBSD version.
+
+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.  */
+
+/* $FreeBSD: src/contrib/gcc/config/i386/freebsd64.h,v 1.9 2004/07/28 04:44:23 kan Exp $ */
+
+
+#undef  TARGET_VERSION
+#define TARGET_VERSION fprintf (stderr, " (x86-64 DragonFly/ELF)");
+
+/* Tell final.c that we don't need a label passed to mcount.  */
+
+#define SUBTARGET_EXTRA_SPECS \
+  { "dfbsd_dynamic_linker", DFBSD_DYNAMIC_LINKER }
+
+#undef  MCOUNT_NAME
+#define MCOUNT_NAME ".mcount"
+
+/* Provide a LINK_SPEC appropriate for the DragonFly/x86-64 ELF target.
+   This is a copy of LINK_SPEC from <i386/dragonfly.h> tweaked for
+   the x86-64 target.
+   XXX We don't support two arch userland yet  */
+
+#undef	LINK_SPEC
+#define LINK_SPEC "\
+  %{v:-V} \
+  %{assert*} %{R*} %{rpath*} %{defsym*} \
+  %{shared:-Bshareable %{h*} %{soname*}} \
+    %{!shared: \
+      %{!static: \
+        %{rdynamic:-export-dynamic} \
+	%{!dynamic-linker:-dynamic-linker %(dfbsd_dynamic_linker) }} \
+    %{static:-Bstatic}} \
+  %{symbolic:-Bsymbolic}"
diff --git a/gcc46/files/patch-gcc_targhooks.c-openbsd.diff b/gcc46/files/patch-gcc_targhooks.c-openbsd.diff
new file mode 100644
index 0000000..71ea5d4
--- /dev/null
+++ b/gcc46/files/patch-gcc_targhooks.c-openbsd.diff
@@ -0,0 +1,150 @@
+$NetBSD: patch-gcc_targhooks.c-openbsd.diff,v 1.2 2015/12/29 04:04:28 dholland Exp $
+
+--- 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/gcc46/files/values.c b/gcc46/files/values.c
new file mode 100644
index 0000000..cefb792
--- /dev/null
+++ b/gcc46/files/values.c
@@ -0,0 +1,64 @@
+#if 0 /* $NetBSD: values.c,v 1.1 2011/10/13 10:39:45 hans Exp $ */
+#
+# This is Solaris x86 specific GCC run-time environment patch, which
+# makes it possible to reliably deploy .init snippets. Trouble is that
+# Solaris linker erroneously pads .init segment with zeros [instead of
+# nops], which is bound to SEGV early upon program start-up. This bug
+# was recognized by GCC team [it is mentioned in source code], but
+# workaround apparently and obviously erroneously slipped away in some
+# newer GCC release. This patch compensates for this mishap by dropping
+# modified values-X*.o into GCC installation tree. Object modules in
+# question are normally provided by Sun and linked prior crtbegin.o.
+# Modified versions are additionally crafted with custom .init segment,
+# which does some magic:-)
+#						<appro%fy.chalmers.se@localhost>
+set -e
+gcc=gcc
+if [[ "x$1" = x*gcc ]]; then
+	gcc=$1; shift
+fi
+gcc_dir=`${gcc} "$@" -print-libgcc-file-name`
+gcc_dir=${gcc_dir%/*}	#*/
+set -x 
+${gcc} "$@" -c -o $gcc_dir/values-Xa.o -DXa $0
+${gcc} "$@" -c -o $gcc_dir/values-Xc.o -DXc $0
+${gcc} "$@" -c -o $gcc_dir/values-Xt.o -DXt $0
+exit
+#endif
+
+#include <math.h>
+
+#if defined(Xa)
+const enum version _lib_version = ansi_1;
+#elif defined(Xc)
+const enum version _lib_version = strict_ansi;
+#elif defined(Xt)
+const enum version _lib_version = c_issue_4;
+#else
+#error "compile by issuing 'ksh -f values.c [gcc] [-m64]'"
+#endif
+
+#if defined(__x86_64__)
+asm("\n"
+".section	.init\n"
+".align	1\n"
+"	leaq	1f(%rip),%rax\n"
+"1:	cmpl	$0,2f-1b(%rax)\n"
+"	jne	2f\n"
+"	jmp	2f+5\n"
+"	.skip	9\n"	/* pad up to 0x1b bytes */
+"2:\n"
+);
+#else
+asm("\n"
+".section	.init\n"
+".align	1\n"
+"	call	1f\n"
+"1:	popl	%eax\n"
+"	cmpl	$0,2f-1b(%eax)\n"
+"	jne	2f\n"
+"	jmp	2f+5\n"
+"	.skip	10\n"	/* pad up to 0x1b bytes */
+"2:\n"
+);
+#endif
diff --git a/gcc46/hacks.mk b/gcc46/hacks.mk
new file mode 100644
index 0000000..a678e50
--- /dev/null
+++ b/gcc46/hacks.mk
@@ -0,0 +1,9 @@
+# $NetBSD: hacks.mk,v 1.2 2013/04/03 19:29:23 jmcneill Exp $
+
+#
+# Avoid -fkeep-inline-functions with NetBSD/arm
+#
+.if ${OPSYS} == "NetBSD" && ${MACHINE_ARCH} == "arm"
+PKG_HACKS+=		netbsd-arm-stage1-fix
+CONFIGURE_ARGS+=	--disable-bootstrap
+.endif
diff --git a/gcc46/options.mk b/gcc46/options.mk
new file mode 100644
index 0000000..e226cc5
--- /dev/null
+++ b/gcc46/options.mk
@@ -0,0 +1,128 @@
+# $NetBSD: options.mk,v 1.10 2016/02/25 14:42:55 jperkin Exp $
+
+PKG_OPTIONS_VAR=	PKG_OPTIONS.gcc46
+PKG_SUPPORTED_OPTIONS=	nls gcc-inplace-math gcc-c++ gcc-fortran gcc-java gcc-objc #gcc-ada
+PKG_SUGGESTED_OPTIONS=	gcc-c++ gcc-fortran gcc-objc
+
+PKG_SUGGESTED_OPTIONS.NetBSD+=	nls
+PKG_SUGGESTED_OPTIONS.SunOS+=	gcc-inplace-math
+
+PKG_OPTIONS_LEGACY_VARS+=	BUILD_CXX:gcc-c++
+PKG_OPTIONS_LEGACY_VARS+=	BUILD_FORTRAN:gcc-fortran
+PKG_OPTIONS_LEGACY_VARS+=	BUILD_JAVA:gcc-java
+PKG_OPTIONS_LEGACY_VARS+=	BUILD_OBJC:gcc-objc
+
+###
+### Determine if multilib is avalible.
+###
+MULTILIB_SUPPORTED?=	unknown
+.if !empty(MACHINE_PLATFORM:MLinux-*-x86_64)
+.  if exists(/usr/include/gnu/stubs-64.h) && \
+     !exists(/usr/include/gnu/stubs-32.h)
+MULTILIB_SUPPORTED=No
+.  else
+MULTILIB_SUPPORTED=Yes
+.  endif
+.endif
+.if !empty(MULTILIB_SUPPORTED:M[Yy][Ee][Ss])
+PKG_SUPPORTED_OPTIONS+=	gcc-multilib
+PKG_SUGGESTED_OPTIONS+=	gcc-multilib
+.endif
+
+.include "../../mk/bsd.options.mk"
+
+###
+### Build math libraries in place
+###
+.if !empty(PKG_OPTIONS:Mgcc-inplace-math)
+.include "../../devel/gmp/inplace.mk"
+.include "../../math/mpcomplex/inplace.mk"
+.include "../../math/mpfr/inplace.mk"
+.else
+CONFIGURE_ARGS+=	--with-gmp=${BUILDLINK_PREFIX.gmp}
+CONFIGURE_ARGS+=	--with-mpc=${BUILDLINK_PREFIX.mpcomplex}
+CONFIGURE_ARGS+=	--with-mpfr=${BUILDLINK_PREFIX.mpfr}
+LIBS.SunOS+=		-lgmp
+.include "../../devel/gmp/buildlink3.mk"
+.include "../../math/mpcomplex/buildlink3.mk"
+.include "../../math/mpfr/buildlink3.mk"
+.endif
+
+###
+### Native Language Support
+###
+.if !empty(PKG_OPTIONS:Mnls)
+USE_TOOLS+=		msgfmt
+CONFIGURE_ARGS+=	--enable-nls
+CONFIGURE_ARGS+=	--with-libiconv-prefix=${BUILDLINK_PREFIX.libiconv}
+MAKE_ENV+=		ICONVPREFIX=${BUILDLINK_PREFIX.iconv}
+.include "../../converters/libiconv/buildlink3.mk"
+.include "../../devel/gettext-lib/buildlink3.mk"
+.else
+CONFIGURE_ARGS+=	--disable-nls
+.endif
+
+###
+### Multilib Support
+###
+.if (!empty(MULTILIB_SUPPORTED:M[Yy][Ee][Ss]) && \
+      empty(PKG_OPTIONS:Mgcc-multilib) ) || \
+    !empty(MULTILIB_SUPPORTED:M[Nn][Oo])
+CONFIGURE_ARGS+=	--disable-multilib
+.endif
+
+###
+### Optional languages
+### Ada could be added although there is a bootstrapping issue.  See
+### ../gcc34-ada for guidance
+###
+
+LANGS=			c
+
+.if !empty(PKG_OPTIONS:Mgcc-java)
+.  if empty(PKG_OPTIONS:Mgcc-c++)
+PKG_OPTIONS+=		gcc-c++
+.  endif
+
+LANGS+=			java
+REPLACE_PYTHON=		libjava/contrib/aot-compile.in
+
+USE_TOOLS+=		unzip zip:run
+CONFIGURE_ARGS+=	--with-system-zlib
+
+# ${WRKSRC}/gcc-4.6.1/libjava/contrib/aotcompile.py.in stores the path to
+# a 'make' program so we need to make sure we give it the installed # 'make' and not
+# the tool wrapped one.
+CONFIGURE_ENV+=		PKGSRC_MAKE=${TOOLS_PATH.gmake}
+MAKE_ENV+=		PKGSRC_MAKE=${TOOLS_PATH.gmake}
+
+# fastjar-0.93 from pkgsrc/archivers/fastjar seems to trigger a build
+# failure (seen on NetBSD-5.0/i386) when building java.  So in case
+# the fastjar package is installed, make sure the configure script
+# doesn't pick it up.
+CONFIGURE_ENV+=		JAR=no
+MAKE_ENV+=		JAR=no
+MAKE_ENV+=		ac_cv_prog_JAR=no
+
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../lang/python/application.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Mgcc-c++)
+LANGS+=			c++
+USE_TOOLS+=		perl
+CONFIGURE_ARGS+=	--enable-__cxa_atexit
+CONFIGURE_ARGS+=	--with-gxx-include-dir=${GCC_PREFIX}/include/c++/
+.endif
+
+.if !empty(PKG_OPTIONS:Mgcc-fortran)
+LANGS+=			fortran
+.endif
+
+.if !empty(PKG_OPTIONS:Mgcc-objc)
+LANGS+=			objc
+.endif
+
+#.if !empty(PKG_OPTIONS:Mgcc-ada)
+#LANGS+=		ada
+#.endif
diff --git a/gcc46/patches/patch-aa b/gcc46/patches/patch-aa
new file mode 100644
index 0000000..9675343
--- /dev/null
+++ b/gcc46/patches/patch-aa
@@ -0,0 +1,203 @@
+$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.
+* wrap the system stdint.h on NetBSD.
+
+* Add Dragonfly support.
+
+--- 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
+   ;;
++*-*-dragonfly*)
++  gas=yes
++  gnu_ld=yes
++  extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o"
++  case ${target} in
++    *-*-dragonfly1 | *-*-dragonfly[1].*)
++      tm_defines="${tm_defines} DFBSD_MAJOR=1" ;;
++    *-*-dragonfly2 | *-*-dragonfly[2].*)
++      tm_defines="${tm_defines} DFBSD_MAJOR=2" ;;
++    *-*-dragonfly3 | *-*-dragonfly[3].*)
++      tm_defines="${tm_defines} DFBSD_MAJOR=3" ;;
++    *-*-dragonfly4 | *-*-dragonfly[4].*)
++      tm_defines="${tm_defines} DFBSD_MAJOR=4" ;;
++    *)
++      echo 'Please update *-*-dragonfly* in gcc/config.gcc'
++      exit 1
++      ;;
++  esac
++  tmake_file="t-slibgcc-elf-ver t-dragonfly"
++  case ${enable_threads} in
++    "" | yes | posix)
++      thread_file='posix'
++      tmake_file="${tmake_file} t-dragonfly-thread"
++      ;;
++  esac
++  dfbsd_tm_file="${dfbsd_tm_file} dragonfly-spec.h dragonfly.h"
++  ;;
+ *-*-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 @@ case ${target} in
+       default_use_cxa_atexit=yes
+       ;;
+   esac
++  use_gcc_stdint=wrap
+   ;;
+ *-*-openbsd*)
+   tmake_file="t-libc-ok t-openbsd t-libgcc-pic"
+@@ -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"
+ 	;;
++x86_64-*-dragonfly*)
++	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${dfbsd_tm_file} i386/x86-64.h i386/dragonfly.h i386/dragonfly64.h"
++	;;
++i[34567]86-*-dragonfly*)
++	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${dfbsd_tm_file} i386/dragonfly.h"
++	;;
+ i[34567]86-*-netbsdelf*)
+-	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/netbsd-elf.h"
++	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/netbsd-elf.h netbsd-stdint.h"
+ 	extra_options="${extra_options} netbsd.opt netbsd-elf.opt"
++	tmake_file="${tmake_file} i386/t-crtstuff"
+ 	;;
+ i[34567]86-*-netbsd*)
+-	tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h netbsd.h netbsd-aout.h i386/netbsd.h"
++	tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h netbsd.h netbsd-aout.h i386/netbsd.h netbsd-stdint.h"
+ 	extra_options="${extra_options} netbsd.opt"
+ 	tmake_file="${tmake_file} t-netbsd"
+ 	extra_parts=""
+ 	use_collect2=yes
+ 	;;
+ x86_64-*-netbsd*)
+-	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/x86-64.h i386/netbsd64.h"
++	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/x86-64.h i386/netbsd64.h netbsd-stdint.h"
+ 	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/gcc46/patches/patch-ab b/gcc46/patches/patch-ab
new file mode 100644
index 0000000..1b4d179
--- /dev/null
+++ b/gcc46/patches/patch-ab
@@ -0,0 +1,53 @@
+$NetBSD: patch-ab,v 1.3 2014/01/25 13:38:48 ryoon Exp $
+
+* Add Dragonfly support.
+
+--- libgcc/config.host.orig	2011-11-23 22:15:54.000000000 +0000
++++ libgcc/config.host
+@@ -150,6 +150,8 @@ case ${host} in
+   # machine-specific sections may refine and add to this
+   # configuration.
+   ;;
++*-*-dragonfly*)
++  ;;
+ *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu*)
+   extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
+   ;;
+@@ -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"
+ 	;;
++i[34567]86-*-dragonfly*)
++	;;
++x86_64-*-dragonfly*)
++	;;
+ 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/gcc46/patches/patch-ac b/gcc46/patches/patch-ac
new file mode 100644
index 0000000..07e958e
--- /dev/null
+++ b/gcc46/patches/patch-ac
@@ -0,0 +1,17 @@
+$NetBSD: patch-ac,v 1.5 2015/01/01 01:29:56 ryoon Exp $
+
+Add gcc libdir to a programs rpath so that _this gcc's_ support libraries
+are found.
+
+NOTE: the %M spec string is added by patch-gcc_gcc.c
+
+--- gcc/Makefile.in.orig	2004-06-17 15:56:58.000000000 -0600
++++ gcc/Makefile.in
+@@ -1944,6 +1944,7 @@ c-omp.o : c-omp.c $(CONFIG_H) $(SYSTEM_H
+ # Language-independent files.
+ 
+ DRIVER_DEFINES = \
++  -DLINK_LIBGCC_SPEC="\"%D $(LINKER_RPATH_FLAG)$(prefix)/@GCC_TARGET_MACHINE@/lib/%M $(LINKER_RPATH_FLAG)$(libdir)/%M \"" \
+   -DSTANDARD_STARTFILE_PREFIX=\"$(unlibsubdir)/\" \
+   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
+   -DSTANDARD_LIBEXEC_PREFIX=\"$(libexecdir)/gcc/\" \
diff --git a/gcc46/patches/patch-ad b/gcc46/patches/patch-ad
new file mode 100644
index 0000000..66b788c
--- /dev/null
+++ b/gcc46/patches/patch-ad
@@ -0,0 +1,28 @@
+$NetBSD: patch-ad,v 1.3 2012/05/03 12:20:19 hans Exp $
+
+--- configure.orig	2011-03-16 18:27:36.000000000 +0000
++++ configure
+@@ -5269,7 +5269,7 @@ fi
+ 
+ 
+ if test "x$with_mpfr" != x; then
+-  gmplibs="-L$with_mpfr/lib $gmplibs"
++  gmplibs="-L$with_mpfr/lib ${COMPILER_RPATH_FLAG}$with_mpfr/lib $gmplibs"
+   gmpinc="-I$with_mpfr/include $gmpinc"
+ fi
+ if test "x$with_mpfr_include" != x; then
+@@ -5279,9 +5279,11 @@ if test "x$with_mpfr_lib" != x; then
+   gmplibs="-L$with_mpfr_lib $gmplibs"
+ fi
+ if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
+-  gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir $gmplibs"
+-  gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
+-  extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir"
++  sdir=
++  test -d "${srcdir}/mpfr/src" && sdir=/src
++  gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr'"$sdir/$lt_cv_objdir $gmplibs"
++  gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr'"$sdir "'-I$$s/mpfr'"$sdir $gmpinc"
++  extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr'"$sdir "'--with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr'"$sdir/$lt_cv_objdir"
+   # Do not test the mpfr version.  Assume that it is sufficient, since
+   # it is in the source tree, and the library has not been built yet
+   # but it would be included on the link line in the version check below
diff --git a/gcc46/patches/patch-af b/gcc46/patches/patch-af
new file mode 100644
index 0000000..302317e
--- /dev/null
+++ b/gcc46/patches/patch-af
@@ -0,0 +1,17 @@
+$NetBSD: patch-af,v 1.2 2012/04/17 07:48:13 sbd Exp $
+
+Avoid a reference to the wrapped make in the pkgsrc work directory from
+showing up in an installed file.
+See: libjava/contrib/aotcompile.py.in
+
+--- libjava/configure.orig	2011-03-25 17:07:00.000000000 +0000
++++ libjava/configure
+@@ -24653,7 +24653,7 @@ $as_echo "Python modules dir: ${python_m
+ 
+ 
+ # needed for aot-compile-rpm
+-MAKE=`which make`
++MAKE=${PKGSRC_MAKE}
+ 
+ 
+ # Check whether --enable-aot-compile-rpm was given.
diff --git a/gcc46/patches/patch-ag b/gcc46/patches/patch-ag
new file mode 100644
index 0000000..1187cc6
--- /dev/null
+++ b/gcc46/patches/patch-ag
@@ -0,0 +1,29 @@
+$NetBSD: patch-ag,v 1.2 2012/04/17 07:48:13 sbd Exp $
+
+No need to use bash for this small script.
+
+Also -print0 is not portable to solaris and perhaps others.
+
+--- libjava/contrib/rebuild-gcj-db.in.orig	2008-07-02 13:17:54.000000000 +0000
++++ libjava/contrib/rebuild-gcj-db.in
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/sh
+ # rebuild-gcj-db
+ 
+ ## Copyright (C) 2000, 2002, 2003, 2008 Free Software Foundation
+@@ -16,12 +16,12 @@ for i in `@prefix@/bin/gcc --print-multi
+    base=@prefix@/lib/$dirname
+    dbLocation=`@prefix@/bin/gcj-dbtool -p $base`
+    libdir=$base/gcj
+-   if ! test -d $libdir; then
++   if test ! -d $libdir; then
+       # No shared libraries here.
+       continue
+    fi
+    dirname $dbLocation | xargs mkdir -p
+    @prefix@/bin/gcj-dbtool -n $dbLocation 64
+-   find $libdir -follow -name '*.db' -print0 | \
++   find $libdir -follow -name '*.db' -print | @AWK@ '{printf("%s%c", $1, 0);}'| \
+       @prefix@/bin/gcj-dbtool -0 -m $dbLocation $dbLocation
+ done
diff --git a/gcc46/patches/patch-ah b/gcc46/patches/patch-ah
new file mode 100644
index 0000000..1e12b25
--- /dev/null
+++ b/gcc46/patches/patch-ah
@@ -0,0 +1,37 @@
+$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-04-05 08:13:16.000000000 +0000
++++ gcc/fortran/f95-lang.c
+@@ -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);
++#if defined(__NetBSD__)
++  gfc_define_builtin ("__builtin_cabs", func_cdouble_double, 
++		      BUILT_IN_CABS, "__c99_cabs", ATTR_CONST_NOTHROW_LEAF_LIST);
++  gfc_define_builtin ("__builtin_cabsf", func_cfloat_float, 
++		      BUILT_IN_CABSF, "__c99_cabsf", ATTR_CONST_NOTHROW_LEAF_LIST);
++#else
+   gfc_define_builtin ("__builtin_cabs", func_cdouble_double, 
+ 		      BUILT_IN_CABS, "cabs", ATTR_CONST_NOTHROW_LEAF_LIST);
+   gfc_define_builtin ("__builtin_cabsf", func_cfloat_float, 
+ 		      BUILT_IN_CABSF, "cabsf", ATTR_CONST_NOTHROW_LEAF_LIST);
++#endif
+  
+   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/gcc46/patches/patch-ak b/gcc46/patches/patch-ak
new file mode 100644
index 0000000..5fcb0cf
--- /dev/null
+++ b/gcc46/patches/patch-ak
@@ -0,0 +1,19 @@
+$NetBSD: patch-ak,v 1.2 2012/04/17 07:48:13 sbd Exp $
+
+Fix build on NetBSD i386/amd64 after the ansi.h header include protection
+name change.
+
+--- gcc/ginclude/stddef.h.orig	2011-01-29 22:15:52.000000000 +0000
++++ gcc/ginclude/stddef.h
+@@ -53,6 +53,11 @@ see the files COPYING3 and COPYING.RUNTI
+    one less case to deal with in the following.  */
+ #if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__)
+ #include <machine/ansi.h>
++#if !defined(_MACHINE_ANSI_H_)
++#if defined(_I386_ANSI_H_) || defined(_X86_64_ANSI_H_)
++#define _MACHINE_ANSI_H_
++#endif
++#endif
+ #endif
+ /* On FreeBSD 5, machine/ansi.h does not exist anymore... */
+ #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
diff --git a/gcc46/patches/patch-al b/gcc46/patches/patch-al
new file mode 100644
index 0000000..c60095f
--- /dev/null
+++ b/gcc46/patches/patch-al
@@ -0,0 +1,15 @@
+$NetBSD: patch-al,v 1.3 2012/04/17 07:48:13 sbd Exp $
+
+"#pragma weak" shouldn't be used on NetBSD.
+
+--- libgfortran/configure.orig	2011-06-27 10:13:01.000000000 +0000
++++ libgfortran/configure
+@@ -25699,7 +25699,7 @@ $as_echo "#define SUPPORTS_WEAK 1" >>con
+ 
+   fi
+   case "$host" in
+-    *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | alpha*-dec-osf* )
++    *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | alpha*-dec-osf* | *-*-netbsd* )
+ 
+ $as_echo "#define GTHREAD_USE_WEAK 0" >>confdefs.h
+ 
diff --git a/gcc46/patches/patch-boehm-gc_configure b/gcc46/patches/patch-boehm-gc_configure
new file mode 100644
index 0000000..eea4be3
--- /dev/null
+++ b/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/gcc46/patches/patch-boehm-gc_dyn__load.c b/gcc46/patches/patch-boehm-gc_dyn__load.c
new file mode 100644
index 0000000..564014f
--- /dev/null
+++ b/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/gcc46/patches/patch-boehm-gc_include_gc__config.h.in b/gcc46/patches/patch-boehm-gc_include_gc__config.h.in
new file mode 100644
index 0000000..d5787fd
--- /dev/null
+++ b/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/gcc46/patches/patch-boehm-gc_include_gc__config__macros.h b/gcc46/patches/patch-boehm-gc_include_gc__config__macros.h
new file mode 100644
index 0000000..599cda1
--- /dev/null
+++ b/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/gcc46/patches/patch-boehm-gc_include_gc__pthread__redirects.h b/gcc46/patches/patch-boehm-gc_include_gc__pthread__redirects.h
new file mode 100644
index 0000000..acf7408
--- /dev/null
+++ b/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/gcc46/patches/patch-boehm-gc_include_private_gcconfig.h b/gcc46/patches/patch-boehm-gc_include_private_gcconfig.h
new file mode 100644
index 0000000..4817c74
--- /dev/null
+++ b/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/gcc46/patches/patch-boehm-gc_mach__dep.c b/gcc46/patches/patch-boehm-gc_mach__dep.c
new file mode 100644
index 0000000..4f6d32f
--- /dev/null
+++ b/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/gcc46/patches/patch-boehm-gc_os__dep.c b/gcc46/patches/patch-boehm-gc_os__dep.c
new file mode 100644
index 0000000..7ac3811
--- /dev/null
+++ b/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/gcc46/patches/patch-boehm-gc_pthread__support.c b/gcc46/patches/patch-boehm-gc_pthread__support.c
new file mode 100644
index 0000000..677fd95
--- /dev/null
+++ b/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/gcc46/patches/patch-boehm-gc_tests_test.c b/gcc46/patches/patch-boehm-gc_tests_test.c
new file mode 100644
index 0000000..0e5283a
--- /dev/null
+++ b/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/gcc46/patches/patch-boehm-gc_threadlibs.c b/gcc46/patches/patch-boehm-gc_threadlibs.c
new file mode 100644
index 0000000..7ccee53
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_common.opt b/gcc46/patches/patch-gcc_common.opt
new file mode 100644
index 0000000..26d50aa
--- /dev/null
+++ b/gcc46/patches/patch-gcc_common.opt
@@ -0,0 +1,62 @@
+$NetBSD: patch-gcc_common.opt,v 1.2 2014/09/02 09:57:39 pho 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
diff --git a/gcc46/patches/patch-gcc_config.host b/gcc46/patches/patch-gcc_config.host
new file mode 100644
index 0000000..c1e5078
--- /dev/null
+++ b/gcc46/patches/patch-gcc_config.host
@@ -0,0 +1,22 @@
+$NetBSD: patch-gcc_config.host,v 1.2 2015/08/05 19:51:50 martin Exp $
+
+Add host hooks for NetBSD - needed for working precompiled headers.
+http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58397
+
+--- gcc/config.host.orig	2011-02-15 10:49:14.000000000 +0100
++++ gcc/config.host	2015-08-05 21:04:37.000000000 +0200
+@@ -268,6 +268,14 @@
+     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"
++    ;;
++  *-*-netbsd*)
++    out_host_hook_obj=host-netbsd.o
++    host_xmake_file="${host_xmake_file} x-netbsd"
++    ;;
+   *-*-linux*)
+     out_host_hook_obj=host-linux.o
+     host_xmake_file="${host_xmake_file} x-linux"
diff --git a/gcc46/patches/patch-gcc_config_arm_elf.h b/gcc46/patches/patch-gcc_config_arm_elf.h
new file mode 100644
index 0000000..f0b45d2
--- /dev/null
+++ b/gcc46/patches/patch-gcc_config_arm_elf.h
@@ -0,0 +1,14 @@
+$NetBSD: patch-gcc_config_arm_elf.h,v 1.1 2013/04/02 22:31:40 jmcneill Exp $
+
+--- gcc/config/arm/elf.h.orig	2009-06-21 20:48:15.000000000 +0000
++++ gcc/config/arm/elf.h
+@@ -161,6 +161,9 @@
+ #undef L_floatdidf
+ #undef L_floatdisf
+ #undef L_floatundidf
++/* XXXMRG: don't take this out, we need it! */
++# ifndef __NetBSD__
+ #undef L_floatundisf
++# endif
+ #endif
+ 
diff --git a/gcc46/patches/patch-gcc_config_arm_t-netbsd b/gcc46/patches/patch-gcc_config_arm_t-netbsd
new file mode 100644
index 0000000..94d1b40
--- /dev/null
+++ b/gcc46/patches/patch-gcc_config_arm_t-netbsd
@@ -0,0 +1,19 @@
+$NetBSD: patch-gcc_config_arm_t-netbsd,v 1.1 2013/04/02 22:31:40 jmcneill Exp $
+
+--- gcc/config/arm/t-netbsd.orig	2009-04-21 19:03:23.000000000 +0000
++++ gcc/config/arm/t-netbsd
+@@ -23,6 +23,14 @@ TARGET_LIBGCC2_CFLAGS = -fomit-frame-poi
+ LIBGCC2_DEBUG_CFLAGS = -g0
+ LIB2FUNCS_EXTRA = $(srcdir)/config/floatunsidf.c $(srcdir)/config/floatunsisf.c
+ 
++# This list is from t-arm-elf, but with some things removed.
++LIB1ASMFUNCS += _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func \
++	_call_via_rX _interwork_call_via_rX \
++	_arm_fixunsdfsi _arm_fixunssfsi \
++	_arm_floatdidf _arm_floatdisf _arm_floatundidf _arm_floatundisf \
++	_lshrdi3 _ashrdi3 _ashldi3 \
++	_clzsi2 _clzdi2
++
+ # Build a shared libgcc library.
+ SHLIB_EXT = .so
+ SHLIB_NAME = @shlib_base_name@.so
diff --git a/gcc46/patches/patch-gcc_config_exec-stack.h b/gcc46/patches/patch-gcc_config_exec-stack.h
new file mode 100644
index 0000000..7e89a4c
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_config_host-netbsd.c b/gcc46/patches/patch-gcc_config_host-netbsd.c
new file mode 100644
index 0000000..ec04185
--- /dev/null
+++ b/gcc46/patches/patch-gcc_config_host-netbsd.c
@@ -0,0 +1,93 @@
+$NetBSD: patch-gcc_config_host-netbsd.c,v 1.1 2015/08/05 19:51:50 martin Exp $
+
+Add host hooks for NetBSD - needed for working precompiled headers.
+http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58397
+
+--- /dev/null	2013-09-11 20:06:51.000000000 +0200
++++ gcc/config/host-netbsd.c	2013-09-11 20:29:31.000000000 +0200
+@@ -0,0 +1,85 @@
++/* NetBSD host-specific hook definitions.
++   Copyright (C) 2004-2013 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/>.  */
++
++#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 netbsd_gt_pch_get_address
++#undef HOST_HOOKS_GT_PCH_USE_ADDRESS
++#define HOST_HOOKS_GT_PCH_USE_ADDRESS netbsd_gt_pch_use_address
++
++/* For various ports, try to guess a fixed spot in the vm space
++   that's probably free.  */
++#if defined(__sparc64__)
++# define TRY_EMPTY_VM_SPACE	0x40000000000
++#elif defined(_LP64)
++# define TRY_EMPTY_VM_SPACE	0x400000000000
++#elif defined(__mips__) || defined(__vax__) || defined (__arm__)
++# define TRY_EMPTY_VM_SPACE	0x60000000
++#else
++# define TRY_EMPTY_VM_SPACE	0xb0000000
++#endif
++
++/* Determine a location where we might be able to reliably allocate
++   SIZE bytes.  FD is the PCH file, though we should return with the
++   file unmapped.  */
++
++static void *
++netbsd_gt_pch_get_address (size_t size, int fd)
++{
++  void *addr;
++
++  addr = mmap ((void *) TRY_EMPTY_VM_SPACE, size, PROT_READ | PROT_WRITE,
++	       MAP_PRIVATE | MAP_FIXED, fd, 0);
++
++  /* If we failed the map, that means there's *no* free space.  */
++  if (addr == (void *) MAP_FAILED)
++    return NULL;
++  /* Unmap the area before returning.  */
++  munmap (addr, size);
++
++  return addr;
++}
++
++/* Map SIZE bytes of FD+OFFSET at BASE.  Return 1 if we succeeded at 
++   mapping the data at BASE, -1 if we couldn't.  */
++
++static int
++netbsd_gt_pch_use_address (void *base, size_t size, int fd, size_t offset)
++{
++  void *addr;
++
++  /* We're called with size == 0 if we're not planning to load a PCH
++     file at all.  This allows the hook to free any static space that
++     we might have allocated at link time.  */
++  if (size == 0)
++    return -1;
++
++  addr = mmap (base, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, offset);
++
++  return addr == base ? 1 : -1;
++}
++
++
++const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
diff --git a/gcc46/patches/patch-gcc_config_host-openbsd.c b/gcc46/patches/patch-gcc_config_host-openbsd.c
new file mode 100644
index 0000000..e6b769e
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_config_i386_i386.c b/gcc46/patches/patch-gcc_config_i386_i386.c
new file mode 100644
index 0000000..f021d95
--- /dev/null
+++ b/gcc46/patches/patch-gcc_config_i386_i386.c
@@ -0,0 +1,32 @@
+$NetBSD: patch-gcc_config_i386_i386.c,v 1.1 2014/03/29 20:50:03 ryoon Exp $
+
+* Fix PR pkg/48670.
+  Fix build under NetBSD/i386 5.2 at least.
+  From http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/5dd34005fbf5509736906dc6aa56d3e77f6a3dcb?hp=9d5dccab15766b547c37d9b452e0971d340a6453
+
+--- gcc/config/i386/i386.c.orig	2013-04-02 16:54:58.000000000 +0000
++++ gcc/config/i386/i386.c
+@@ -59,6 +59,9 @@ along with GCC; see the file COPYING3.  
+ #include "sched-int.h"
+ #include "sbitmap.h"
+ #include "fibheap.h"
++#if defined(__NetBSD__)
++#include <sys/param.h>
++#endif
+ 
+ enum upper_128bits_state
+ {
+@@ -32185,9 +32188,13 @@ ix86_mangle_type (const_tree type)
+ static tree
+ ix86_stack_protect_fail (void)
+ {
++#if defined(__NetBSD__) && ( __NetBSD_Version__ >= 500000000) && ( __NetBSD_Version__ < 600000000)
++  return default_external_stack_protect_fail ();
++#else
+   return TARGET_64BIT
+ 	 ? default_external_stack_protect_fail ()
+ 	 : default_hidden_stack_protect_fail ();
++#endif
+ }
+ 
+ /* Select a format to encode pointers in exception handling data.  CODE
diff --git a/gcc46/patches/patch-gcc_config_i386_openbsd.h b/gcc46/patches/patch-gcc_config_i386_openbsd.h
new file mode 100644
index 0000000..e586905
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_config_i386_openbsd64.h b/gcc46/patches/patch-gcc_config_i386_openbsd64.h
new file mode 100644
index 0000000..e478588
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_config_i386_openbsdelf.h b/gcc46/patches/patch-gcc_config_i386_openbsdelf.h
new file mode 100644
index 0000000..c8f13ba
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_config_netbsd.h b/gcc46/patches/patch-gcc_config_netbsd.h
new file mode 100644
index 0000000..cfbef89
--- /dev/null
+++ b/gcc46/patches/patch-gcc_config_netbsd.h
@@ -0,0 +1,22 @@
+$NetBSD: patch-gcc_config_netbsd.h,v 1.1 2016/09/06 13:57:02 maya Exp $
+
+when using shared, link against libc.
+
+--- gcc/config/netbsd.h.orig	2013-01-10 20:38:27.000000000 +0000
++++ gcc/config/netbsd.h
+@@ -96,6 +96,7 @@ along with GCC; see the file COPYING3.  
+        %{!pg:-lposix}}		\
+      %{p:-lposix_p}		\
+      %{pg:-lposix_p}}		\
++   %{shared:-lc}		\
+    %{!shared:			\
+      %{!symbolic:		\
+        %{!p:			\
+@@ -109,6 +110,7 @@ along with GCC; see the file COPYING3.  
+        %{!pg:-lposix}}		\
+      %{p:-lposix_p}		\
+      %{pg:-lposix_p}}		\
++   %{shared:-lc}		\
+    %{!shared:			\
+      %{!symbolic:		\
+        %{!p:			\
diff --git a/gcc46/patches/patch-gcc_config_openbsd-libpthread.h b/gcc46/patches/patch-gcc_config_openbsd-libpthread.h
new file mode 100644
index 0000000..1c946a2
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_config_openbsd.h b/gcc46/patches/patch-gcc_config_openbsd.h
new file mode 100644
index 0000000..b466663
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_config_t-openbsd b/gcc46/patches/patch-gcc_config_t-openbsd
new file mode 100644
index 0000000..2e93873
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_config_x-netbsd b/gcc46/patches/patch-gcc_config_x-netbsd
new file mode 100644
index 0000000..b5ddff6
--- /dev/null
+++ b/gcc46/patches/patch-gcc_config_x-netbsd
@@ -0,0 +1,12 @@
+$NetBSD: patch-gcc_config_x-netbsd,v 1.1 2015/08/05 19:51:50 martin Exp $
+
+Add host hooks for NetBSD - needed for working precompiled headers.
+http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58397
+
+--- /dev/null	2013-09-11 09:12:57.000000000 +0200
++++ gcc/config/x-netbsd	2013-09-10 18:57:27.000000000 +0200
+@@ -0,0 +1,4 @@
++host-netbsd.o : $(srcdir)/config/host-netbsd.c $(CONFIG_H) $(SYSTEM_H) \
++  coretypes.h hosthooks.h hosthooks-def.h $(HOOKS_H)
++	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
++		$(srcdir)/config/host-netbsd.c
diff --git a/gcc46/patches/patch-gcc_config_x-openbsd b/gcc46/patches/patch-gcc_config_x-openbsd
new file mode 100644
index 0000000..5f7038f
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_configure b/gcc46/patches/patch-gcc_configure
new file mode 100644
index 0000000..f005b93
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_defaults.h b/gcc46/patches/patch-gcc_defaults.h
new file mode 100644
index 0000000..6584da5
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_gcc.c b/gcc46/patches/patch-gcc_gcc.c
new file mode 100644
index 0000000..ab754b4
--- /dev/null
+++ b/gcc46/patches/patch-gcc_gcc.c
@@ -0,0 +1,30 @@
+$NetBSD: patch-gcc_gcc.c,v 1.2 2015/01/01 01:29:56 ryoon Exp $
+
+Add %M spec string.
+From pkgsrc/lang/gcc47/patches/patch-gcc_gcc.c
+
+--- 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
+@@ -5101,6 +5101,13 @@ do_spec_1 (const char *spec, int inswitc
+ 	      return value;
+ 	    break;
+ 
++	  case 'M':
++	    if (multilib_os_dir == NULL)
++	      obstack_1grow (&obstack, '.');
++	    else
++	      obstack_grow (&obstack, multilib_os_dir, strlen(multilib_os_dir));
++	    break;
++
+ 	  case 'G':
+ 	    value = do_spec_1 (libgcc_spec, 0, NULL);
+ 	    if (value != 0)
diff --git a/gcc46/patches/patch-gcc_ggc-common.c b/gcc46/patches/patch-gcc_ggc-common.c
new file mode 100644
index 0000000..2093ecd
--- /dev/null
+++ b/gcc46/patches/patch-gcc_ggc-common.c
@@ -0,0 +1,86 @@
+$NetBSD: patch-gcc_ggc-common.c,v 1.1 2015/08/05 19:51:50 martin Exp $
+
+When failing a PCH read-in, restore some globals to allow the generic
+error reporting to work in pre-PCH context.
+
+Patch submitted upstream in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58381
+
+--- gcc/ggc-common.c.orig	2013-03-05 16:51:48.000000000 +0100
++++ gcc/ggc-common.c	2013-09-10 17:20:52.000000000 +0200
+@@ -666,6 +666,8 @@
+   size_t i;
+   struct mmap_info mmi;
+   int result;
++  struct line_maps * old_line_table = line_table;
++  location_t old_input_loc = input_location;
+ 
+   /* Delete any deletable objects.  This makes ggc_pch_read much
+      faster, as it can be sure that no GCable objects remain other
+@@ -677,39 +679,60 @@
+   /* Read in all the scalar variables.  */
+   for (rt = gt_pch_scalar_rtab; *rt; rt++)
+     for (rti = *rt; rti->base != NULL; rti++)
+-      if (fread (rti->base, rti->stride, 1, f) != 1)
++      if (fread (rti->base, rti->stride, 1, f) != 1) {
++        line_table = old_line_table;
++	input_location = old_input_loc;
+ 	fatal_error ("can%'t read PCH file: %m");
++      }
+ 
+   /* Read in all the global pointers, in 6 easy loops.  */
+   for (rt = gt_ggc_rtab; *rt; rt++)
+     for (rti = *rt; rti->base != NULL; rti++)
+       for (i = 0; i < rti->nelt; i++)
+ 	if (fread ((char *)rti->base + rti->stride * i,
+-		   sizeof (void *), 1, f) != 1)
++		   sizeof (void *), 1, f) != 1) {
++          line_table = old_line_table;
++	  input_location = old_input_loc;
+ 	  fatal_error ("can%'t read PCH file: %m");
++        }
+ 
+   for (rt = gt_pch_cache_rtab; *rt; rt++)
+     for (rti = *rt; rti->base != NULL; rti++)
+       for (i = 0; i < rti->nelt; i++)
+ 	if (fread ((char *)rti->base + rti->stride * i,
+-		   sizeof (void *), 1, f) != 1)
++		   sizeof (void *), 1, f) != 1) {
++          line_table = old_line_table;
++	  input_location = old_input_loc;
+ 	  fatal_error ("can%'t read PCH file: %m");
++        }
+ 
+-  if (fread (&mmi, sizeof (mmi), 1, f) != 1)
++  if (fread (&mmi, sizeof (mmi), 1, f) != 1) {
++    line_table = old_line_table;
++    input_location = old_input_loc;
+     fatal_error ("can%'t read PCH file: %m");
++  }
+ 
+   result = host_hooks.gt_pch_use_address (mmi.preferred_base, mmi.size,
+ 					  fileno (f), mmi.offset);
+-  if (result < 0)
++  if (result < 0) {
++    line_table = old_line_table;
++    input_location = old_input_loc;
+     fatal_error ("had to relocate PCH");
++  }
+   if (result == 0)
+     {
+       if (fseek (f, mmi.offset, SEEK_SET) != 0
+-	  || fread (mmi.preferred_base, mmi.size, 1, f) != 1)
++	  || fread (mmi.preferred_base, mmi.size, 1, f) != 1) {
++        line_table = old_line_table;
++        input_location = old_input_loc;
+ 	fatal_error ("can%'t read PCH file: %m");
++      }
+     }
+-  else if (fseek (f, mmi.offset + mmi.size, SEEK_SET) != 0)
++  else if (fseek (f, mmi.offset + mmi.size, SEEK_SET) != 0) {
++    line_table = old_line_table;
++    input_location = old_input_loc;
+     fatal_error ("can%'t read PCH file: %m");
++  }
+ 
+   ggc_pch_read (f, mmi.preferred_base);
+ 
diff --git a/gcc46/patches/patch-gcc_lto_lto.c b/gcc46/patches/patch-gcc_lto_lto.c
new file mode 100644
index 0000000..c9353fc
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_opts.c b/gcc46/patches/patch-gcc_opts.c
new file mode 100644
index 0000000..a86c53d
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_unwind-dw2-fde-glibc.c b/gcc46/patches/patch-gcc_unwind-dw2-fde-glibc.c
new file mode 100644
index 0000000..f61823a
--- /dev/null
+++ b/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/gcc46/patches/patch-gcc_unwind-dw2-fde-openbsd.c b/gcc46/patches/patch-gcc_unwind-dw2-fde-openbsd.c
new file mode 100644
index 0000000..b77e0a3
--- /dev/null
+++ b/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/gcc46/patches/patch-include_libiberty.h b/gcc46/patches/patch-include_libiberty.h
new file mode 100644
index 0000000..7628dbb
--- /dev/null
+++ b/gcc46/patches/patch-include_libiberty.h
@@ -0,0 +1,24 @@
+$NetBSD: patch-include_libiberty.h,v 1.1 2016/09/06 13:57:02 maya Exp $
+
+Don't use PARAMS
+cherry picked necessary parts from
+https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=206881
+
+fixes PR pkg/50042
+
+--- include/libiberty.h.orig	2011-01-03 20:52:22.000000000 +0000
++++ include/libiberty.h
+@@ -85,11 +85,11 @@ extern char **dupargv (char **) ATTRIBUT
+ 
+ /* Expand "@file" arguments in argv.  */
+ 
+-extern void expandargv PARAMS ((int *, char ***));
++extern void expandargv (int *, char ***);
+ 
+ /* Write argv to an @-file, inserting necessary quoting.  */
+ 
+-extern int writeargv PARAMS ((char **, FILE *));
++extern int writeargv (char **, FILE *);
+ 
+ /* Return the last component of a path name.  Note that we can't use a
+    prototype here because the parameter is declared inconsistently
diff --git a/gcc46/patches/patch-libgcc_config_t-slibgcc-darwin b/gcc46/patches/patch-libgcc_config_t-slibgcc-darwin
new file mode 100644
index 0000000..3097b1a
--- /dev/null
+++ b/gcc46/patches/patch-libgcc_config_t-slibgcc-darwin
@@ -0,0 +1,26 @@
+$NetBSD: patch-libgcc_config_t-slibgcc-darwin,v 1.1 2014/05/15 12:04:41 pho Exp $
+
+If we don't install libgcc_s.10.[45].dylib, our gcc links binaries
+with *both* /usr/lib/libgcc_s.1.dylib and
+${GCC_PREFIX}/lib/libgcc_s.1.dylib, which is certainly a bad thing.
+
+The problem was already reported to the upstream but it caught
+seemingly no attention:
+http://gcc.gnu.org/ml/gcc-help/2010-07/msg00164.html
+
+--- libgcc/config/t-slibgcc-darwin.orig	2010-02-02 08:18:48.000000000 +0000
++++ libgcc/config/t-slibgcc-darwin
+@@ -26,13 +26,7 @@ SHLIB_MKMAP = $(gcc_srcdir)/mkmap-flat.a
+ SHLIB_MKMAP_OPTS = -v leading_underscore=1
+ SHLIB_MAPFILES += $(gcc_srcdir)/libgcc-std.ver $(gcc_srcdir)/libgcc-libsystem.ver
+ 
+-# we're only going to build the stubs if the target slib is /usr/lib
+-# there is no other case in which they're useful in a live system.
+-ifeq (/usr/lib,$(shlib_slibdir))
+ LGCC_STUBS = libgcc_s.10.4.dylib libgcc_s.10.5.dylib
+-else
+-LGCC_STUBS =
+-endif
+ 
+ LGCC_FILES = libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
+ LGCC_FILES += $(LGCC_STUBS)
diff --git a/gcc46/patches/patch-libiberty___doprnt.c b/gcc46/patches/patch-libiberty___doprnt.c
new file mode 100644
index 0000000..82a85b2
--- /dev/null
+++ b/gcc46/patches/patch-libiberty___doprnt.c
@@ -0,0 +1,25 @@
+$NetBSD: patch-libiberty___doprnt.c,v 1.1 2016/09/06 13:57:02 maya Exp $
+
+use stdarg, not VA_* macros.
+cherry picked necessary parts from
+https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=206881
+
+fixes PR pkg/50042
+
+--- libiberty/_doprnt.c.orig	2005-05-10 15:33:18.000000000 +0000
++++ libiberty/_doprnt.c
+@@ -222,11 +222,11 @@ static int
+ checkit (const char* format, ...)
+ {
+   int result;
+-  VA_OPEN (args, format);
+-  VA_FIXEDARG (args, char *, format);
++  va_list args;
++  va_start (args, format);
+ 
+   result = _doprnt (format, args, stdout);
+-  VA_CLOSE (args);
++  va_end (args);
+ 
+   return result;
+ }
diff --git a/gcc46/patches/patch-libiberty_asprintf.c b/gcc46/patches/patch-libiberty_asprintf.c
new file mode 100644
index 0000000..a1d24bf
--- /dev/null
+++ b/gcc46/patches/patch-libiberty_asprintf.c
@@ -0,0 +1,24 @@
+$NetBSD: patch-libiberty_asprintf.c,v 1.1 2016/09/06 13:57:02 maya Exp $
+
+use stdarg, not VA_* macros.
+cherry picked necessary parts from
+https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=206881
+
+fixes PR pkg/50042
+
+--- libiberty/asprintf.c.orig	2005-05-10 15:33:18.000000000 +0000
++++ libiberty/asprintf.c
+@@ -47,10 +47,9 @@ int
+ asprintf (char **buf, const char *fmt, ...)
+ {
+   int status;
+-  VA_OPEN (ap, fmt);
+-  VA_FIXEDARG (ap, char **, buf);
+-  VA_FIXEDARG (ap, const char *, fmt);
++  va_list ap;
++  va_start (ap, fmt);
+   status = vasprintf (buf, fmt, ap);
+-  VA_CLOSE (ap);
++  va_end (ap);
+   return status;
+ }
diff --git a/gcc46/patches/patch-libiberty_concat.c b/gcc46/patches/patch-libiberty_concat.c
new file mode 100644
index 0000000..b937a7e
--- /dev/null
+++ b/gcc46/patches/patch-libiberty_concat.c
@@ -0,0 +1,108 @@
+$NetBSD: patch-libiberty_concat.c,v 1.1 2016/09/06 13:57:02 maya Exp $
+
+use stdarg, not VA_* macros.
+cherry picked necessary parts from
+https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=206881
+
+fixes PR pkg/50042
+
+--- libiberty/concat.c.orig	2011-02-03 07:23:20.000000000 +0000
++++ libiberty/concat.c
+@@ -102,11 +90,11 @@ unsigned long
+ concat_length (const char *first, ...)
+ {
+   unsigned long length;
++  va_list args;
+ 
+-  VA_OPEN (args, first);
+-  VA_FIXEDARG (args, const char *, first);
++  va_start (args, first);
+   length = vconcat_length (first, args);
+-  VA_CLOSE (args);
++  va_end (args);
+ 
+   return length;
+ }
+@@ -117,13 +105,12 @@ char *
+ concat_copy (char *dst, const char *first, ...)
+ {
+   char *save_dst;
++  va_list args;
+ 
+-  VA_OPEN (args, first);
+-  VA_FIXEDARG (args, char *, dst);
+-  VA_FIXEDARG (args, const char *, first);
++  va_start (args, first);
+   vconcat_copy (dst, first, args);
+   save_dst = dst; /* With K&R C, dst goes out of scope here.  */
+-  VA_CLOSE (args);
++  va_end (args);
+ 
+   return save_dst;
+ }
+@@ -141,10 +128,10 @@ char *libiberty_concat_ptr;
+ char *
+ concat_copy2 (const char *first, ...)
+ {
+-  VA_OPEN (args, first);
+-  VA_FIXEDARG (args, const char *, first);
++  va_list args;
++  va_start (args, first);
+   vconcat_copy (libiberty_concat_ptr, first, args);
+-  VA_CLOSE (args);
++  va_end (args);
+ 
+   return libiberty_concat_ptr;
+ }
+@@ -153,18 +140,17 @@ char *
+ concat (const char *first, ...)
+ {
+   char *newstr;
++  va_list args;
+ 
+   /* First compute the size of the result and get sufficient memory.  */
+-  VA_OPEN (args, first);
+-  VA_FIXEDARG (args, const char *, first);
++  va_start (args, first);
+   newstr = XNEWVEC (char, vconcat_length (first, args) + 1);
+-  VA_CLOSE (args);
++  va_end (args);
+ 
+   /* Now copy the individual pieces to the result string. */
+-  VA_OPEN (args, first);
+-  VA_FIXEDARG (args, const char *, first);
++  va_start (args, first);
+   vconcat_copy (newstr, first, args);
+-  VA_CLOSE (args);
++  va_end (args);
+ 
+   return newstr;
+ }
+@@ -191,22 +177,19 @@ char *
+ reconcat (char *optr, const char *first, ...)
+ {
+   char *newstr;
++  va_list args;
+ 
+   /* First compute the size of the result and get sufficient memory.  */
+-  VA_OPEN (args, first);
+-  VA_FIXEDARG (args, char *, optr);
+-  VA_FIXEDARG (args, const char *, first);
++  va_start (args, first);
+   newstr = XNEWVEC (char, vconcat_length (first, args) + 1);
+-  VA_CLOSE (args);
++  va_end (args);
+ 
+   /* Now copy the individual pieces to the result string. */
+-  VA_OPEN (args, first);
+-  VA_FIXEDARG (args, char *, optr);
+-  VA_FIXEDARG (args, const char *, first);
++  va_start (args, first);
+   vconcat_copy (newstr, first, args);
+   if (optr) /* Done before VA_CLOSE so optr stays in scope for K&R C.  */
+     free (optr);
+-  VA_CLOSE (args);
++  va_end (args);
+ 
+   return newstr;
+ }
diff --git a/gcc46/patches/patch-libiberty_snprintf.c b/gcc46/patches/patch-libiberty_snprintf.c
new file mode 100644
index 0000000..5a8b977
--- /dev/null
+++ b/gcc46/patches/patch-libiberty_snprintf.c
@@ -0,0 +1,25 @@
+$NetBSD: patch-libiberty_snprintf.c,v 1.1 2016/09/06 13:57:02 maya Exp $
+
+use stdarg, not VA_* macros.
+cherry picked necessary parts from
+https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=206881
+
+fixes PR pkg/50042
+
+--- libiberty/snprintf.c.orig	2011-02-03 07:23:20.000000000 +0000
++++ libiberty/snprintf.c
+@@ -53,11 +53,9 @@ int
+ snprintf (char *s, size_t n, const char *format, ...)
+ {
+   int result;
+-  VA_OPEN (ap, format);
+-  VA_FIXEDARG (ap, char *, s);
+-  VA_FIXEDARG (ap, size_t, n);
+-  VA_FIXEDARG (ap, const char *, format);
++  va_list ap;
++  va_start (ap, format);
+   result = vsnprintf (s, n, format, ap);
+-  VA_CLOSE (ap);
++  va_end (ap);
+   return result;
+ }
diff --git a/gcc46/patches/patch-libiberty_vasprintf.c b/gcc46/patches/patch-libiberty_vasprintf.c
new file mode 100644
index 0000000..a9e98b5
--- /dev/null
+++ b/gcc46/patches/patch-libiberty_vasprintf.c
@@ -0,0 +1,24 @@
+$NetBSD: patch-libiberty_vasprintf.c,v 1.1 2016/09/06 13:57:02 maya Exp $
+
+use stdarg, not VA_* macros.
+cherry picked necessary parts from
+https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=206881
+
+fixes PR pkg/50042
+
+--- libiberty/vasprintf.c.orig	2011-02-03 07:23:20.000000000 +0000
++++ libiberty/vasprintf.c
+@@ -165,10 +165,10 @@ static void ATTRIBUTE_PRINTF_1
+ checkit (const char *format, ...)
+ {
+   char *result;
+-  VA_OPEN (args, format);
+-  VA_FIXEDARG (args, const char *, format);
++  va_list args;
++  va_start (args, format);
+   vasprintf (&result, format, args);
+-  VA_CLOSE (args);
++  va_end (args);
+ 
+   if (strlen (result) < (size_t) global_total_width)
+     printf ("PASS: ");
diff --git a/gcc46/patches/patch-libiberty_vsnprintf.c b/gcc46/patches/patch-libiberty_vsnprintf.c
new file mode 100644
index 0000000..bcba0a2
--- /dev/null
+++ b/gcc46/patches/patch-libiberty_vsnprintf.c
@@ -0,0 +1,26 @@
+$NetBSD: patch-libiberty_vsnprintf.c,v 1.1 2016/09/06 13:57:02 maya Exp $
+
+use stdarg, not VA_* macros.
+cherry picked necessary parts from
+https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=206881
+
+fixes PR pkg/50042
+
+--- libiberty/vsnprintf.c.orig	2011-02-03 07:23:20.000000000 +0000
++++ libiberty/vsnprintf.c
+@@ -95,12 +95,10 @@ static int ATTRIBUTE_PRINTF_3
+ checkit (char *s, size_t n, const char *format, ...)
+ {
+   int result;
+-  VA_OPEN (ap, format);
+-  VA_FIXEDARG (ap, char *, s);
+-  VA_FIXEDARG (ap, size_t, n);
+-  VA_FIXEDARG (ap, const char *, format);
++  va_list ap;
++  va_start (ap, format);
+   result = vsnprintf (s, n, format, ap);
+-  VA_CLOSE (ap);
++  va_end (ap);
+   return result;
+ }
+ 
diff --git a/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h b/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h
new file mode 100644
index 0000000..b54d2d5
--- /dev/null
+++ b/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h
@@ -0,0 +1,69 @@
+$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	2012-06-20 08:30:55.000000000 +0000
++++ libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
+@@ -30,7 +30,7 @@
+ // Full details can be found from the CVS files at:
+ //   anoncvs%anoncvs.netbsd.org@localhost:/cvsroot/basesrc/include/ctype.h
+ // See www.netbsd.org for details of access.
+-  
++
+ namespace std _GLIBCXX_VISIBILITY(default)
+ {
+ _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.
++#if defined(_CTYPE_BL)
++    typedef unsigned short      mask;
++    static const mask upper     = _CTYPE_U;
++    static const mask lower     = _CTYPE_L;
++    static const mask alpha     = _CTYPE_A;
++    static const mask digit     = _CTYPE_D;
++    static const mask xdigit    = _CTYPE_X;
++    static const mask space     = _CTYPE_S;
++    static const mask print     = _CTYPE_R;
++    static const mask graph     = _CTYPE_G;
++    static const mask cntrl     = _CTYPE_C;
++    static const mask punct     = _CTYPE_P;
++    static const mask alnum     = _CTYPE_A | _CTYPE_D;
++#elif defined(_CTYPE_U)
+     typedef unsigned char      	mask;
+-
+-#ifndef _CTYPE_U
+-    static const mask upper    	= _U;
+-    static const mask lower 	= _L;
+-    static const mask alpha 	= _U | _L;
+-    static const mask digit 	= _N;
+-    static const mask xdigit 	= _N | _X;
+-    static const mask space 	= _S;
+-    static const mask print 	= _P | _U | _L | _N | _B;
+-    static const mask graph 	= _P | _U | _L | _N;
+-    static const mask cntrl 	= _C;
+-    static const mask punct 	= _P;
+-    static const mask alnum 	= _U | _L | _N;
+-#else
+     static const mask upper    	= _CTYPE_U;
+     static const mask lower 	= _CTYPE_L;
+     static const mask alpha 	= _CTYPE_U | _CTYPE_L;
+@@ -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;
++#else
++    typedef unsigned char      	mask;
++    static const mask upper    	= _U;
++    static const mask lower 	= _L;
++    static const mask alpha 	= _U | _L;
++    static const mask digit 	= _N;
++    static const mask xdigit 	= _N | _X;
++    static const mask space 	= _S;
++    static const mask print 	= _P | _U | _L | _N | _B;
++    static const mask graph 	= _P | _U | _L | _N;
++    static const mask cntrl 	= _C;
++    static const mask punct 	= _P;
++    static const mask alnum 	= _U | _L | _N;
+ #endif
+   };
+ 
diff --git a/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__inline.h b/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__inline.h
new file mode 100644
index 0000000..4c306c7
--- /dev/null
+++ b/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__inline.h
@@ -0,0 +1,13 @@
+$NetBSD: patch-libstdc++-v3_config_os_bsd_netbsd_ctype__inline.h,v 1.1 2013/04/30 22:24:16 joerg Exp $
+
+--- libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h.orig	2011-01-30 22:39:36.000000000 +0000
++++ libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h
+@@ -48,7 +48,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+   is(const char* __low, const char* __high, mask* __vec) const
+   {
+     while (__low < __high)
+-      *__vec++ = _M_table[*__low++];
++      *__vec++ = _M_table[(unsigned char)*__low++];
+     return __high;
+   }
+ 
diff --git a/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__noninline.h b/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__noninline.h
new file mode 100644
index 0000000..7b9d9a3
--- /dev/null
+++ b/gcc46/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__noninline.h
@@ -0,0 +1,57 @@
+$NetBSD: patch-libstdc++-v3_config_os_bsd_netbsd_ctype__noninline.h,v 1.1 2013/04/30 22:24:16 joerg Exp $
+
+--- libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h.orig	2011-01-03 20:52:22.000000000 +0000
++++ libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h
+@@ -34,11 +34,17 @@
+   
+ // Information as gleaned from /usr/include/ctype.h
+ 
++#ifndef _CTYPE_BL
+   extern "C" const u_int8_t _C_ctype_[];
++#endif
+ 
+   const ctype_base::mask*
+   ctype<char>::classic_table() throw()
+-  { return _C_ctype_ + 1; }
++#ifdef _CTYPE_BL
++  { return _C_ctype_tab_ + 1; }
++#else
++   { return _C_ctype_ + 1; }
++#endif
+ 
+   ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+ 		     size_t __refs) 
+@@ -65,14 +71,14 @@
+ 
+   char
+   ctype<char>::do_toupper(char __c) const
+-  { return ::toupper((int) __c); }
++  { return ::toupper((int)(unsigned char) __c); }
+ 
+   const char*
+   ctype<char>::do_toupper(char* __low, const char* __high) const
+   {
+     while (__low < __high)
+       {
+-	*__low = ::toupper((int) *__low);
++	*__low = ::toupper((int)(unsigned char) *__low);
+ 	++__low;
+       }
+     return __high;
+@@ -80,14 +86,14 @@
+ 
+   char
+   ctype<char>::do_tolower(char __c) const
+-  { return ::tolower((int) __c); }
++  { return ::tolower((int)(unsigned char) __c); }
+ 
+   const char* 
+   ctype<char>::do_tolower(char* __low, const char* __high) const
+   {
+     while (__low < __high)
+       {
+-	*__low = ::tolower((int) *__low);
++	*__low = ::tolower((int)(unsigned char) *__low);
+ 	++__low;
+       }
+     return __high;
diff --git a/gcc46/patches/patch-libstdc++-v3_include_std_mutex b/gcc46/patches/patch-libstdc++-v3_include_std_mutex
new file mode 100644
index 0000000..500e80d
--- /dev/null
+++ b/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>



Home | Main Index | Thread Index | Old Index