Merge "Add support for fuchsia native tools."
diff --git a/patches/gcc-patch.txt b/patches/gcc-patch.txt
index bd5c275..1cf8639 100644
--- a/patches/gcc-patch.txt
+++ b/patches/gcc-patch.txt
@@ -60,7 +60,6 @@
  # 
  # MULTILIB_OPTIONS    += fno-leading-underscore/fleading-underscore
  # MULTILIB_DIRNAMES   += elf under
-reverted:
 --- gcc-4.8.2.orig/gcc/config/i386/t-x86_64-elf	1970-01-01 01:00:00.000000000 +0100
 +++ gcc-4.8.2/gcc/config/i386/t-x86_64-elf	2013-12-29 12:47:35.000000000 +0000
 @@ -0,0 +1,8 @@
@@ -73,19 +72,6 @@
 +MULTILIB_OPTIONS  += m32
 +MULTILIB_DIRNAMES += 32
 \ No newline at end of file
-reverted:
---- gcc-4.8.2.orig/gcc/config.gcc	2013-10-03 01:47:24.000000000 +0100
-+++ gcc-4.8.2/gcc/config.gcc	2013-12-29 12:06:18.000000000 +0000
-@@ -1213,6 +1213,7 @@
- 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h"
- 	;;
- x86_64-*-elf*)
-+	tmake_file="${tmake_file} i386/t-x86_64-elf"
- 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h"
- 	;;
- i[34567]86-*-rdos*)
-
-gcc/
 2016-09-27  Roland McGrath  <roland@hack.frob.com>
 
 	PR other/77609
@@ -143,12 +129,138 @@
   	-none)
   		;;
   	*)
