diff --git a/gcc/config.gcc b/gcc/config.gcc
index 95c91ee02be..19f003c7952 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1482,6 +1482,11 @@ arm*-*-eabi* | arm*-*-symbianelf* | arm*-*-rtems* | arm*-*-fuchsia*)
 	  tm_file="$tm_file newlib-stdint.h"
 	  tmake_file="${tmake_file} arm/t-bpabi"
 	  use_gcc_stdint=wrap
+	  tm_file="${tm_file} devkitpro.h"
+	  extra_options="${extra_options} devkitpro.opt"
+	  case ${enable_threads} in
+		"" | yes | posix) thread_file='posix' ;;
+	  esac
 	  ;;
 	arm*-*-fuchsia*)
 	  tm_file="${tm_file} fuchsia.h arm/fuchsia-elf.h glibc-stdint.h"
diff --git a/gcc/config/arm/arm-cpus.in b/gcc/config/arm/arm-cpus.in
index 451b15fe9f9..c9efaf21c8c 100644
--- a/gcc/config/arm/arm-cpus.in
+++ b/gcc/config/arm/arm-cpus.in
@@ -416,7 +416,7 @@ begin arch armv6k
  tune for mpcore
  tune flags CO_PROC
  base 6K
- isa ARMv6k
+ isa ARMv6k VFPv2 FP_DBL
  option fp add VFPv2 FP_DBL
  optalias vfpv2 fp
  option nofp remove ALL_FP
diff --git a/gcc/config/arm/t-arm-elf b/gcc/config/arm/t-arm-elf
index aa64e50edeb..99cc8199ec5 100644
--- a/gcc/config/arm/t-arm-elf
+++ b/gcc/config/arm/t-arm-elf
@@ -16,120 +16,22 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
-# Build a very basic set of libraries that should cater for most cases.
-
-# Single-precision floating-point is NOT supported; we don't build a
-# suitable library for that.  Use the rm-profile config in that case.
-
-# PART 1 - Useful groups of options
-
-dp_fpus		:= vfp vfpv2 vfpv3 vfpv3-fp16 vfpv3-d16 vfpv3-d16-fp16 \
-		   neon neon-vfpv3 neon-fp16 vfpv4 neon-vfpv4 vfpv4-d16 \
-		   fpv5-d16 fp-armv8 neon-fp-armv8 crypto-neon-fp-armv8 \
-		   vfp3
-
-sp_fpus		:= vfpv3xd vfpv3xd-fp16  fpv4-sp-d16 fpv5-sp-d16
-
-v7a_fps		:= vfpv3 vfpv3-fp16 vfpv4 simd neon-fp16 neon-vfpv4
-v7ve_fps	:= vfpv3-d16 vfpv3 vfpv3-d16-fp16 vfpv3-fp16 vfpv4 neon \
-		   neon-fp16 simd
-
-# Not all these permutations exist for all architecture variants, but
-# it seems to work ok.
-v8_fps		:= simd fp16 crypto fp16+crypto dotprod fp16fml
-
-v9_fps		:= simd fp16 crypto fp16+crypto dotprod fp16fml
-
-# We don't do anything special with these.  Pre-v4t probably doesn't work.
-all_early_nofp	:= armv4 armv4t armv5t
-
-all_early_arch	:= armv5tej armv6 armv6j armv6k armv6z armv6kz \
-		   armv6zk armv6t2 iwmmxt iwmmxt2
-
-all_v7_a_r	:= armv7-a armv7ve armv7-r
-
-all_v8_archs	:= armv8-a armv8-a+crc armv8.1-a armv8.2-a armv8.3-a armv8.4-a \
-		   armv8.5-a armv8.6-a
-
-all_v9_archs	:= armv9-a
-
-# No floating point variants, require thumb1 softfp
-all_nofp_t	:= armv6-m armv6s-m armv8-m.base
-
-all_nofp_t2	:= armv7-m
-
-all_sp_only	:= armv7e-m armv8-m.main
-
-MULTILIB_OPTIONS     =
-MULTILIB_DIRNAMES    =
+MULTILIB_OPTIONS     = mthumb mbig-endian march=armv6k march=armv6s-m mfloat-abi=hard mfloat-abi=soft
+MULTILIB_DIRNAMES    = thumb be armv6k v6-m fpu nofp
 MULTILIB_EXCEPTIONS  = 
 MULTILIB_MATCHES     =
