diff --git a/gcc/common.opt b/gcc/common.opt
index 41a9838..f6e3f4a 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1540,7 +1540,7 @@ Common JoinedOrMissing Negative(gdwarf-)
 Generate debug information in COFF format
 
 gdwarf-
-Common Joined UInteger Var(dwarf_version) Init(2) Negative(gstabs)
+Common Joined UInteger Var(dwarf_version) Init(DEFAULT_DWARF_VERSION) Negative(gstabs)
 Generate debug information in DWARF v2 (or later) format
 
 ggdb
diff --git a/gcc/config.in b/gcc/config.in
index c451c53..9d229f3 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -24,6 +24,12 @@
 #endif
 
 
+/* Default DWARF version with no -gdwarf-N switch. */
+#ifndef USED_FOR_TARGET
+#undef DEFAULT_DWARF_VERSION
+#endif
+
+
 /* Define to enable the use of a default linker. */
 #ifndef USED_FOR_TARGET
 #undef DEFAULT_LINKER
diff --git a/gcc/configure b/gcc/configure
index aa61cd6..41bca0f 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -890,6 +890,7 @@ with_pkgversion
 with_bugurl
 enable_languages
 with_multilib_list
+enable_default_dwarf
 enable_rpath
 with_libiconv_prefix
 enable_initfini_array
@@ -1589,6 +1590,8 @@ Optional Features:
   --disable-shared        don't provide a shared libgcc
   --enable-intermodule    build the compiler in one step
   --enable-languages=LIST specify which front-ends to build
+  --enable-default-dwarf=VERSION
+                          -g defaults to -gdwarf-VERSION
   --disable-rpath         do not hardcode runtime library paths
   --enable-initfini-array	use .init_array/.fini_array sections
   --enable-sjlj-exceptions
@@ -6968,6 +6971,37 @@ else
 fi
 
 
+# Check whether --enable-default-dwarf was given.
+if test "${enable_default_dwarf+set}" = set; then :
+  enableval=$enable_default_dwarf; default_dwarf=$enableval
+else
+  default_dwarf=2
+fi
+
+case "$default_dwarf" in
+[2-9]) ;;
+*) as_fn_error "--enable-default-dwarf requires a DWARF version number" "$LINENO" 5 ;;
+esac
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_DWARF_VERSION $default_dwarf
+_ACEOF
+
+doc_config_vars="$doc_config_vars default_dwarf"
+
+# ----------------------------------------------------------------
+# Generate gcc-config.texi to pass along vars in $doc_config_vars.
+# ----------------------------------------------------------------
+doc_config=
+for var in $doc_config_vars; do
+  eval val=\$$var
+  doc_config="$doc_config
+@set $var $val"
+done
+ac_config_commands="$ac_config_commands gcc-config.texi"
+
+
 # -------------------------
 # Checks for other programs
 # -------------------------
@@ -17109,7 +17143,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17112 "configure"
+#line 17146 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17215,7 +17249,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17218 "configure"
+#line 17252 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -26466,6 +26500,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 #
 # INIT-COMMANDS
 #
+doc_config="$doc_config"
 subdirs='$subdirs'
 
 _ACEOF
@@ -26477,6 +26512,7 @@ for ac_config_target in $ac_config_targets
 do
   case $ac_config_target in
     "auto-host.h") CONFIG_HEADERS="$CONFIG_HEADERS auto-host.h:config.in" ;;
+    "gcc-config.texi") CONFIG_COMMANDS="$CONFIG_COMMANDS gcc-config.texi" ;;
     "as") CONFIG_FILES="$CONFIG_FILES as:exec-tool.in" ;;
     "collect-ld") CONFIG_FILES="$CONFIG_FILES collect-ld:exec-tool.in" ;;
     "nm") CONFIG_FILES="$CONFIG_FILES nm:exec-tool.in" ;;
@@ -27060,6 +27096,13 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
 
 
   case $ac_file$ac_mode in
+    "gcc-config.texi":C)
+  rm -f gcc-config.texi
+  cat > gcc-config.texi <<EOF
+@c Generated by configure.
+$doc_config
+EOF
+ ;;
     "as":F) chmod +x as ;;
     "collect-ld":F) chmod +x collect-ld ;;
     "nm":F) chmod +x nm ;;
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 24d38aa..6eeedce 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -833,6 +833,37 @@ AC_ARG_WITH(multilib-list,
 :,
 with_multilib_list=default)
 
+AC_ARG_ENABLE(default-dwarf,
+  [AS_HELP_STRING([--enable-default-dwarf=VERSION],
+		  [-g defaults to -gdwarf-VERSION])],
+  [default_dwarf=$enableval],
+  [default_dwarf=2])
+case "$default_dwarf" in
+@<:@2-9@:>@) ;;
+*) AC_MSG_ERROR([--enable-default-dwarf requires a DWARF version number]) ;;
+esac
+
+AC_DEFINE_UNQUOTED([DEFAULT_DWARF_VERSION], $default_dwarf,
+		   [Default DWARF version with no -gdwarf-N switch.])
+doc_config_vars="$doc_config_vars default_dwarf"
+
+# ----------------------------------------------------------------
+# Generate gcc-config.texi to pass along vars in $doc_config_vars.
+# ----------------------------------------------------------------
+doc_config=
+for var in $doc_config_vars; do
+  eval val=\$$var
+  doc_config="$doc_config
+@set $var $val"
+done
+AC_CONFIG_COMMANDS([gcc-config.texi], [
+  rm -f gcc-config.texi
+  cat > gcc-config.texi <<EOF
+@c Generated by configure.
+$doc_config
+EOF
+], [doc_config="$doc_config"])
+
 # -------------------------
 # Checks for other programs
 # -------------------------
diff --git a/gcc/doc/include/gcc-common.texi b/gcc/doc/include/gcc-common.texi
index f06eb1f..3c8daed 100644
--- a/gcc/doc/include/gcc-common.texi
+++ b/gcc/doc/include/gcc-common.texi
@@ -1,5 +1,5 @@
-@c Copyright (C) 2001, 2002, 2003, 2004, 2005,
-@c 2007 Free Software Foundation, Inc.
+@c Copyright (C) 2001,2002,2003,2004,2005,2007,2010
+@c	Free Software Foundation, Inc.
 @c This is part of the GCC manual.
 @c For copying conditions, see the file gcc.texi.
 
@@ -10,6 +10,7 @@
 @c in gcc/DEV-PHASE).
 
 @include gcc-vers.texi
+@include gcc-config.texi
 
 @c Common macros to support generating man pages:
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 73051de..9ed4491 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -4587,7 +4587,8 @@ assembler (GAS) to fail with an error.
 @opindex gdwarf-@var{version}
 Produce debugging information in DWARF format (if that is
 supported).  This is the format used by DBX on IRIX 6.  The value
-of @var{version} may be either 2, 3 or 4; the default version is 2.
+of @var{version} may be either 2, 3 or 4; the default version is
+@value{default_dwarf}.
 
 Note that with DWARF version 2 some ports require, and will always
 use, some non-conflicting DWARF 3 extensions in the unwind tables.