-diff -dcprN gcc-6.2.0/gcc/config/fuchsia.h gcc-6.2.0-fuchsia/gcc/config/fuchsia.h
-*** gcc-6.2.0/gcc/config/fuchsia.h	1969-12-31 16:00:00.000000000 -0800
---- gcc-6.2.0-fuchsia/gcc/config/fuchsia.h	2016-10-31 13:08:34.707128162 -0700
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/collect2.c gcc-6.2.0/gcc/collect2.c
+*** gcc-6.2.0-fsf/gcc/collect2.c	2016-11-23 09:11:05.324188090 -0800
+--- gcc-6.2.0/gcc/collect2.c	2016-11-30 13:50:14.585469484 -0800
+*************** main (int argc, char **argv)
+*** 1067,1074 ****
+--- 1067,1076 ----
+    if (signal (SIGQUIT, SIG_IGN) != SIG_IGN)
+      signal (SIGQUIT, handler);
+  #endif
++ #ifdef SIGINT
+    if (signal (SIGINT, SIG_IGN) != SIG_IGN)
+      signal (SIGINT, handler);
++ #endif
+  #ifdef SIGALRM
+    if (signal (SIGALRM, SIG_IGN) != SIG_IGN)
+      signal (SIGALRM, handler);
+*************** main (int argc, char **argv)
+*** 1077,1084 ****
+--- 1079,1088 ----
+    if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
+      signal (SIGHUP, handler);
+  #endif
++ #ifdef SIGSEGV
+    if (signal (SIGSEGV, SIG_IGN) != SIG_IGN)
+      signal (SIGSEGV, handler);
++ #endif
+  #ifdef SIGBUS
+    if (signal (SIGBUS, SIG_IGN) != SIG_IGN)
+      signal (SIGBUS, handler);
+*************** static void
+*** 2307,2313 ****
+--- 2311,2319 ----
+  scan_prog_file (const char *prog_name, scanpass which_pass,
+  		scanfilter filter)
+  {
++ #ifdef SIGINT
+    void (*int_handler) (int);
++ #endif
+  #ifdef SIGQUIT
+    void (*quit_handler) (int);
+  #endif
+*************** scan_prog_file (const char *prog_name, s
+*** 2373,2379 ****
+--- 2379,2387 ----
+  	fatal_error (input_location, errmsg);
+      }
+  
++ #ifdef SIGINT
+    int_handler  = (void (*) (int)) signal (SIGINT,  SIG_IGN);
++ #endif
+  #ifdef SIGQUIT
+    quit_handler = (void (*) (int)) signal (SIGQUIT, SIG_IGN);
+  #endif
+*************** scan_prog_file (const char *prog_name, s
+*** 2499,2505 ****
+--- 2507,2515 ----
+  
+    do_wait (nm_file_name, pex);
+  
++ #ifdef SIGINT
+    signal (SIGINT,  int_handler);
++ #endif
+  #ifdef SIGQUIT
+    signal (SIGQUIT, quit_handler);
+  #endif
+*************** scan_libraries (const char *prog_name)
+*** 2571,2577 ****
+--- 2581,2589 ----
+  	fatal_error (input_location, errmsg);
+      }
+  
++ #ifdef SIGINT
+    int_handler  = (void (*) (int)) signal (SIGINT,  SIG_IGN);
++ #endif
+  #ifdef SIGQUIT
+    quit_handler = (void (*) (int)) signal (SIGQUIT, SIG_IGN);
+  #endif
+*************** scan_libraries (const char *prog_name)
+*** 2619,2625 ****
+--- 2631,2639 ----
+  
+    do_wait (ldd_file_name, pex);
+  
++ #ifdef SIGINT
+    signal (SIGINT,  int_handler);
++ #endif
+  #ifdef SIGQUIT
+    signal (SIGQUIT, quit_handler);
+  #endif
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/config/arm/fuchsia-elf.h gcc-6.2.0/gcc/config/arm/fuchsia-elf.h
+*** gcc-6.2.0-fsf/gcc/config/arm/fuchsia-elf.h	1969-12-31 16:00:00.000000000 -0800
+--- gcc-6.2.0/gcc/config/arm/fuchsia-elf.h	2016-11-21 19:10:12.382326720 -0800
 ***************
 *** 0 ****
---- 1,49 ----
+--- 1,31 ----
++ /* Configuration file for ARM Fuchsia ELF targets.
++    Copyright (C) 2016 Free Software Foundation, Inc.
++    Contributed by Google.
++ 
++    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/>.  */
++ 
++ /* Use the BPABI builtins and the generic OS builtins.  */
++ #undef  TARGET_SUB_OS_CPP_BUILTINS
++ #define TARGET_SUB_OS_CPP_BUILTINS() 		\
++   TARGET_BPABI_CPP_BUILTINS()
++ 
++ /* Use the AAPCS ABI by default.  */
++ #undef ARM_DEFAULT_ABI
++ #define ARM_DEFAULT_ABI ARM_ABI_AAPCS
++ 
++ #define ARM_TARGET2_DWARF_FORMAT (DW_EH_PE_pcrel | DW_EH_PE_indirect)
++ 
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/config/fuchsia.h gcc-6.2.0/gcc/config/fuchsia.h
+*** gcc-6.2.0-fsf/gcc/config/fuchsia.h	1969-12-31 16:00:00.000000000 -0800
+--- gcc-6.2.0/gcc/config/fuchsia.h	2016-12-09 16:41:30.153720864 -0800
+***************
+*** 0 ****
+--- 1,99 ----
 + /* Base configuration file for all Fuchsia targets.
 +    Copyright (C) 2016 Free Software Foundation, Inc.
 + 
@@ -174,17 +286,21 @@
 + #define USING_CONFIG_FUCHSIA 1
 + 
 + #undef  STARTFILE_SPEC
-+ #define STARTFILE_SPEC "%{!shared: crt1.o%s}"
++ #define STARTFILE_SPEC "%{!shared: crt1%O%s} crtbegin%O%s"
 + 
 + #undef  ENDFILE_SPEC
-+ #define ENDFILE_SPEC ""
++ #define ENDFILE_SPEC "crtend%O%s"
 + 
++ /* When neither pic nor pie has been specified, use PIE by default.  */
 + #undef  CC1_SPEC
-+ #define CC1_SPEC "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}"
++ #define CC1_SPEC "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC:" \
++                    "%{!fno-pie:%{!fno-PIE:%{!fpie:%{!fPIE: -fPIE}}}}}}}}"
 + 
 + #undef  LIB_SPEC
-+ #define LIB_SPEC "-lmxio -lmagenta -lc" \
-+ 		 "%{!static: -lgcc_s}"
++ #define LIB_SPEC "--start-group" \
++ 		 " -lmxio -lmagenta -lc -llaunchpad" \
++ 		 "%{!static: -lgcc_s}" \
++ 		 " --end-group"
 + 
 + #undef  LINK_SPEC
 + #define LINK_SPEC "-z max-page-size=4096" \
@@ -194,16 +310,143 @@
 + 		  " -z text" \
 + 		  "%{!hash-style: --hash-style=gnu}" \
 + 		  "%{!no-eh-frame-hdr: --eh-frame-hdr}" \
-+                   "%{!no-build-id: --build-id}" \
++ 		  "%{!no-build-id: --build-id}" \
 + 		  "%{shared: -shared}" \
 + 		  "%{!shared:%{!static:%{!dynamic-linker: -dynamic-linker=ld.so.1}}}"
 + 
-diff -dcprN gcc-6.2.0/gcc/config.gcc gcc-6.2.0-fuchsia/gcc/config.gcc
-*** gcc-6.2.0/gcc/config.gcc	2016-10-24 16:39:48.403676689 -0700
---- gcc-6.2.0-fuchsia/gcc/config.gcc	2016-10-31 15:26:25.548944871 -0700
++ /* We are using MUSL as our libc.  */
++ #undef  OPTION_MUSL
++ #define OPTION_MUSL 1
++ 
++ #ifndef TARGET_SUB_OS_CPP_BUILTINS
++ #define TARGET_SUB_OS_CPP_BUILTINS()
++ #endif
++ 
++ #undef  TARGET_OS_CPP_BUILTINS
++ #define TARGET_OS_CPP_BUILTINS()		\
++   do						\
++     {						\
++       builtin_define ("__fuchsia__");		\
++       TARGET_SUB_OS_CPP_BUILTINS();		\
++     }						\
++   while (false)
++ 
++ 
++ /* In fact we have ftw.h, but the function itself is unimplemented.  */
++ #undef HAVE_FTW_H
++ 
++ /* Functions that are implemented as stubs in libc.  */
++ #undef HAVE_GETRLIMIT
++ #undef HAVE_GETRUSAGE
++ #undef HAVE_REALPATH
++ #undef HAVE_SETRLIMIT
++ #undef HAVE_TIMES
++ 
++ /* No ioctl() support.  */
++ #undef TIOCGWINSZ
++ 
++ /* No signal() support.  */
++ #undef SIGABRT
++ #undef SIGALRM
++ #undef SIGBUS
++ #undef SIGCHLD
++ #undef SIGFPE
++ #undef SIGHUP
++ #undef SIGILL
++ #undef SIGINT
++ #undef SIGIOT
++ #undef SIGPIPE
++ #undef SIGQUIT
++ #undef SIGSEGV
++ #undef SIGTERM
++ 
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/config.gcc gcc-6.2.0/gcc/config.gcc
+*** gcc-6.2.0-fsf/gcc/config.gcc	2016-11-23 09:11:05.804186203 -0800
+--- gcc-6.2.0/gcc/config.gcc	2016-11-21 16:05:55.706051533 -0800
+*************** case ${target} in
+*** 710,715 ****
+--- 710,718 ----
+    esac
+    use_gcc_stdint=wrap
+    ;;
++ *-*-fuchsia*)
++   native_system_header_dir=/include
++   ;;
+  *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu)
+    extra_options="$extra_options gnu-user.opt"
+    gas=yes
+*************** case ${target} in
+*** 907,913 ****
+  esac
+  
+  case ${target} in
+! aarch64*-*-elf | aarch64*-*-rtems*)
+  	tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
+  	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-elf-raw.h"
+  	tmake_file="${tmake_file} aarch64/t-aarch64"
+--- 910,916 ----
+  esac
+  
+  case ${target} in
+! aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
+  	tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
+  	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-elf-raw.h"
+  	tmake_file="${tmake_file} aarch64/t-aarch64"
+*************** aarch64*-*-elf | aarch64*-*-rtems*)
+*** 915,920 ****
+--- 918,926 ----
+  	aarch64-*-elf*)
+  		use_gcc_stdint=wrap
+  		;;
++         aarch64-*-fuchsia*)
++                 tm_file="${tm_file} fuchsia.h"
++                 ;;
+  	aarch64-*-rtems*)
+  	  	tm_file="${tm_file} rtems.h aarch64/rtems.h"
+  		;;
+*************** arm*-*-uclinux*eabi*)		# ARM ucLinux
+*** 1097,1103 ****
+  	# The EABI requires the use of __cxa_atexit.
+  	default_use_cxa_atexit=yes
+  	;;
+! arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
+  	case ${target} in
+  	arm*eb-*-eabi*)
+  	  tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
+--- 1103,1109 ----
+  	# The EABI requires the use of __cxa_atexit.
+  	default_use_cxa_atexit=yes
+  	;;
+! arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems* | arm*-*-fuchsia*)
+  	case ${target} in
+  	arm*eb-*-eabi*)
+  	  tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
+*************** arm*-*-eabi* | arm*-*-symbianelf* | arm*
+*** 1111,1116 ****
+--- 1117,1126 ----
+  	  tmake_file="${tmake_file} arm/t-bpabi"
+  	  use_gcc_stdint=wrap
+  	  ;;
++ 	arm*-*-fuchsia*)
++ 	  tm_file="${tm_file} fuchsia.h arm/fuchsia-elf.h glibc-stdint.h"
++ 	  tmake_file="${tmake_file} arm/t-bpabi"
++ 	  ;;
+  	arm*-*-rtems*)
+  	  tm_file="${tm_file} rtems.h arm/rtems.h newlib-stdint.h"
+  	  tmake_file="${tmake_file} arm/t-bpabi arm/t-rtems"
+*************** i[34567]86-*-elf*)
+*** 1418,1423 ****
+--- 1428,1434 ----
+  	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h"
+  	;;
+  x86_64-*-elf*)
++ 	tmake_file="${tmake_file} i386/t-x86_64-elf"
+  	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h"
+  	;;
+  x86_64-*-rtems*)
 *************** i[34567]86-*-interix[3-9]*)