-MULTILIB_REUSE	     =
-
-# PART 2 - multilib build rules
-
-MULTILIB_OPTIONS     += marm/mthumb
-MULTILIB_DIRNAMES    += arm thumb
-
-MULTILIB_OPTIONS     += mfpu=auto
-MULTILIB_DIRNAMES    += autofp
-
-MULTILIB_OPTIONS     += march=armv5te+fp/march=armv7+fp
-MULTILIB_DIRNAMES    += v5te v7
-
-MULTILIB_OPTIONS     += mfloat-abi=hard
-MULTILIB_DIRNAMES    += fpu
-
-# Build a total of 4 library variants (base options plus the following):
-MULTILIB_REQUIRED    += mthumb
-MULTILIB_REQUIRED    += marm/mfpu=auto/march=armv5te+fp/mfloat-abi=hard
-MULTILIB_REQUIRED    += mthumb/mfpu=auto/march=armv7+fp/mfloat-abi=hard
-
-# PART 3 - Match rules
-
-# Map all supported FPUs onto mfpu=auto
-MULTILIB_MATCHES     += $(foreach FPU, $(dp_fpus), \
-			  mfpu?auto=mfpu?$(FPU))
-
-MULTILIB_MATCHES     += march?armv5te+fp=march?armv5te
-
-MULTILIB_MATCHES     += $(foreach ARCH, $(all_early_arch), \
-		          march?armv5te+fp=march?$(ARCH) \
-			  march?armv5te+fp=march?$(ARCH)+fp)
-
-MULTILIB_MATCHES     += march?armv7+fp=march?armv7
-
-MULTILIB_MATCHES     += $(foreach FPARCH, $(v7a_fps), \
-		          march?armv7+fp=march?armv7-a+$(FPARCH))
-
-MULTILIB_MATCHES     += $(foreach FPARCH, $(v7ve_fps), \
-		          march?armv7+fp=march?armv7ve+$(FPARCH))
-
-MULTILIB_MATCHES     += $(foreach ARCH, $(all_v7_a_r), \
-			  march?armv7+fp=march?$(ARCH) \
-			  march?armv7+fp=march?$(ARCH)+fp)
 
-MULTILIB_MATCHES     += $(foreach ARCH, $(all_v8_archs), \
-			  march?armv7+fp=march?$(ARCH) \
-			  $(foreach FPARCH, $(v8_fps), \
-			    march?armv7+fp=march?$(ARCH)+$(FPARCH)))
+MULTILIB_REQUIRED    = mthumb mbig-endian mthumb/mbig-endian march=armv6k/mfloat-abi=hard mthumb/march=armv6s-m/mfloat-abi=soft
 
-MULTILIB_MATCHES     += $(foreach ARCH, $(all_v9_archs), \
-			  march?armv7+fp=march?$(ARCH) \
-			  $(foreach FPARCH, $(v9_fps), \
-			    march?armv7+fp=march?$(ARCH)+$(FPARCH)))
 
-MULTILIB_MATCHES     += $(foreach ARCH, armv7e-m armv8-m.mainline, \
-			  march?armv7+fp=march?$(ARCH)+fp.dp)
+MULTILIB_MATCHES    += march?armv6k=mtune?mpcore
+MULTILIB_MATCHES    += march?armv6k=mcpu?mpcore
 
-# PART 4 - Reuse rules
+MULTILIB_MATCHES    += march?armv6s-m=mcpu?cortex-m0
+MULTILIB_MATCHES    += march?armv6s-m=mtune?cortex-m0
+MULTILIB_MATCHES    += march?armv6s-m=mcpu?cortex-m0plus
+MULTILIB_MATCHES    += march?armv6s-m=mtune?cortex-m0plus
+MULTILIB_MATCHES    += march?armv6s-m=mcpu?cortex-m1
+MULTILIB_MATCHES    += march?armv6s-m=mtune?cortex-m1
 
