Please test the following diff I can make a more minimal change for pkgsrc copying netbsd and override STARTFILE_SPEC but I think this is nicer.
? work Index: distinfo =================================================================== RCS file: /cvsroot/pkgsrc/lang/gcc7/distinfo,v retrieving revision 1.6 diff -u -r1.6 distinfo --- distinfo 5 Jul 2017 10:17:01 -0000 1.6 +++ distinfo 23 Jul 2017 18:42:12 -0000 @@ -10,7 +10,9 @@ Size (isl-0.16.1.tar.bz2) = 1626446 bytes SHA1 (patch-contrib_download__prerequisites) = 86c6c16e0e3e3a0bcb38579a8b4004f603fac1ca SHA1 (patch-gcc_Makefile.in) = c0f97c75ba1d37eae894141edd58bb36b734f651 -SHA1 (patch-gcc_config.gcc) = fea8288c22bb2c4dd44a5e77c8f92dee8f8f6b18 +SHA1 (patch-gcc_config.gcc) = f03da5fd74eac67402df6a2a71236df90737137f +SHA1 (patch-gcc_config_alpha_elf.h) = 2897337860aae09a270b38b8e296e1494b3c8629 +SHA1 (patch-gcc_config_alpha_linux.h) = bb2247b0201363dedf8d13b329fb7e2dd14053ce SHA1 (patch-gcc_config_arm_arm.h) = 92c8bff1063e153fec4454e6dea5334a42b0dad6 SHA1 (patch-gcc_config_netbsd-protos.h) = 6d28864b4ccc8c1a63fe28e43601b84b63a00633 SHA1 (patch-gcc_config_netbsd.c) = 85f786bce881ef2fc348f98ef81fdbc001076183 Index: patches/patch-gcc_config.gcc =================================================================== RCS file: /cvsroot/pkgsrc/lang/gcc7/patches/patch-gcc_config.gcc,v retrieving revision 1.1 diff -u -r1.1 patch-gcc_config.gcc --- patches/patch-gcc_config.gcc 3 May 2017 00:21:03 -0000 1.1 +++ patches/patch-gcc_config.gcc 23 Jul 2017 18:42:13 -0000 @@ -1,8 +1,8 @@ $NetBSD: patch-gcc_config.gcc,v 1.1 2017/05/03 00:21:03 maya Exp $ ---- gcc/config.gcc.orig 2016-12-10 21:07:10.000000000 +0000 +--- gcc/config.gcc.orig 2017-03-24 13:59:51.000000000 +0000 +++ gcc/config.gcc -@@ -765,10 +765,15 @@ case ${target} in +@@ -775,10 +775,15 @@ case ${target} in target_has_targetcm=yes ;; *-*-netbsd*) @@ -19,14 +19,35 @@ # NetBSD 2.0 and later get POSIX threads enabled by default. # Allow them to be explicitly enabled on any other version. -@@ -1460,10 +1465,12 @@ x86_64-*-freebsd*) +@@ -804,6 +809,7 @@ case ${target} in + default_use_cxa_atexit=yes + ;; + esac ++ nbsd_tm_file="${nbsd_tm_file} netbsd.h netbsd-stdint.h netbsd-elf.h" + ;; + *-*-openbsd*) + tmake_file="t-openbsd" +@@ -999,7 +1005,7 @@ alpha*-*-freebsd*) + extra_options="${extra_options} alpha/elf.opt" + ;; + alpha*-*-netbsd*) +- tm_file="elfos.h ${tm_file} netbsd.h alpha/elf.h netbsd-elf.h alpha/netbsd.h" ++ tm_file="elfos.h ${tm_file} ${nbsd_tm_file} alpha/elf.h alpha/netbsd.h" + tmake_file="${tmake_file} alpha/t-alpha" + extra_options="${extra_options} netbsd.opt netbsd-elf.opt \ + alpha/elf.opt" +@@ -1472,12 +1478,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-stdint.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-stdint.h netbsd-elf.h i386/netbsd-elf.h" ++ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${nbsd_tm_file} i386/netbsd-elf.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-stdint.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-stdint.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 ${nbsd_tm_file} i386/x86-64.h i386/netbsd64.h" extra_options="${extra_options} netbsd.opt netbsd-elf.opt" + tmake_file="${tmake_file} i386/t-crtstuff" ;; Index: patches/patch-gcc_config_alpha_elf.h =================================================================== RCS file: patches/patch-gcc_config_alpha_elf.h diff -N patches/patch-gcc_config_alpha_elf.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-gcc_config_alpha_elf.h 23 Jul 2017 18:42:13 -0000 @@ -0,0 +1,39 @@ +$NetBSD$ + +move linux-specific spec definitions to the linux file + +--- gcc/config/alpha/elf.h.orig 2017-01-01 12:07:43.000000000 +0000 ++++ gcc/config/alpha/elf.h +@@ -100,32 +100,6 @@ do { \ + ASM_OUTPUT_DEF (FILE, alias, name); \ + } while (0) + +-/* Provide a STARTFILE_SPEC appropriate for ELF. Here we add the +- (even more) magical crtbegin.o file which provides part of the +- support for getting C++ file-scope static object constructed +- before entering `main'. */ +- +-#undef STARTFILE_SPEC +-#ifdef HAVE_LD_PIE +-#define STARTFILE_SPEC \ +- "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\ +- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" +-#else +-#define STARTFILE_SPEC \ +- "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\ +- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" +-#endif +- +-/* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the +- magical crtend.o file which provides part of the support for +- getting C++ file-scope static object constructed before entering +- `main', followed by a normal ELF "finalizer" file, `crtn.o'. */ +- +-#undef ENDFILE_SPEC +-#define ENDFILE_SPEC \ +- "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ +- %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" +- + /* This variable should be set to 'true' if the target ABI requires + unwinding tables even when exceptions are not used. */ + #define TARGET_UNWIND_TABLES_DEFAULT true Index: patches/patch-gcc_config_alpha_linux.h =================================================================== RCS file: patches/patch-gcc_config_alpha_linux.h diff -N patches/patch-gcc_config_alpha_linux.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-gcc_config_alpha_linux.h 23 Jul 2017 18:42:13 -0000 @@ -0,0 +1,34 @@ +$NetBSD$ + +move linux-specific spec definitions to the linux file + +--- gcc/config/alpha/linux.h.orig 2017-01-01 12:07:43.000000000 +0000 ++++ gcc/config/alpha/linux.h +@@ -78,6 +78,27 @@ along with GCC; see the file COPYING3. + + #define TARGET_POSIX_IO + ++#undef STARTFILE_SPEC ++#ifdef HAVE_LD_PIE ++#define STARTFILE_SPEC \ ++ "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\ ++ crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" ++#else ++#define STARTFILE_SPEC \ ++ "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\ ++ crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" ++#endif ++ ++/* Provide a ENDFILE_SPEC appropriate for ELF. Here we tack on the ++ magical crtend.o file which provides part of the support for ++ getting C++ file-scope static object constructed before entering ++ `main', followed by a normal ELF "finalizer" file, `crtn.o'. */ ++ ++#undef ENDFILE_SPEC ++#define ENDFILE_SPEC \ ++ "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ ++ %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" ++ + #define LINK_GCC_C_SEQUENCE_SPEC \ + "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}" +