-*** 1792,1797 ****
---- 1792,1801 ----
+*** 1791,1796 ****
+--- 1802,1811 ----
   		tm_file="${tm_file} dbxcoff.h"
   	fi
   	;;
@@ -214,9 +457,394 @@
   ia64*-*-elf*)
   	tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h ia64/sysv4.h ia64/elf.h"
   	tmake_file="ia64/t-ia64"
-diff -dcprN gcc-6.2.0/libgcc/config/t-slibgcc-fuchsia gcc-6.2.0-fuchsia/libgcc/config/t-slibgcc-fuchsia
-*** gcc-6.2.0/libgcc/config/t-slibgcc-fuchsia	1969-12-31 16:00:00.000000000 -0800
---- gcc-6.2.0-fuchsia/libgcc/config/t-slibgcc-fuchsia	2016-10-28 10:05:17.778985385 -0700
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/config.host gcc-6.2.0/gcc/config.host
+*** gcc-6.2.0-fsf/gcc/config.host	2016-11-23 09:10:49.908248680 -0800
+--- gcc-6.2.0/gcc/config.host	2016-11-21 18:57:29.749649894 -0800
+*************** case ${host} in
+*** 99,105 ****
+  esac
+  
+  case ${host} in
+!   aarch64*-*-linux*)
+      case ${target} in
+        aarch64*-*-*)
+  	host_extra_gcc_objs="driver-aarch64.o"
+--- 99,105 ----
+  esac
+  
+  case ${host} in
+!   aarch64*-*-linux* | aarch64*-*-fuchsia*)
+      case ${target} in
+        aarch64*-*-*)
+  	host_extra_gcc_objs="driver-aarch64.o"
+*************** case ${host} in
+*** 107,113 ****
+  	;;
+      esac
+      ;;
+!   arm*-*-freebsd* | arm*-*-linux*)
+      case ${target} in
+        arm*-*-*)
+  	host_extra_gcc_objs="driver-arm.o"
+--- 107,113 ----
+  	;;
+      esac
+      ;;
+!   arm*-*-freebsd* | arm*-*-linux* | arm*-*-fuchsia*)
+      case ${target} in
+        arm*-*-*)
+  	host_extra_gcc_objs="driver-arm.o"
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/configure gcc-6.2.0/gcc/configure
+*** gcc-6.2.0-fsf/gcc/configure	2016-11-23 09:11:05.200188577 -0800
+--- gcc-6.2.0/gcc/configure	2016-11-30 12:34:30.868394376 -0800
+*************** if test -z "$aix_libpath"; then aix_libp
+*** 16703,16708 ****
+--- 16703,16715 ----
+        hardcode_shlibpath_var=no
+        ;;
+  
++     fuchsia*)
++       archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
++       hardcode_libdir_flag_spec='-R$libdir'
++       hardcode_direct=yes
++       hardcode_shlibpath_var=no
++       ;;
++ 
+      hpux9*)
+        if test "$GCC" = yes; then
+  	archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+*************** freebsd* | dragonfly*)
+*** 17638,17643 ****
+--- 17645,17656 ----
+    esac
+    ;;
+  
++ fuchsia*)
++   library_names_spec='${libname}${shared_ext}'
++   need_lib_prefix=no
++   need_version=no
++   ;;
++ 
+  gnu*)
+    version_type=linux
+    need_lib_prefix=no
+*************** fi
+*** 18241,18246 ****
+--- 18254,18264 ----
+  
+      ;;
+  
++   fuchsia*)
++     lt_cv_dlopen="dlopen"
++     lt_cv_dlopen_libs=
++     ;;
++ 
+    *)
+      ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+  if test "x$ac_cv_func_shl_load" = x""yes; then :
+*************** else
+*** 18453,18459 ****
+    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<_LT_EOF
+! #line 18456 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+--- 18471,18477 ----
+    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<_LT_EOF
+! #line 18474 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+*************** else
+*** 18559,18565 ****
+    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<_LT_EOF
+! #line 18562 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+--- 18577,18583 ----
+    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+    lt_status=$lt_dlunknown
+    cat > conftest.$ac_ext <<_LT_EOF
+! #line 18580 "configure"
+  #include "confdefs.h"
+  
+  #if HAVE_DLFCN_H
+*************** freebsd* | dragonfly*)
+*** 21298,21303 ****
+--- 21316,21327 ----
+    esac
+    ;;
+  
++ fuchsia*)
++   library_names_spec='${libname}${shared_ext}'
++   need_lib_prefix=no
++   need_version=no
++   ;;
++ 
+  gnu*)
+    version_type=linux
+    need_lib_prefix=no
+*************** fi
+*** 29375,29388 ****
+  
+  
+  # Check if -fno-PIE works.
+! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-PIE option" >&5
+  $as_echo_n "checking for -fno-PIE option... " >&6; }
+  if test "${gcc_cv_c_no_fpie+set}" = set; then :
+    $as_echo_n "(cached) " >&6
+  else
+    saved_CXXFLAGS="$CXXFLAGS"
+!    CXXFLAGS="$CXXFLAGS -fno-PIE"
+!    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  /* end confdefs.h.  */
+  int main(void) {return 0;}
+  _ACEOF
+--- 29399,29417 ----
+  
+  
+  # Check if -fno-PIE works.
+! case $host_os in
+!   fuchsia*)
+!     # Fuchsia requires PIE binaries
+!     ;;
+!   *)
+!     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-PIE option" >&5
+  $as_echo_n "checking for -fno-PIE option... " >&6; }
+  if test "${gcc_cv_c_no_fpie+set}" = set; then :
+    $as_echo_n "(cached) " >&6
+  else
+    saved_CXXFLAGS="$CXXFLAGS"
+!        CXXFLAGS="$CXXFLAGS -fno-PIE"
+!        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  /* end confdefs.h.  */
+  int main(void) {return 0;}
+  _ACEOF
+*************** else
+*** 29392,29415 ****
+    gcc_cv_c_no_fpie=no
+  fi
+  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+!    CXXFLAGS="$saved_CXXFLAGS"
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_c_no_fpie" >&5
+  $as_echo "$gcc_cv_c_no_fpie" >&6; }
+! if test "$gcc_cv_c_no_fpie" = "yes"; then
+!   NO_PIE_CFLAGS="-fno-PIE"
+! fi
+  
+  
+  # Check if -no-pie works.
+! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5
+  $as_echo_n "checking for -no-pie option... " >&6; }
+  if test "${gcc_cv_no_pie+set}" = set; then :
+    $as_echo_n "(cached) " >&6
+  else
+    saved_LDFLAGS="$LDFLAGS"
+!    LDFLAGS="$LDFLAGS -no-pie"
+!    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  /* end confdefs.h.  */
+  int main(void) {return 0;}
+  _ACEOF
+--- 29421,29451 ----
+    gcc_cv_c_no_fpie=no
+  fi
+  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+!        CXXFLAGS="$saved_CXXFLAGS"
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_c_no_fpie" >&5
+  $as_echo "$gcc_cv_c_no_fpie" >&6; }
+!     if test "$gcc_cv_c_no_fpie" = "yes"; then
+!       NO_PIE_CFLAGS="-fno-PIE"
+!     fi
+!     ;;
+! esac
+  
+  
+  # Check if -no-pie works.
+! case $host_os in
+!   fuchsia*)
+!     # Fuchsia requires PIE binaries
+!     ;;
+!   *)
+!     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5
+  $as_echo_n "checking for -no-pie option... " >&6; }
+  if test "${gcc_cv_no_pie+set}" = set; then :
+    $as_echo_n "(cached) " >&6
+  else
+    saved_LDFLAGS="$LDFLAGS"
+!        LDFLAGS="$LDFLAGS -no-pie"
+!        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  /* end confdefs.h.  */
+  int main(void) {return 0;}
+  _ACEOF
+*************** else
+*** 29420,29432 ****
+  fi
+  rm -f core conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+!    LDFLAGS="$saved_LDFLAGS"
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5
+  $as_echo "$gcc_cv_no_pie" >&6; }
+! if test "$gcc_cv_no_pie" = "yes"; then
+!   NO_PIE_FLAG="-no-pie"
+! fi
+  
+  
+  # Check linker supports '-z bndplt'
+--- 29456,29470 ----
+  fi
+  rm -f core conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+!        LDFLAGS="$saved_LDFLAGS"
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5
+  $as_echo "$gcc_cv_no_pie" >&6; }
+!     if test "$gcc_cv_no_pie" = "yes"; then
+!       NO_PIE_FLAG="-no-pie"
+!     fi
+!     ;;
+! esac
+  
+  
+  # Check linker supports '-z bndplt'
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/configure.ac gcc-6.2.0/gcc/configure.ac
+*** gcc-6.2.0-fsf/gcc/configure.ac	2016-11-23 09:11:05.952185621 -0800
+--- gcc-6.2.0/gcc/configure.ac	2016-11-30 12:31:48.821079660 -0800
+*************** fi
+*** 6086,6116 ****
+  AC_SUBST([enable_default_pie])
+  
+  # Check if -fno-PIE works.
+! AC_CACHE_CHECK([for -fno-PIE option],
+!   [gcc_cv_c_no_fpie],
+!   [saved_CXXFLAGS="$CXXFLAGS"
+!    CXXFLAGS="$CXXFLAGS -fno-PIE"
+!    AC_COMPILE_IFELSE([int main(void) {return 0;}],
+!      [gcc_cv_c_no_fpie=yes],
+!      [gcc_cv_c_no_fpie=no])
+!    CXXFLAGS="$saved_CXXFLAGS"])
+! if test "$gcc_cv_c_no_fpie" = "yes"; then
+!   NO_PIE_CFLAGS="-fno-PIE"
+! fi
+  AC_SUBST([NO_PIE_CFLAGS])
+  
+  # Check if -no-pie works.
+! AC_CACHE_CHECK([for -no-pie option],
+!   [gcc_cv_no_pie],
+!   [saved_LDFLAGS="$LDFLAGS"
+!    LDFLAGS="$LDFLAGS -no-pie"
+!    AC_LINK_IFELSE([int main(void) {return 0;}],
+!      [gcc_cv_no_pie=yes],
+!      [gcc_cv_no_pie=no])
+!    LDFLAGS="$saved_LDFLAGS"])
+! if test "$gcc_cv_no_pie" = "yes"; then
+!   NO_PIE_FLAG="-no-pie"
+! fi
+  AC_SUBST([NO_PIE_FLAG])
+  
+  # Check linker supports '-z bndplt'
+--- 6086,6130 ----
+  AC_SUBST([enable_default_pie])
+  
+  # Check if -fno-PIE works.
+! case $host_os in
+!   fuchsia*)
+!     # Fuchsia requires PIE binaries
+!     ;;
+!   *)
+!     AC_CACHE_CHECK([for -fno-PIE option],
+!       [gcc_cv_c_no_fpie],
+!       [saved_CXXFLAGS="$CXXFLAGS"
+!        CXXFLAGS="$CXXFLAGS -fno-PIE"
+!        AC_COMPILE_IFELSE([int main(void) {return 0;}],
+!          [gcc_cv_c_no_fpie=yes],
+!          [gcc_cv_c_no_fpie=no])
+!        CXXFLAGS="$saved_CXXFLAGS"])
+!     if test "$gcc_cv_c_no_fpie" = "yes"; then
+!       NO_PIE_CFLAGS="-fno-PIE"
+!     fi
+!     ;;
+! esac
+  AC_SUBST([NO_PIE_CFLAGS])
+  
+  # Check if -no-pie works.
+! case $host_os in
+!   fuchsia*)
+!     # Fuchsia requires PIE binaries
+!     ;;
+!   *)
+!     AC_CACHE_CHECK([for -no-pie option],
+!       [gcc_cv_no_pie],
+!       [saved_LDFLAGS="$LDFLAGS"
+!        LDFLAGS="$LDFLAGS -no-pie"
+!        AC_LINK_IFELSE([int main(void) {return 0;}],
+!          [gcc_cv_no_pie=yes],
+!          [gcc_cv_no_pie=no])
+!        LDFLAGS="$saved_LDFLAGS"])
+!     if test "$gcc_cv_no_pie" = "yes"; then
+!       NO_PIE_FLAG="-no-pie"
+!     fi
+!     ;;
+! esac
+  AC_SUBST([NO_PIE_FLAG])
+  
+  # Check linker supports '-z bndplt'
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/gcc/gcc.c gcc-6.2.0/gcc/gcc.c
+*** gcc-6.2.0-fsf/gcc/gcc.c	2016-11-23 09:11:05.472187508 -0800
+--- gcc-6.2.0/gcc/gcc.c	2016-11-30 13:46:59.158288993 -0800
+*************** driver::global_initializations ()
+*** 7255,7268 ****
+--- 7255,7272 ----
+    if (atexit (delete_temp_files) != 0)
+      fatal_error (input_location, "atexit failed");
+  
++ #ifdef SIGINT
+    if (signal (SIGINT, SIG_IGN) != SIG_IGN)
+      signal (SIGINT, fatal_signal);
++ #endif
+  #ifdef SIGHUP
+    if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
+      signal (SIGHUP, fatal_signal);
+  #endif
++ #ifdef SIGTERM
+    if (signal (SIGTERM, SIG_IGN) != SIG_IGN)
+      signal (SIGTERM, fatal_signal);
++ #endif
+  #ifdef SIGPIPE
+    if (signal (SIGPIPE, SIG_IGN) != SIG_IGN)
+      signal (SIGPIPE, fatal_signal);
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libgcc/config/arm/unwind-arm.h gcc-6.2.0/libgcc/config/arm/unwind-arm.h
+*** gcc-6.2.0-fsf/libgcc/config/arm/unwind-arm.h	2016-11-23 09:11:08.272176504 -0800
+--- gcc-6.2.0/libgcc/config/arm/unwind-arm.h	2016-11-21 15:14:40.515788234 -0800
+*************** extern "C" {
+*** 49,55 ****
+  	return 0;
+  
+  #if (defined(linux) && !defined(__uClinux__)) || defined(__NetBSD__) \
+!     || defined(__FreeBSD__)
+        /* Pc-relative indirect.  */
+  #define _GLIBCXX_OVERRIDE_TTYPE_ENCODING (DW_EH_PE_pcrel | DW_EH_PE_indirect)
+        tmp += ptr;
+--- 49,55 ----
+  	return 0;
+  
+  #if (defined(linux) && !defined(__uClinux__)) || defined(__NetBSD__) \
+!     || defined(__FreeBSD__) || defined(__fuchsia__)
+        /* Pc-relative indirect.  */
+  #define _GLIBCXX_OVERRIDE_TTYPE_ENCODING (DW_EH_PE_pcrel | DW_EH_PE_indirect)
+        tmp += ptr;
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libgcc/config/t-slibgcc-fuchsia gcc-6.2.0/libgcc/config/t-slibgcc-fuchsia
+*** gcc-6.2.0-fsf/libgcc/config/t-slibgcc-fuchsia	1969-12-31 16:00:00.000000000 -0800
+--- gcc-6.2.0/libgcc/config/t-slibgcc-fuchsia	2016-11-16 08:49:38.427039926 -0800
 ***************
 *** 0 ****
 --- 1,22 ----
@@ -242,21 +870,50 @@
 + 
 + SHLIB_LDFLAGS = -Wl,--soname=$(SHLIB_SONAME) \
 +                 $(LDFLAGS)
-diff -dcprN gcc-6.2.0/libgcc/config.host gcc-6.2.0-fuchsia/libgcc/config.host
-*** gcc-6.2.0/libgcc/config.host	2016-05-16 23:15:52.000000000 -0700
---- gcc-6.2.0-fuchsia/libgcc/config.host	2016-10-31 15:15:46.787859155 -0700
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libgcc/config.host gcc-6.2.0/libgcc/config.host
+*** gcc-6.2.0-fsf/libgcc/config.host	2016-11-23 09:11:08.440175844 -0800
+--- gcc-6.2.0/libgcc/config.host	2016-12-08 12:43:21.452060382 -0800
 *************** case ${host} in
 *** 230,235 ****
---- 230,238 ----
+--- 230,239 ----
         ;;
     esac
     ;;
 + *-*-fuchsia*)