-MULTILIB_REUSE	     += mthumb=mthumb/mfpu.auto
-MULTILIB_REUSE	     += mthumb=mthumb/mfpu.auto/march.armv5te+fp
-MULTILIB_REUSE	     += mthumb=mthumb/march.armv5te+fp
-MULTILIB_REUSE	     += marm/mfpu.auto/march.armv5te+fp/mfloat-abi.hard=marm/march.armv5te+fp/mfloat-abi.hard
-MULTILIB_REUSE	     += marm/mfpu.auto/march.armv5te+fp/mfloat-abi.hard=march.armv5te+fp/mfloat-abi.hard
-MULTILIB_REUSE	     += marm/mfpu.auto/march.armv5te+fp/mfloat-abi.hard=mfpu.auto/march.armv5te+fp/mfloat-abi.hard
-MULTILIB_REUSE	     += mthumb/mfpu.auto/march.armv7+fp/mfloat-abi.hard=mthumb/march.armv7+fp/mfloat-abi.hard
-MULTILIB_REUSE	     += mthumb/mfpu.auto/march.armv7+fp/mfloat-abi.hard=mfpu.auto/march.armv7+fp/mfloat-abi.hard
-MULTILIB_REUSE	     += mthumb/mfpu.auto/march.armv7+fp/mfloat-abi.hard=march.armv7+fp/mfloat-abi.hard
+MULTILIB_REUSE       = mthumb/march.armv6s-m/mfloat-abi.soft=mthumb/march.armv6s-m
diff --git a/gcc/config/arm/unknown-elf.h b/gcc/config/arm/unknown-elf.h
index 6b313042f20..7b39702224a 100644
--- a/gcc/config/arm/unknown-elf.h
+++ b/gcc/config/arm/unknown-elf.h
@@ -29,7 +29,7 @@
 #endif
 
 /* Now we define the strings used to build the spec file.  */
-#define UNKNOWN_ELF_STARTFILE_SPEC	" crti%O%s crtbegin%O%s crt0%O%s"
+#define UNKNOWN_ELF_STARTFILE_SPEC	" crti%O%s crtbegin%O%s"
 
 #undef  STARTFILE_SPEC
 #define STARTFILE_SPEC	\
@@ -93,4 +93,5 @@
    udivmoddi4, which will depend on the exception unwind routines,
    which will depend on abort, which is defined in libc.  */ 
 #undef LINK_GCC_C_SEQUENCE_SPEC
-#define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %{!nolibc:%L} --end-group"
+#define LINK_GCC_C_SEQUENCE_SPEC "--start-group %G %L %(libgloss) --end-group"
+
diff --git a/gcc/config/devkitpro.h b/gcc/config/devkitpro.h
new file mode 100644
index 00000000000..180a9ea8553
--- /dev/null
+++ b/gcc/config/devkitpro.h
@@ -0,0 +1,27 @@
+/* Definitions for devkitPro toolchains.
+   Copyright (C) 2016-2018 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.
+   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/>.  */
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS()                \
+    do {                                        \
+        builtin_define ("__DEVKITPRO__");       \
+        builtin_define ("__DEVKITARM__");       \
+    } while (0)
+
+
diff --git a/gcc/config/devkitpro.opt b/gcc/config/devkitpro.opt
new file mode 100644
index 00000000000..9acbbf9d27c
--- /dev/null
+++ b/gcc/config/devkitpro.opt
@@ -0,0 +1,29 @@
+; Options for devkitPro toolchains.
+
+; Copyright (C) 2011-2018 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/>.
+
+; See the GCC internals manual (options.texi) for a description of
+; this file's format.
+
+; Please try to keep this file in ASCII collating order.
+
+pthread
+Driver
+
+; This comment is to ensure we retain the blank line above.
diff --git a/gcc/config/devkitpro.opt.urls b/gcc/config/devkitpro.opt.urls
new file mode 100644
index 00000000000..ab7b466aa71
--- /dev/null
+++ b/gcc/config/devkitpro.opt.urls
@@ -0,0 +1 @@
+; Autogenerated by regenerate-opt-urls.py from gcc/config/devkitpro.opt and generated HTML
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 728332b8153..47fc03eb8c8 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -881,6 +881,11 @@ proper position among the other output files.  */
 #endif
 #endif
 
