summaryrefslogtreecommitdiff
path: root/lang/gcc5/patches
diff options
context:
space:
mode:
authorryoon <ryoon>2015-07-16 12:03:36 +0000
committerryoon <ryoon>2015-07-16 12:03:36 +0000
commit4f8c7a13adee7c84b85677ddc30d2e48abc7f813 (patch)
treec73afcdd96699171c82b509d29087a5270947c64 /lang/gcc5/patches
parent7cd468ee103e70591dd68c03e3d523b209ddab07 (diff)
downloadpkgsrc-4f8c7a13adee7c84b85677ddc30d2e48abc7f813.tar.gz
Import gcc5-5.1.0 as lang/gcc5.
The GNU Compiler Collection (GCC) includes front ends for C, C++, Objective-C, Fortran, Java, and Go, as well as libraries for these languages (libstdc++, libgcj,...). This package provides the snapshot release of version 5. On NetBSD a working cabsl function must be present in libm to build gfortran. This has been added to -current on 2014/10/10 and to NetBSD7 on 2014/10/13.
Diffstat (limited to 'lang/gcc5/patches')
-rw-r--r--lang/gcc5/patches/patch-gcc_Makefile.in15
-rw-r--r--lang/gcc5/patches/patch-gcc_config.gcc39
-rw-r--r--lang/gcc5/patches/patch-gcc_config_netbsd-protos.h34
-rw-r--r--lang/gcc5/patches/patch-gcc_config_netbsd-stdint.h63
-rw-r--r--lang/gcc5/patches/patch-gcc_config_netbsd.c127
-rw-r--r--lang/gcc5/patches/patch-gcc_config_netbsd.h24
-rw-r--r--lang/gcc5/patches/patch-gcc_config_t-netbsd28
-rw-r--r--lang/gcc5/patches/patch-gcc_config_x-netbsd12
-rw-r--r--lang/gcc5/patches/patch-gcc_configure18
-rw-r--r--lang/gcc5/patches/patch-gcc_ggc-common.c71
-rw-r--r--lang/gcc5/patches/patch-gcc_lto_lto.c19
-rw-r--r--lang/gcc5/patches/patch-gcc_system.h27
-rw-r--r--lang/gcc5/patches/patch-libcilkrts_configure13
-rw-r--r--lang/gcc5/patches/patch-libcilkrts_runtime_os-unix.c33
-rw-r--r--lang/gcc5/patches/patch-libdecnumber_decNumber.c13
-rw-r--r--lang/gcc5/patches/patch-libffi_configure13
-rw-r--r--lang/gcc5/patches/patch-libffi_testsuite_libffi.call_float2.c13
-rw-r--r--lang/gcc5/patches/patch-libgcc_crtstuff.c14
-rw-r--r--lang/gcc5/patches/patch-libgcc_unwind-dw2-fde-dip.c13
-rw-r--r--lang/gcc5/patches/patch-libgfortran_configure13
-rw-r--r--lang/gcc5/patches/patch-libgo_Makefile.in17
-rw-r--r--lang/gcc5/patches/patch-libgo_mksysinfo.sh13
-rw-r--r--lang/gcc5/patches/patch-libjava_boehm.cc22
-rw-r--r--lang/gcc5/patches/patch-libjava_configure17
-rw-r--r--lang/gcc5/patches/patch-libjava_contrib_rebuild-gcj-db.in29
-rw-r--r--lang/gcc5/patches/patch-libsanitizer_configure.tgt13
-rw-r--r--lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h37
-rw-r--r--lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__configure__char.cc57
-rw-r--r--lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__inline.h13
-rw-r--r--lang/gcc5/patches/patch-libstdc++-v3_libsupc++_unwind-cxx.h12
30 files changed, 832 insertions, 0 deletions
diff --git a/lang/gcc5/patches/patch-gcc_Makefile.in b/lang/gcc5/patches/patch-gcc_Makefile.in
new file mode 100644
index 00000000000..c76a7e4301d
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_Makefile.in
@@ -0,0 +1,15 @@
+$NetBSD: patch-gcc_Makefile.in,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+Add gcc libdir to a programs rpath so that _this gcc's_ support libraries
+are found.
+
+--- gcc/Makefile.in.orig 2013-03-05 09:46:34.000000000 +0000
++++ gcc/Makefile.in
+@@ -2027,6 +2027,7 @@ prefix.o: prefix.c $(CONFIG_H) $(SYSTEM_
+ # 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/lang/gcc5/patches/patch-gcc_config.gcc b/lang/gcc5/patches/patch-gcc_config.gcc
new file mode 100644
index 00000000000..8aad48ec3bb
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_config.gcc
@@ -0,0 +1,39 @@
+$NetBSD: patch-gcc_config.gcc,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- gcc/config.gcc.orig 2014-11-21 16:04:20.000000000 +0000
++++ gcc/config.gcc
+@@ -745,10 +745,16 @@ case ${target} in
+ target_has_targetcm=yes
+ ;;
+ *-*-netbsd*)
+- tmake_file="t-slibgcc"
++ use_gcc_stdint=wrap
++ tmake_file="t-slibgcc t-netbsd"
+ gas=yes
+ gnu_ld=yes
+
++ # cabs/cabsf are renamed to __c99_cabs/cabsf
++ tm_p_file="${tm_p_file} netbsd-protos.h"
++ target_gtfiles="\$(srcdir)/config/netbsd.c"
++ extra_objs="netbsd.o"
++
+ # NetBSD 2.0 and later get POSIX threads enabled by default.
+ # Allow them to be explicitly enabled on any other version.
+ case ${enable_threads} in
+@@ -1372,12 +1378,14 @@ 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"
+ ;;
+ 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"
+ ;;
+ 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"
+ ;;
+ i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123])
+ tm_file="i386/i386.h i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h openbsd-oldgas.h openbsd.h i386/openbsd.h"
diff --git a/lang/gcc5/patches/patch-gcc_config_netbsd-protos.h b/lang/gcc5/patches/patch-gcc_config_netbsd-protos.h
new file mode 100644
index 00000000000..e87c8d5dd54
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_config_netbsd-protos.h
@@ -0,0 +1,34 @@
+$NetBSD: patch-gcc_config_netbsd-protos.h,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- /dev/null 2014-12-15 07:13:57.000000000 +0000
++++ gcc/config/netbsd-protos.h
+@@ -0,0 +1,29 @@
++/* Prototypes.
++ Copyright (C) 2001-2014 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/>. */
++
++#ifndef _NETBSD_PROTOS_H_
++#define _NETBSD_PROTOS_H_
++
++double __c99_cabs (double complex);
++float __c99_cabsf (float complex);
++long double __c99_cabsl (long double complex);
++
++void netbsd_patch_builtins (void);
++
++#endif /* _NETBSD_PROTOS_H_ */
diff --git a/lang/gcc5/patches/patch-gcc_config_netbsd-stdint.h b/lang/gcc5/patches/patch-gcc_config_netbsd-stdint.h
new file mode 100644
index 00000000000..0a52c6d55db
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_config_netbsd-stdint.h
@@ -0,0 +1,63 @@
+$NetBSD: patch-gcc_config_netbsd-stdint.h,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+Copy gcc/config/freebsd-stdint.h to gcc/config/netbsd-stdint.h.
+
+--- gcc/config/netbsd-stdint.h.orig 2012-04-02 09:19:19.577200540 +0000
++++ gcc/config/netbsd-stdint.h
+@@ -0,0 +1,56 @@
++/* Definitions for <stdint.h> types for NetBSD systems.
++ Copyright (C) 2009 Free Software Foundation, Inc.
++ Contributed by Gerald Pfeifer <gerald@pfeifer.com>.
++
++This file is part of GCC.
++
++GCC is free software; you can redistribute it and/or modify
++it under the terms of the GNU General Public License as published by
++the Free Software Foundation; either version 3, or (at your option)
++any later version.
++
++GCC is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++Under Section 7 of GPL version 3, you are granted additional
++permissions described in the GCC Runtime Library Exception, version
++3.1, as published by the Free Software Foundation.
++
++You should have received a copy of the GNU General Public License and
++a copy of the GCC Runtime Library Exception along with this program;
++see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
++<http://www.gnu.org/licenses/>. */
++
++#define SIG_ATOMIC_TYPE "int"
++
++#define INT8_TYPE "signed char"
++#define INT16_TYPE "short int"
++#define INT32_TYPE "int"
++#define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
++#define UINT8_TYPE "unsigned char"
++#define UINT16_TYPE "short unsigned int"
++#define UINT32_TYPE "unsigned int"
++#define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
++
++#define INT_LEAST8_TYPE "signed char"
++#define INT_LEAST16_TYPE "short int"
++#define INT_LEAST32_TYPE "int"
++#define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
++#define UINT_LEAST8_TYPE "unsigned char"
++#define UINT_LEAST16_TYPE "short unsigned int"
++#define UINT_LEAST32_TYPE "unsigned int"
++#define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
++
++#define INT_FAST8_TYPE "int"
++#define INT_FAST16_TYPE "int"
++#define INT_FAST32_TYPE "int"
++#define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
++#define UINT_FAST8_TYPE "unsigned int"
++#define UINT_FAST16_TYPE "unsigned int"
++#define UINT_FAST32_TYPE "unsigned int"
++#define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
++
++#define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
++#define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
diff --git a/lang/gcc5/patches/patch-gcc_config_netbsd.c b/lang/gcc5/patches/patch-gcc_config_netbsd.c
new file mode 100644
index 00000000000..cf01a51b5f0
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_config_netbsd.c
@@ -0,0 +1,127 @@
+$NetBSD: patch-gcc_config_netbsd.c,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- /dev/null 2015-01-20 20:33:39.000000000 +0000
++++ gcc/config/netbsd.c
+@@ -0,0 +1,122 @@
++/* Functions for generic NetBSD as target machine for GNU C compiler.
++ Copyright (C) 1989-2014 Free Software Foundation, Inc.
++ Contributed by Apple Computer 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 "tm.h"
++#include "rtl.h"
++#include "regs.h"
++#include "hard-reg-set.h"
++#include "insn-config.h"
++#include "conditions.h"
++#include "insn-flags.h"
++#include "output.h"
++#include "insn-attr.h"
++#include "flags.h"
++#include "hash-set.h"
++#include "machmode.h"
++#include "vec.h"
++#include "double-int.h"
++#include "input.h"
++#include "alias.h"
++#include "symtab.h"
++#include "wide-int.h"
++#include "inchash.h"
++#include "tree.h"
++#include "fold-const.h"
++#include "stringpool.h"
++#include "varasm.h"
++#include "stor-layout.h"
++#include "hashtab.h"
++#include "function.h"
++#include "statistics.h"
++#include "real.h"
++#include "fixed-value.h"
++#include "expmed.h"
++#include "dojump.h"
++#include "explow.h"
++#include "calls.h"
++#include "emit-rtl.h"
++#include "stmt.h"
++#include "expr.h"
++#include "reload.h"
++#include "ggc.h"
++#include "langhooks.h"
++#include "target.h"
++#include "tm_p.h"
++#include "diagnostic-core.h"
++#include "toplev.h"
++#include "dominance.h"
++#include "cfg.h"
++#include "cfgrtl.h"
++#include "cfganal.h"
++#include "lcm.h"
++#include "cfgbuild.h"
++#include "cfgcleanup.h"
++#include "predict.h"
++#include "basic-block.h"
++#include "df.h"
++#include "debug.h"
++#include "obstack.h"
++#include "hash-table.h"
++#include "tree-ssa-alias.h"
++#include "internal-fn.h"
++#include "gimple-fold.h"
++#include "tree-eh.h"
++#include "gimple-expr.h"
++#include "is-a.h"
++#include "gimple.h"
++#include "gimplify.h"
++#include "hash-map.h"
++#include "plugin-api.h"
++#include "ipa-ref.h"
++#include "cgraph.h"
++#include "lto-streamer.h"
++#include "lto-section-names.h"
++
++static void
++netbsd_patch_builtin (enum built_in_function fncode)
++{
++ tree fn = builtin_decl_explicit (fncode);
++ tree sym;
++ char *newname;
++
++ if (!fn)
++ return;
++
++ sym = DECL_ASSEMBLER_NAME (fn);
++ newname = ACONCAT (("__c99_", IDENTIFIER_POINTER (sym), NULL));
++
++ set_user_assembler_name (fn, newname);
++
++ fn = builtin_decl_implicit (fncode);
++ if (fn)
++ set_user_assembler_name (fn, newname);
++}
++
++void
++netbsd_patch_builtins (void)
++{
++ netbsd_patch_builtin (BUILT_IN_CABSF);
++ netbsd_patch_builtin (BUILT_IN_CABS);
++ netbsd_patch_builtin (BUILT_IN_CABSL);
++}
diff --git a/lang/gcc5/patches/patch-gcc_config_netbsd.h b/lang/gcc5/patches/patch-gcc_config_netbsd.h
new file mode 100644
index 00000000000..995fb188c52
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_config_netbsd.h
@@ -0,0 +1,24 @@
+$NetBSD: patch-gcc_config_netbsd.h,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- gcc/config/netbsd.h.orig 2014-01-02 22:23:26.000000000 +0000
++++ gcc/config/netbsd.h
+@@ -17,6 +17,9 @@ You should have received a copy of the G
+ along with GCC; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
++
++#include "netbsd-protos.h"
++
+ /* TARGET_OS_CPP_BUILTINS() common to all NetBSD targets. */
+ #define NETBSD_OS_CPP_BUILTINS_COMMON() \
+ do \
+@@ -175,3 +178,9 @@ along with GCC; see the file COPYING3.
+
+ #undef WINT_TYPE
+ #define WINT_TYPE "int"
++
++#undef SUBTARGET_INIT_BUILTINS
++#define SUBTARGET_INIT_BUILTINS \
++do { \
++ netbsd_patch_builtins (); \
++} while(0)
diff --git a/lang/gcc5/patches/patch-gcc_config_t-netbsd b/lang/gcc5/patches/patch-gcc_config_t-netbsd
new file mode 100644
index 00000000000..ad7927a7839
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_config_t-netbsd
@@ -0,0 +1,28 @@
+$NetBSD: patch-gcc_config_t-netbsd,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- /dev/null 2014-12-16 20:23:05.000000000 +0000
++++ gcc/config/t-netbsd
+@@ -0,0 +1,23 @@
++# Copyright (C) 2002-2014 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/>.
++
++
++netbsd.o: $(srcdir)/config/netbsd.c
++ $(COMPILE) $<
++ $(POSTCOMPILE)
++
diff --git a/lang/gcc5/patches/patch-gcc_config_x-netbsd b/lang/gcc5/patches/patch-gcc_config_x-netbsd
new file mode 100644
index 00000000000..6751a7806d9
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_config_x-netbsd
@@ -0,0 +1,12 @@
+$NetBSD: patch-gcc_config_x-netbsd,v 1.1 2015/07/16 12:03:36 ryoon 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/lang/gcc5/patches/patch-gcc_configure b/lang/gcc5/patches/patch-gcc_configure
new file mode 100644
index 00000000000..2af6aa575bf
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_configure
@@ -0,0 +1,18 @@
+$NetBSD: patch-gcc_configure,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- gcc/configure.orig 2014-05-21 11:08:58.000000000 +0000
++++ gcc/configure
+@@ -27332,6 +27332,13 @@ case "$target" in
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-*-netbsd* | *-*-openbsd*)
++ if grep dl_iterate_phdr $target_header_dir/sys/link_elf.h > /dev/null 2>&1; then
++ gcc_cv_target_dl_iterate_phdr=yes
++ else
++ gcc_cv_target_dl_iterate_phdr=no
++ fi
++ ;;
+ esac
+
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
diff --git a/lang/gcc5/patches/patch-gcc_ggc-common.c b/lang/gcc5/patches/patch-gcc_ggc-common.c
new file mode 100644
index 00000000000..793b2bc8cde
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_ggc-common.c
@@ -0,0 +1,71 @@
+$NetBSD: patch-gcc_ggc-common.c,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- gcc/ggc-common.c.orig 2014-12-10 03:45:40.000000000 +0000
++++ gcc/ggc-common.c
+@@ -603,6 +603,8 @@ gt_pch_restore (FILE *f)
+ 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
+@@ -616,32 +618,50 @@ gt_pch_restore (FILE *f)
+ /* 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 (input_location, "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 (input_location, "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 (input_location, "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 (input_location, "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 (input_location, "can%'t read PCH file: %m");
++ }
+ }
+- else if (fseek (f, mmi.offset + mmi.size, SEEK_SET) != 0)
+- fatal_error (input_location, "can%'t read PCH file: %m");
++ else if (fseek (f, mmi.offset + mmi.size, SEEK_SET) != 0) {
++ line_table = old_line_table;
++ input_location = old_input_loc;
++ fatal_error (input_location, "can%'t read PCH file: %m");
++ }
+
+ ggc_pch_read (f, mmi.preferred_base);
+
diff --git a/lang/gcc5/patches/patch-gcc_lto_lto.c b/lang/gcc5/patches/patch-gcc_lto_lto.c
new file mode 100644
index 00000000000..74238e82a23
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_lto_lto.c
@@ -0,0 +1,19 @@
+$NetBSD: patch-gcc_lto_lto.c,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- gcc/lto/lto.c.orig 2015-01-30 16:15:00.000000000 +0000
++++ gcc/lto/lto.c
+@@ -2495,7 +2495,13 @@ wait_for_child ()
+ #ifndef WCONTINUED
+ #define WCONTINUED 0
+ #endif
+- int w = waitpid (0, &status, WUNTRACED | WCONTINUED);
++
++#if defined(__NetBSD__)
++ int w = waitpid(0, &status, WUNTRACED | WALLSIG);
++#else
++ int w = waitpid(0, &status, WUNTRACED | WCONTINUED);
++#endif
++
+ if (w == -1)
+ fatal_error (input_location, "waitpid failed");
+
diff --git a/lang/gcc5/patches/patch-gcc_system.h b/lang/gcc5/patches/patch-gcc_system.h
new file mode 100644
index 00000000000..ba77cf2fa31
--- /dev/null
+++ b/lang/gcc5/patches/patch-gcc_system.h
@@ -0,0 +1,27 @@
+$NetBSD: patch-gcc_system.h,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- gcc/system.h.orig 2013-04-29 18:37:29.000000000 +0000
++++ gcc/system.h
+@@ -72,18 +72,22 @@ along with GCC; see the file COPYING3.
+
+ #if defined HAVE_DECL_PUTC_UNLOCKED && HAVE_DECL_PUTC_UNLOCKED
+
++# if !defined(__NetBSD__)
+ # ifdef HAVE_PUTC_UNLOCKED
+ # undef putc
+ # define putc(C, Stream) putc_unlocked (C, Stream)
+ # endif
++# endif
+ # ifdef HAVE_PUTCHAR_UNLOCKED
+ # undef putchar
+ # define putchar(C) putchar_unlocked (C)
+ # endif
++# if !defined(__NetBSD__)
+ # ifdef HAVE_GETC_UNLOCKED
+ # undef getc
+ # define getc(Stream) getc_unlocked (Stream)
+ # endif
++# endif
+ # ifdef HAVE_GETCHAR_UNLOCKED
+ # undef getchar
+ # define getchar() getchar_unlocked ()
diff --git a/lang/gcc5/patches/patch-libcilkrts_configure b/lang/gcc5/patches/patch-libcilkrts_configure
new file mode 100644
index 00000000000..7ab3c7244c2
--- /dev/null
+++ b/lang/gcc5/patches/patch-libcilkrts_configure
@@ -0,0 +1,13 @@
+$NetBSD: patch-libcilkrts_configure,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libcilkrts/configure.orig 2014-08-12 11:06:44.000000000 +0000
++++ libcilkrts/configure
+@@ -14519,7 +14519,7 @@ esac
+ CFLAGS="$save_CFLAGS"
+
+ if test $enable_shared = yes; then
+- link_cilkrts="-lcilkrts %{static: $LIBS}"
++ link_cilkrts="-rpath ${PREFIX}/gcc50snapshot/lib --as-needed -lgcc_s -lcilkrts %{static $LIBS}"
+ else
+ link_cilkrts="-lcilkrts $LIBS"
+ fi
diff --git a/lang/gcc5/patches/patch-libcilkrts_runtime_os-unix.c b/lang/gcc5/patches/patch-libcilkrts_runtime_os-unix.c
new file mode 100644
index 00000000000..38d57d266da
--- /dev/null
+++ b/lang/gcc5/patches/patch-libcilkrts_runtime_os-unix.c
@@ -0,0 +1,33 @@
+$NetBSD: patch-libcilkrts_runtime_os-unix.c,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libcilkrts/runtime/os-unix.c.orig 2014-05-21 11:08:58.000000000 +0000
++++ libcilkrts/runtime/os-unix.c
+@@ -56,7 +56,9 @@
+ // Uses sysconf(_SC_NPROCESSORS_ONLN) in verbose output
+ #elif defined __DragonFly__
+ // No additional include files
+-#elif defined __FreeBSD__
++#elif defined __FreeBSD__
++// No additional include files
++#elif defined __NetBSD__
+ // No additional include files
+ #elif defined __CYGWIN__
+ // Cygwin on Windows - no additional include files
+@@ -376,7 +378,7 @@ COMMON_SYSDEP int __cilkrts_hardware_cpu
+ assert((unsigned)count == count);
+
+ return count;
+-#elif defined __FreeBSD__ || defined __CYGWIN__ || defined __DragonFly__
++#elif defined __FreeBSD__ || defined __CYGWIN__ || defined __DragonFly__ || defined __NetBSD__
+ int ncores = sysconf(_SC_NPROCESSORS_ONLN);
+
+ return ncores;
+@@ -400,7 +402,7 @@ COMMON_SYSDEP void __cilkrts_sleep(void)
+
+ COMMON_SYSDEP void __cilkrts_yield(void)
+ {
+-#if __APPLE__ || __FreeBSD__ || __VXWORKS__
++#if __APPLE__ || __FreeBSD__ || __NetBSD__ || __VXWORKS__
+ // On MacOS, call sched_yield to yield quantum. I'm not sure why we
+ // don't do this on Linux also.
+ sched_yield();
diff --git a/lang/gcc5/patches/patch-libdecnumber_decNumber.c b/lang/gcc5/patches/patch-libdecnumber_decNumber.c
new file mode 100644
index 00000000000..0637f8aff0c
--- /dev/null
+++ b/lang/gcc5/patches/patch-libdecnumber_decNumber.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-libdecnumber_decNumber.c,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libdecnumber/decNumber.c.orig 2013-08-14 08:42:04.000000000 +0000
++++ libdecnumber/decNumber.c
+@@ -770,7 +770,7 @@ decNumber * decNumberAbs(decNumber *res,
+ decNumber * decNumberAdd(decNumber *res, const decNumber *lhs,
+ const decNumber *rhs, decContext *set) {
+ uInt status=0; /* accumulator */
+- decAddOp(res, lhs, rhs, set, 0, &status);
++ decAddOp(res, lhs, rhs, set, (uByte)0, &status);
+ if (status!=0) decStatus(res, status, set);
+ #if DECCHECK
+ decCheckInexact(res, set);
diff --git a/lang/gcc5/patches/patch-libffi_configure b/lang/gcc5/patches/patch-libffi_configure
new file mode 100644
index 00000000000..f61494f4b5d
--- /dev/null
+++ b/lang/gcc5/patches/patch-libffi_configure
@@ -0,0 +1,13 @@
+$NetBSD: patch-libffi_configure,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libffi/configure.orig 2013-06-01 17:03:49.000000000 +0000
++++ libffi/configure
+@@ -12689,7 +12689,7 @@ case "$target" in
+ $as_echo "#define FFI_EXEC_TRAMPOLINE_TABLE 1" >>confdefs.h
+
+ ;;
+- *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
++ *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-netbsd* | *-*-openbsd* | *-pc-solaris*)
+
+ $as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h
+
diff --git a/lang/gcc5/patches/patch-libffi_testsuite_libffi.call_float2.c b/lang/gcc5/patches/patch-libffi_testsuite_libffi.call_float2.c
new file mode 100644
index 00000000000..ca220f13c90
--- /dev/null
+++ b/lang/gcc5/patches/patch-libffi_testsuite_libffi.call_float2.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-libffi_testsuite_libffi.call_float2.c,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libffi/testsuite/libffi.call/float2.c.orig 2013-06-01 17:08:18.000000000 +0000
++++ libffi/testsuite/libffi.call/float2.c
+@@ -45,7 +45,7 @@ int main (void)
+ /* This is ifdef'd out for now. long double support under SunOS/gcc
+ is pretty much non-existent. You'll get the odd bus error in library
+ routines like printf(). */
+- printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON);
++ printf ("%Lf, %Lf, %Lf, %Lf\n", (long double)ld, (long double)ldblit(f), (long double)(ld - ldblit(f)), (long double)LDBL_EPSILON);
+ #endif
+
+ /* These are not always the same!! Check for a reasonable delta */
diff --git a/lang/gcc5/patches/patch-libgcc_crtstuff.c b/lang/gcc5/patches/patch-libgcc_crtstuff.c
new file mode 100644
index 00000000000..2fa4066af9e
--- /dev/null
+++ b/lang/gcc5/patches/patch-libgcc_crtstuff.c
@@ -0,0 +1,14 @@
+$NetBSD: patch-libgcc_crtstuff.c,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libgcc/crtstuff.c.orig 2014-09-22 00:49:01.000000000 +0000
++++ libgcc/crtstuff.c
+@@ -81,7 +81,8 @@ call_ ## FUNC (void) \
+ #endif
+
+ #if defined(TARGET_DL_ITERATE_PHDR) && \
+- (defined(__DragonFly__) || defined(__FreeBSD__))
++ (defined(__DragonFly__) || defined(__FreeBSD__) || \
++ defined(__NetBSD__) || defined(__OpenBSD__))
+ #define BSD_DL_ITERATE_PHDR_AVAILABLE
+ #endif
+
diff --git a/lang/gcc5/patches/patch-libgcc_unwind-dw2-fde-dip.c b/lang/gcc5/patches/patch-libgcc_unwind-dw2-fde-dip.c
new file mode 100644
index 00000000000..957e5e44610
--- /dev/null
+++ b/lang/gcc5/patches/patch-libgcc_unwind-dw2-fde-dip.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-libgcc_unwind-dw2-fde-dip.c,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libgcc/unwind-dw2-fde-dip.c.orig 2014-05-21 11:08:58.000000000 +0000
++++ libgcc/unwind-dw2-fde-dip.c
+@@ -65,7 +65,7 @@
+ #endif
+
+ #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+- && defined(__OpenBSD__)
++ && defined(__OpenBSD__) || defined(__NetBSD__)
+ # define ElfW(type) Elf_##type
+ # define USE_PT_GNU_EH_FRAME
+ #endif
diff --git a/lang/gcc5/patches/patch-libgfortran_configure b/lang/gcc5/patches/patch-libgfortran_configure
new file mode 100644
index 00000000000..ac53775afb3
--- /dev/null
+++ b/lang/gcc5/patches/patch-libgfortran_configure
@@ -0,0 +1,13 @@
+$NetBSD: patch-libgfortran_configure,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libgfortran/configure.orig 2014-12-07 22:38:00.000000000 +0000
++++ libgfortran/configure
+@@ -26447,7 +26447,7 @@ $as_echo "#define SUPPORTS_WEAK 1" >>con
+
+ fi
+ case "$host" in
+- *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* )
++ *-*-darwin* | *-*-hpux* | *-*-cygwin* | *-*-mingw* | *-*-netbsd* )
+
+ $as_echo "#define GTHREAD_USE_WEAK 0" >>confdefs.h
+
diff --git a/lang/gcc5/patches/patch-libgo_Makefile.in b/lang/gcc5/patches/patch-libgo_Makefile.in
new file mode 100644
index 00000000000..4b0d065a793
--- /dev/null
+++ b/lang/gcc5/patches/patch-libgo_Makefile.in
@@ -0,0 +1,17 @@
+$NetBSD: patch-libgo_Makefile.in,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+proc.c will not compile with inline-functions (implied by -O3)
+so add -fno-inline-functions to it's cflags.
+
+
+--- libgo/Makefile.in.orig 2012-08-06 14:34:27.000000000 +0000
++++ libgo/Makefile.in
+@@ -3051,7 +3051,7 @@ print.lo: runtime/print.c
+ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o print.lo `test -f 'runtime/print.c' || echo '$(srcdir)/'`runtime/print.c
+
+ proc.lo: runtime/proc.c
+-@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT proc.lo -MD -MP -MF $(DEPDIR)/proc.Tpo -c -o proc.lo `test -f 'runtime/proc.c' || echo '$(srcdir)/'`runtime/proc.c
++@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) -fno-inline-functions $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT proc.lo -MD -MP -MF $(DEPDIR)/proc.Tpo -c -o proc.lo `test -f 'runtime/proc.c' || echo '$(srcdir)/'`runtime/proc.c
+ @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/proc.Tpo $(DEPDIR)/proc.Plo
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runtime/proc.c' object='proc.lo' libtool=yes @AMDEPBACKSLASH@
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
diff --git a/lang/gcc5/patches/patch-libgo_mksysinfo.sh b/lang/gcc5/patches/patch-libgo_mksysinfo.sh
new file mode 100644
index 00000000000..23bc2760452
--- /dev/null
+++ b/lang/gcc5/patches/patch-libgo_mksysinfo.sh
@@ -0,0 +1,13 @@
+$NetBSD: patch-libgo_mksysinfo.sh,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libgo/mksysinfo.sh.orig 2014-11-12 07:15:40.000000000 +0000
++++ libgo/mksysinfo.sh
+@@ -470,7 +470,7 @@ upcase_fields () {
+ # GNU/Linux specific; it should do no harm if there is no
+ # _user_regs_struct.
+ regs=`grep '^type _user_regs_struct struct' gen-sysinfo.go || true`
+-if test "$regs" == ""; then
++if test "$regs" = ""; then
+ # s390
+ regs=`grep '^type __user_regs_struct struct' gen-sysinfo.go || true`
+ if test "$regs" != ""; then
diff --git a/lang/gcc5/patches/patch-libjava_boehm.cc b/lang/gcc5/patches/patch-libjava_boehm.cc
new file mode 100644
index 00000000000..2a4eae7d488
--- /dev/null
+++ b/lang/gcc5/patches/patch-libjava_boehm.cc
@@ -0,0 +1,22 @@
+$NetBSD: patch-libjava_boehm.cc,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libjava/boehm.cc.orig 2014-05-20 18:02:20.000000000 +0000
++++ libjava/boehm.cc
+@@ -748,7 +748,7 @@ _Jv_GCAttachThread ()
+ // only actually works if pthread_getattr_np is defined.
+ // FIXME: until gc7 it is simpler to disable this on solaris.
+ #if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(GC_SOLARIS_THREADS) \
+- && !defined(GC_WIN32_THREADS)
++ && !defined(__NetBSD__) && !defined(GC_WIN32_THREADS)
+ GC_register_my_thread ();
+ #endif
+ }
+@@ -757,7 +757,7 @@ void
+ _Jv_GCDetachThread ()
+ {
+ #if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(GC_SOLARIS_THREADS) \
+- && !defined(GC_WIN32_THREADS)
++ && !defined(__NetBSD__) && !defined(GC_WIN32_THREADS)
+ GC_unregister_my_thread ();
+ #endif
+ }
diff --git a/lang/gcc5/patches/patch-libjava_configure b/lang/gcc5/patches/patch-libjava_configure
new file mode 100644
index 00000000000..e343a117a2a
--- /dev/null
+++ b/lang/gcc5/patches/patch-libjava_configure
@@ -0,0 +1,17 @@
+$NetBSD: patch-libjava_configure,v 1.1 2015/07/16 12:03:36 ryoon 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 2012-03-22 07:37:39.000000000 +0000
++++ libjava/configure
+@@ -24692,7 +24692,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/lang/gcc5/patches/patch-libjava_contrib_rebuild-gcj-db.in b/lang/gcc5/patches/patch-libjava_contrib_rebuild-gcj-db.in
new file mode 100644
index 00000000000..90a136c442a
--- /dev/null
+++ b/lang/gcc5/patches/patch-libjava_contrib_rebuild-gcj-db.in
@@ -0,0 +1,29 @@
+$NetBSD: patch-libjava_contrib_rebuild-gcj-db.in,v 1.1 2015/07/16 12:03:36 ryoon 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/lang/gcc5/patches/patch-libsanitizer_configure.tgt b/lang/gcc5/patches/patch-libsanitizer_configure.tgt
new file mode 100644
index 00000000000..3b582f32c68
--- /dev/null
+++ b/lang/gcc5/patches/patch-libsanitizer_configure.tgt
@@ -0,0 +1,13 @@
+$NetBSD: patch-libsanitizer_configure.tgt,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libsanitizer/configure.tgt.orig 2014-09-26 13:07:42.000000000 +0000
++++ libsanitizer/configure.tgt
+@@ -37,7 +37,7 @@ case "${target}" in
+ ;;
+ aarch64*-*-linux*)
+ ;;
+- x86_64-*-darwin[1]* | i?86-*-darwin[1]*)
++ x86_64-*-darwin[1][1-9]* | i?86-*-darwin[1][1-9]*)
+ TSAN_SUPPORTED=no
+ ;;
+ *)
diff --git a/lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h b/lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h
new file mode 100644
index 00000000000..37836167b07
--- /dev/null
+++ b/lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h
@@ -0,0 +1,37 @@
+$NetBSD: patch-libstdc++-v3_config_os_bsd_netbsd_ctype__base.h,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libstdc++-v3/config/os/bsd/netbsd/ctype_base.h.orig 2013-02-03 17:54:05.000000000 +0000
++++ libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
+@@ -43,9 +43,22 @@ _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.
+- typedef unsigned char mask;
+
+-#ifndef _CTYPE_U
++#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;
+ static const mask upper = _U;
+ static const mask lower = _L;
+ static const mask alpha = _U | _L;
+@@ -58,6 +71,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+ static const mask punct = _P;
+ static const mask alnum = _U | _L | _N;
+ #else
++ typedef unsigned char mask;
+ static const mask upper = _CTYPE_U;
+ static const mask lower = _CTYPE_L;
+ static const mask alpha = _CTYPE_U | _CTYPE_L;
diff --git a/lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__configure__char.cc b/lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__configure__char.cc
new file mode 100644
index 00000000000..af4c2f4b9a9
--- /dev/null
+++ b/lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__configure__char.cc
@@ -0,0 +1,57 @@
+$NetBSD: patch-libstdc++-v3_config_os_bsd_netbsd_ctype__configure__char.cc,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc.orig 2013-02-03 17:54:05.000000000 +0000
++++ libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc
+@@ -38,11 +38,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // 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)
+@@ -69,14 +75,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ 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;
+@@ -84,14 +90,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ 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/lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__inline.h b/lang/gcc5/patches/patch-libstdc++-v3_config_os_bsd_netbsd_ctype__inline.h
new file mode 100644
index 00000000000..6f1c956d3cb
--- /dev/null
+++ b/lang/gcc5/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 2015/07/16 12:03:36 ryoon Exp $
+
+--- libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h.orig 2013-02-03 17:54:05.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/lang/gcc5/patches/patch-libstdc++-v3_libsupc++_unwind-cxx.h b/lang/gcc5/patches/patch-libstdc++-v3_libsupc++_unwind-cxx.h
new file mode 100644
index 00000000000..1eb5bbc6649
--- /dev/null
+++ b/lang/gcc5/patches/patch-libstdc++-v3_libsupc++_unwind-cxx.h
@@ -0,0 +1,12 @@
+$NetBSD: patch-libstdc++-v3_libsupc++_unwind-cxx.h,v 1.1 2015/07/16 12:03:36 ryoon Exp $
+
+--- libstdc++-v3/libsupc++/unwind-cxx.h.orig 2013-03-19 17:04:44.000000000 +0000
++++ libstdc++-v3/libsupc++/unwind-cxx.h
+@@ -38,6 +38,7 @@
+ #include <cxxabi.h>
+
+ #ifdef _GLIBCXX_HAVE_SYS_SDT_H
++#include <cstdlib>
+ #include <sys/sdt.h>
+ /* We only want to use stap probes starting with v3. Earlier versions
+ added too much startup cost. */