-+   tmake_file="$tmake_file t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-fuchsia"
++   tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-fuchsia"
++   extra_parts="crtbegin.o crtend.o"
 +   ;;
   *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu)
     tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux"
     extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
+*************** aarch64*-*-elf | aarch64*-*-rtems*)
+*** 333,338 ****
+--- 337,346 ----
+  	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+  	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
+  	;;
++ aarch64*-*-fuchsia*)
++ 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
++ 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp"
++ 	;;
+  aarch64*-*-linux*)
+  	extra_parts="$extra_parts crtfastmath.o"
+  	md_unwind_header=aarch64/linux-unwind.h
+*************** arm*-*-freebsd*)                # ARM Fr
+*** 383,388 ****
+--- 391,402 ----
+  	unwind_header=config/arm/unwind-arm.h
+  	tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp"
+  	;;
++ arm*-*-fuchsia*)
++ 	tmake_file="${tmake_file} arm/t-arm arm/t-elf arm/t-bpabi"
++ 	tmake_file="${tmake_file} arm/tsoftfp t-softfp"
++ 	tm_file="${tm_file} arm/bpabi-lib.h"
++ 	unwind_header=config/arm/unwind-arm.h
++ 	;;
+  arm*-*-netbsdelf*)
+  	tmake_file="$tmake_file arm/t-arm arm/t-netbsd t-slibgcc-gld-nover"
+  	;;
 *************** i[34567]86-*-elfiamcu)
 *** 577,584 ****
   i[34567]86-*-elf*)