+#ifndef LIBGLOSS_SPEC
+# define LIBGLOSS_SPEC "-lsysbase"
+#endif
+
+
 /* config.h can define STARTFILE_SPEC to override the default crt0 files.  */
 #ifndef STARTFILE_SPEC
 #define STARTFILE_SPEC  \
@@ -1208,6 +1213,7 @@ static const char *link_spec = LINK_SPEC;
 static const char *lib_spec = LIB_SPEC;
 static const char *link_gomp_spec = "";
 static const char *libgcc_spec = LIBGCC_SPEC;
+static const char *libgloss_spec = LIBGLOSS_SPEC;
 static const char *endfile_spec = ENDFILE_SPEC;
 static const char *startfile_spec = STARTFILE_SPEC;
 static const char *linker_name_spec = LINKER_NAME;
@@ -1720,6 +1726,7 @@ static struct spec_list static_specs[] =
   INIT_STATIC_SPEC ("lib",			&lib_spec),
   INIT_STATIC_SPEC ("link_gomp",		&link_gomp_spec),
   INIT_STATIC_SPEC ("libgcc",			&libgcc_spec),
+  INIT_STATIC_SPEC ("libgloss",			&libgloss_spec),
   INIT_STATIC_SPEC ("startfile",		&startfile_spec),
   INIT_STATIC_SPEC ("cross_compile",		&cross_compile),
   INIT_STATIC_SPEC ("version",			&compiler_version),