@@ -267,7 +924,7 @@
   	;;
   i[34567]86-*-dragonfly*)
   	tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
---- 580,587 ----
+--- 591,598 ----
   i[34567]86-*-elf*)
   	tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
   	;;
@@ -276,9 +933,117 @@
   	;;
   i[34567]86-*-dragonfly*)
   	tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff"
-diff -dcprN gcc-6.2.0/libstdc++-v3/configure gcc-6.2.0-fuchsia/libstdc++-v3/configure
-*** gcc-6.2.0/libstdc++-v3/configure	2016-04-05 12:03:46.000000000 -0700
---- gcc-6.2.0-fuchsia/libstdc++-v3/configure	2016-10-25 16:25:08.882770549 -0700
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libiberty/pex-unix.c gcc-6.2.0/libiberty/pex-unix.c
+*** gcc-6.2.0-fsf/libiberty/pex-unix.c	2016-11-23 09:11:07.752178546 -0800
+--- gcc-6.2.0/libiberty/pex-unix.c	2016-12-09 16:42:25.553491646 -0800
+*************** extern int errno;
+*** 60,65 ****
+--- 60,71 ----
+  #include <process.h>
+  #endif
+  
++ #ifdef __fuchsia__
++ #include <launchpad/launchpad.h>
++ #include <magenta/syscalls.h>
++ #include <magenta/syscalls/object.h>
++ #endif
++ 
+  #ifdef vfork /* Autoconf may define this to fork for us. */
+  # define VFORK_STRING "fork"
+  #else
+*************** to_ptr32 (char **ptr64)
+*** 120,126 ****
+  
+  static pid_t pex_wait (struct pex_obj *, pid_t, int *, struct pex_time *);
+  
+! #ifdef HAVE_WAIT4
+  
+  static pid_t
+  pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status,
+--- 126,162 ----
+  
+  static pid_t pex_wait (struct pex_obj *, pid_t, int *, struct pex_time *);
+  
+! #ifdef __fuchsia__
+! 
+! static pid_t
+! pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status,
+!           struct pex_time *time ATTRIBUTE_UNUSED)
+! {
+!   mx_status_t wait_result, procinfo_result;
+!   mx_info_process_t proc_info;
+! 
+!   /* We don't support waiting on multiple pids.  */
+!   if (pid <= 0)
+!     return -1;
+! 
+!   wait_result = mx_handle_wait_one ((mx_handle_t) pid, MX_SIGNAL_SIGNALED,
+! 				    MX_TIME_INFINITE, NULL);
+! 
+!   if (wait_result != NO_ERROR)
+!     return -1;
+! 
+!   procinfo_result = mx_object_get_info ((mx_handle_t) pid, MX_INFO_PROCESS,
+! 					&proc_info, sizeof (proc_info), NULL,
+! 					NULL);
+! 
+!   if (procinfo_result != NO_ERROR)
+!     return -1;
+! 
+!   *status = proc_info.return_code;
+!   return pid;
+! }
+! 
+! #elif defined(HAVE_WAIT4)
+  
+  static pid_t
+  pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status,
+*************** pex_child_error (struct pex_obj *obj, co
+*** 391,397 ****
+  
+  /* Execute a child.  */
+  
+! #if defined(HAVE_SPAWNVE) && defined(HAVE_SPAWNVPE)
+  /* Implementation of pex->exec_child using the Cygwin spawn operation.  */
+  
+  /* Subroutine of pex_unix_exec_child.  Move OLD_FD to a new file descriptor
+--- 427,433 ----
+  
+  /* Execute a child.  */
+  
+! #if defined(__fuchsia__) || (defined(HAVE_SPAWNVE) && defined(HAVE_SPAWNVPE))
+  /* Implementation of pex->exec_child using the Cygwin spawn operation.  */
+  
+  /* Subroutine of pex_unix_exec_child.  Move OLD_FD to a new file descriptor
+*************** pex_unix_exec_child (struct pex_obj *obj
+*** 547,556 ****
+--- 583,605 ----
+      {
+        typedef const char * const *cc_cp;
+  
++ #ifdef __fuchsia__
++       {
++ 	int argc;
++ 
++ 	/* Count the number of arguments.  */
++ 	for (argc = 0; argv[argc]; argc++)
++ 	  ;
++ 
++         /* TODO: Implement PATH search for PEX_SEARCH option.  */
++         pid = launchpad_launch_mxio (executable, argc, argv);
++       }
++ #else
+        if (flags & PEX_SEARCH)
+  	pid = spawnvpe (_P_NOWAITO, executable, (cc_cp)argv, (cc_cp)env);
+        else
+  	pid = spawnve (_P_NOWAITO, executable, (cc_cp)argv, (cc_cp)env);
++ #endif
+  
+        if (pid > 0)
+  	break;
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libstdc++-v3/configure gcc-6.2.0/libstdc++-v3/configure
+*** gcc-6.2.0-fsf/libstdc++-v3/configure	2016-11-23 09:10:40.968283817 -0800
+--- gcc-6.2.0/libstdc++-v3/configure	2016-11-16 08:49:38.447039849 -0800
 *************** if test -z "$aix_libpath"; then aix_libp
 *** 9825,9830 ****
 --- 9825,9837 ----