diff --git a/libcc1/configure b/libcc1/configure
index ea689a353c8..98f9d9b21b7 100755
--- a/libcc1/configure
+++ b/libcc1/configure
@@ -5119,7 +5119,7 @@ else
        # Adding the `sed 1q' prevents false positives on HP-UX, which says:
        #   nm: unknown option "B" ignored
        case `"$tmp_nm" -B "$tmp_nm_to_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
-       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+       $tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
 	 break
 	 ;;
        *)
diff --git a/libgcc/config/arm/t-bpabi b/libgcc/config/arm/t-bpabi
index dddddc7c444..c2502597953 100644
--- a/libgcc/config/arm/t-bpabi
+++ b/libgcc/config/arm/t-bpabi
@@ -17,4 +17,4 @@ SHLIB_MAPFILES += $(srcdir)/config/arm/libgcc-bpabi.ver
 # On ARM, specifying -fnon-call-exceptions will needlessly pull in
 # the unwinder in simple programs which use 64-bit division.  Omitting
 # the option is safe.
-LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions
+LIB2_DIVMOD_EXCEPTION_FLAGS := -fno-exceptions
diff --git a/libgcc/crtstuff.c b/libgcc/crtstuff.c
index 38d3859a73c..f97358d9787 100644
--- a/libgcc/crtstuff.c
+++ b/libgcc/crtstuff.c
@@ -326,7 +326,7 @@ register_tm_clones (void)
 
 #ifdef OBJECT_FORMAT_ELF
 
-#if DEFAULT_USE_CXA_ATEXIT
+#if 1 /* DEFAULT_USE_CXA_ATEXIT */
 /* Declare the __dso_handle variable.  It should have a unique value
    in every shared-object; in a main program its value is zero.  The
    object should in any case be protected.  This means the instance
diff --git a/libgcc/gthr.h b/libgcc/gthr.h
index 33c2d8ff630..e23c2a7990f 100644
--- a/libgcc/gthr.h
+++ b/libgcc/gthr.h
@@ -136,7 +136,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 /* The pe-coff weak support isn't fully compatible to ELF's weak.
    For static libraries it might would work, but as we need to deal
    with shared versions too, we disable it for mingw-targets.  */
-#ifdef __MINGW32__
+#ifdef __MINGW32__ || defined(__DEVKITARM__)
 #undef GTHREAD_USE_WEAK
 #define GTHREAD_USE_WEAK 0
 #endif
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 21abaeb0778..0ef23891978 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -893,6 +893,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -1027,6 +1028,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1279,6 +1281,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1416,7 +1427,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
+		libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1569,6 +1580,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -5080,7 +5092,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -5126,7 +5138,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -5150,7 +5162,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -5195,7 +5207,7 @@ else
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -5219,7 +5231,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -12280,7 +12292,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12283 "configure"
+#line 12295 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12386,7 +12398,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12389 "configure"
+#line 12401 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16182,7 +16194,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
   # Fake what AC_TRY_COMPILE does.
 
     cat > conftest.$ac_ext << EOF
-#line 16185 "configure"
+#line 16197 "configure"
 int main()
 {
   typedef bool atomic_type;
@@ -16217,7 +16229,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 16220 "configure"
+#line 16232 "configure"
 int main()
 {
   typedef short atomic_type;
@@ -16252,7 +16264,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 16255 "configure"
+#line 16267 "configure"
 int main()
 {
   // NB: _Atomic_word not necessarily int.
@@ -16288,7 +16300,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 16291 "configure"
+#line 16303 "configure"
 int main()
 {
   typedef long long atomic_type;
@@ -16444,7 +16456,7 @@ $as_echo "mutex" >&6; }
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 16447 "configure"
+#line 16459 "configure"
 int main()
 {
   _Decimal32 d1;
@@ -16486,7 +16498,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   # unnecessary for this test.
 
   cat > conftest.$ac_ext << EOF
-#line 16489 "configure"
+#line 16501 "configure"
 template<typename T1, typename T2>
   struct same
   { typedef T2 type; };
@@ -28575,6 +28587,8 @@ _ACEOF
 
     $as_echo "#define HAVE_MEMALIGN 1" >>confdefs.h
 
+    $as_echo "#define HAVE_ALIGNED_ALLOC 1" >>confdefs.h
+
 
     case "${target}" in
       *-rtems*)
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 37396bd6ebb..1dadf658c08 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -378,6 +378,7 @@ dnl # rather than hardcoding that information.
 
     AC_DEFINE(HAVE_ICONV)
     AC_DEFINE(HAVE_MEMALIGN)
+    AC_DEFINE(HAVE_ALIGNED_ALLOC)
 
     case "${target}" in
       *-rtems*)
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 422a0f4bd0a..42185df9517 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -1429,6 +1429,7 @@ ${host_builddir}/gthr.h: ${toplevel_srcdir}/libgcc/gthr.h stamp-${host_alias}
 	    -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \
 	    -e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \
 	    -e 's/_GLIBCXX___MINGW32_GLIBCXX___/__MINGW32__/g' \
+	    -e 's/_GLIBCXX___DEVKITARM_GLIBCXX___/__DEVKITARM__/g' \
 	    -e 's,^#include "\(.*\)",#include <bits/\1>,g' \
 	    < $< > $@
 
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 9fd4ab4848c..0b7ba4021ee 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -336,6 +336,7 @@ prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 python_mod_dir = @python_mod_dir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -1903,6 +1904,7 @@ ${host_builddir}/gthr.h: ${toplevel_srcdir}/libgcc/gthr.h stamp-${host_alias}
 	    -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \
 	    -e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \
 	    -e 's/_GLIBCXX___MINGW32_GLIBCXX___/__MINGW32__/g' \
+	    -e 's/_GLIBCXX___DEVKITARM_GLIBCXX___/__DEVKITARM__/g' \
 	    -e 's,^#include "\(.*\)",#include <bits/\1>,g' \
 	    < $< > $@
 
diff --git a/lto-plugin/configure b/lto-plugin/configure
index 28f5dd79cd7..a79f318a4d6 100755
--- a/lto-plugin/configure
+++ b/lto-plugin/configure
@@ -6469,7 +6469,7 @@ else
        # Adding the `sed 1q' prevents false positives on HP-UX, which says:
        #   nm: unknown option "B" ignored
        case `"$tmp_nm" -B "$tmp_nm_to_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
-       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+       $tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
 	 break
 	 ;;
        *)