@@ -507,9 +1272,9 @@
     *-hpux*)
       SECTION_FLAGS='-ffunction-sections -fdata-sections'
   
-diff -dcprN gcc-6.2.0/libstdc++-v3/crossconfig.m4 gcc-6.2.0-fuchsia/libstdc++-v3/crossconfig.m4
-*** gcc-6.2.0/libstdc++-v3/crossconfig.m4	2015-10-11 15:34:28.000000000 -0700
---- gcc-6.2.0-fuchsia/libstdc++-v3/crossconfig.m4	2016-10-25 16:20:47.855807450 -0700
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libstdc++-v3/crossconfig.m4 gcc-6.2.0/libstdc++-v3/crossconfig.m4
+*** gcc-6.2.0-fsf/libstdc++-v3/crossconfig.m4	2016-11-23 09:10:41.352282308 -0800
+--- gcc-6.2.0/libstdc++-v3/crossconfig.m4	2016-11-16 08:49:38.451039834 -0800
 *************** case "${host}" in
 *** 107,112 ****
 --- 107,118 ----
@@ -525,9 +1290,9 @@
     *-hpux*)
       SECTION_FLAGS='-ffunction-sections -fdata-sections'
       AC_SUBST(SECTION_FLAGS)
-diff -dcprN gcc-6.2.0/libtool.m4 gcc-6.2.0-fuchsia/libtool.m4
-*** gcc-6.2.0/libtool.m4	2015-11-26 05:20:59.000000000 -0800
---- gcc-6.2.0-fuchsia/libtool.m4	2016-10-25 15:03:17.327232321 -0700
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/libtool.m4 gcc-6.2.0/libtool.m4
+*** gcc-6.2.0-fsf/libtool.m4	2016-11-23 09:11:07.960177729 -0800
+--- gcc-6.2.0/libtool.m4	2016-12-09 14:52:40.904402887 -0800
 *************** else
 *** 1748,1753 ****
 --- 1748,1758 ----
@@ -544,135 +1309,86 @@
   	  [lt_cv_dlopen="shl_load"],
 *************** freebsd* | dragonfly*)
 *** 2323,2328 ****
---- 2328,2339 ----
+--- 2328,2342 ----
     esac
     ;;
   
 + fuchsia*)
-+   library_names_spec='${libname}${shared_ext}'
 +   need_lib_prefix=no
 +   need_version=no
++   dynamic_linker="$host_os ld.so.1"
++   library_names_spec='$libname$shared_ext'
++   soname_spec='$libname$shared_ext'
++   sys_lib_dlsearch_path_spec='/system/lib /boot/lib'
 +   ;;
 + 
   gnu*)
     version_type=linux
     need_lib_prefix=no
-*************** _LT_EOF
-*** 4831,4836 ****
---- 4842,4854 ----
-        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
-        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-        _LT_TAGVAR(hardcode_direct, $1)=yes
-+       _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
-+       ;;
+*************** freebsd* | dragonfly*)
+*** 3047,3052 ****
+--- 3061,3070 ----
+    fi
+    ;;
+  
++ fuchsia*)
++   lt_cv_deplibs_check_method=pass_all
++   ;;
 + 
-+     fuchsia*)
-+       _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
-+       _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
-+       _LT_TAGVAR(hardcode_direct, $1)=yes
-        _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+  gnu*)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+*************** m4_if([$1], [CXX], [
+*** 3604,3610 ****
+        esac
         ;;
   
-diff -dcpr gcc-6.2.0-orig/gcc/config/fuchsia.h gcc-6.2.0/gcc/config/fuchsia.h
-*** gcc-6.2.0-orig/gcc/config/fuchsia.h	2016-11-14 16:41:03.688822073 -0800
---- gcc-6.2.0/gcc/config/fuchsia.h	2016-11-15 15:41:41.047289495 -0800
-*************** along with GCC; see the file COPYING3.
-*** 47,49 ****
---- 47,53 ----
-  		  "%{shared: -shared}" \
-  		  "%{!shared:%{!static:%{!dynamic-linker: -dynamic-linker=ld.so.1}}}"
+!     beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+        # PIC is the default for these OSes.
+        ;;
+      mingw* | cygwin* | os2* | pw32* | cegcc*)
+--- 3622,3628 ----
+        esac
+        ;;
   
-+ /* We are using MUSL as our libc.  */
-+ #undef  OPTION_MUSL
-+ #define OPTION_MUSL 1
-+ 
-diff -dcpr gcc-6.2.0-orig/gcc/config.gcc gcc-6.2.0/gcc/config.gcc
-*** gcc-6.2.0-orig/gcc/config.gcc	2016-11-14 16:41:05.332815117 -0800
---- gcc-6.2.0/gcc/config.gcc	2016-11-15 15:42:09.055176481 -0800
-*************** case ${target} in
-*** 907,913 ****
-  esac
-  
-  case ${target} in
-! aarch64*-*-elf | aarch64*-*-rtems*)
-  	tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
-  	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-elf-raw.h"
-  	tmake_file="${tmake_file} aarch64/t-aarch64"
---- 907,913 ----
-  esac
-  
-  case ${target} in
-! aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
-  	tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
-  	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-elf-raw.h"
-  	tmake_file="${tmake_file} aarch64/t-aarch64"
-*************** aarch64*-*-elf | aarch64*-*-rtems*)
-*** 915,920 ****
---- 915,923 ----
-  	aarch64-*-elf*)
-  		use_gcc_stdint=wrap
-  		;;
-+         aarch64-*-fuchsia*)
-+                 tm_file="${tm_file} fuchsia.h"
-+                 ;;
-  	aarch64-*-rtems*)
-  	  	tm_file="${tm_file} rtems.h aarch64/rtems.h"
-  		;;
-*************** arm*-*-uclinux*eabi*)		# ARM ucLinux
-*** 1097,1103 ****
-  	# The EABI requires the use of __cxa_atexit.
-  	default_use_cxa_atexit=yes
+!     beos* | fuchsia* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+        # PIC is the default for these OSes.
+        ;;
+      mingw* | cygwin* | os2* | pw32* | cegcc*)
+*************** m4_if([$1], [CXX], [
+*** 3694,3699 ****
+--- 3712,3722 ----
+        freebsd* | dragonfly*)
+  	# FreeBSD uses GNU C++
   	;;
-! arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems*)
-  	case ${target} in
-  	arm*eb-*-eabi*)
-  	  tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
---- 1100,1106 ----
-  	# The EABI requires the use of __cxa_atexit.
-  	default_use_cxa_atexit=yes
-  	;;
-! arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems* | arm*-*-fuchsia*)
-  	case ${target} in
-  	arm*eb-*-eabi*)
-  	  tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
-*************** arm*-*-eabi* | arm*-*-symbianelf* | arm*
-*** 1111,1116 ****
---- 1114,1122 ----
-  	  tmake_file="${tmake_file} arm/t-bpabi"
-  	  use_gcc_stdint=wrap
-  	  ;;
-+ 	arm*-*-fuchsia*)
-+ 	  tm_file="${tm_file} fuchsia.h glibc-stdint.h"
-+ 	  ;;
-  	arm*-*-rtems*)
-  	  tm_file="${tm_file} rtems.h arm/rtems.h newlib-stdint.h"
-  	  tmake_file="${tmake_file} arm/t-bpabi arm/t-rtems"
-diff -dcpr gcc-6.2.0-orig/libgcc/config.host gcc-6.2.0/libgcc/config.host
-*** gcc-6.2.0-orig/libgcc/config.host	2016-11-14 16:41:05.536814253 -0800
---- gcc-6.2.0/libgcc/config.host	2016-11-15 08:48:35.813137073 -0800
-*************** aarch64*-*-elf | aarch64*-*-rtems*)
-*** 336,341 ****
---- 336,345 ----
-  	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
-  	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
-  	;;
-+ aarch64*-*-fuchsia*)
-+ 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
-+ 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp"
++       fuchsia* )
++ 	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
++ 	_LT_TAGVAR(lt_prog_compiler_pic, $1)=
++ 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
 + 	;;
-  aarch64*-*-linux*)
-  	extra_parts="$extra_parts crtfastmath.o"
-  	md_unwind_header=aarch64/linux-unwind.h
-*************** arm*-*-freebsd*)                # ARM Fr
-*** 386,391 ****
---- 390,399 ----
-  	unwind_header=config/arm/unwind-arm.h
-  	tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp"
-  	;;
-+ arm*-*-fuchsia*)
-+ 	tmake_file="${tmake_file} arm/t-arm arm/t-elf"
-+ 	tmake_file="${tmake_file} arm/tsoftfp t-softfp"
-+ 	;;
-  arm*-*-netbsdelf*)
-  	tmake_file="$tmake_file arm/t-arm arm/t-netbsd t-slibgcc-gld-nover"
-  	;;
+        hpux9* | hpux10* | hpux11*)
+  	case $cc_basename in
+  	  CC*)
+diff -rdcp --unidirectional-new-file gcc-6.2.0-fsf/Makefile.in gcc-6.2.0/Makefile.in
+*** gcc-6.2.0-fsf/Makefile.in	2016-11-23 09:11:07.960177729 -0800
+--- gcc-6.2.0/Makefile.in	2016-12-08 13:11:05.048744794 -0800
+*************** BASE_TARGET_EXPORTS = \
+*** 287,292 ****
+--- 287,293 ----
+  	LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \
+  	LIPO="$(LIPO_FOR_TARGET)"; export LIPO; \
+  	NM="$(COMPILER_NM_FOR_TARGET)"; export NM; \
++ 	NO_PIE_CFLAGS="$(NO_PIE_CFLAGS_FOR_TARGET)"; export NO_PIE_CFLAGS; \
+  	OBJDUMP="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP; \
+  	OBJCOPY="$(OBJCOPY_FOR_TARGET)"; export OBJCOPY; \
+  	RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
+*************** EXTRA_TARGET_FLAGS = \
+*** 869,874 ****
+--- 870,876 ----
+  	'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \
+  	'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET)' \
+  	'NM=$(COMPILER_NM_FOR_TARGET)' \
++ 	'NO_PIE_CFLAGS=$(NO_PIE_CFLAGS_FOR_TARGET)' \
+  	'OBJDUMP=$$(OBJDUMP_FOR_TARGET)' \
+  	'OBJCOPY=$$(OBJCOPY_FOR_TARGET)' \
+  	'RANLIB=$$(RANLIB_FOR_TARGET)' \