diff mbox

Add --enable-default-dwarf=N configury

Message ID 20100727202530.D7BAF400DD@magilla.sf.frob.com
State New
Headers show

Commit Message

Roland McGrath July 27, 2010, 8:25 p.m. UTC
I've updated the patch to document the configure option, and so
update_web_docs_svn should work (didn't test that).  The built
documentation says what the configured default is but the web docs won't.

Any more general changes to option documentation are beyond the scope of
this change.  If you do something like that, this case will fit into that
scheme easily.


Thanks,
Roland

---

gcc/
2010-07-27  Roland McGrath  <roland@redhat.com>

	* configure.ac: Handle --enable-default-dwarf=N.
	Generate gcc-config.texi with @set for default_dwarf.
	* configure: Regenerated.
	* config.in: Regenerated.
	* common.opt (gdwarf-): Use DEFAULT_DWARF_VERSION macro as default.
	* doc/include/gcc-common.texi: @include gcc-config.texi here.
	* doc/invoke.texi (-gdwarf-@var{version}): Use @value{default_dwarf}.
	* doc/install.texi (Configuration): Document --enable-default-dwarf=N.

maintainer-scripts/
2010-07-27  Roland McGrath  <roland@redhat.com>

	* update_web_docs_svn: Create empty gcc-config.texi file.

Comments

Jakub Jelinek July 27, 2010, 8:34 p.m. UTC | #1
On Tue, Jul 27, 2010 at 01:25:30PM -0700, Roland McGrath wrote:
> I've updated the patch to document the configure option, and so
> update_web_docs_svn should work (didn't test that).  The built
> documentation says what the configured default is but the web docs won't.
> 
> Any more general changes to option documentation are beyond the scope of
> this change.  If you do something like that, this case will fit into that
> scheme easily.

Wouldn't it be better just to say in doc/invoke.texi that the default
version depends on how gcc has been configured?

	Jakub
Roland McGrath July 27, 2010, 9 p.m. UTC | #2
> Wouldn't it be better just to say in doc/invoke.texi that the default
> version depends on how gcc has been configured?

It does say that.  It also says what the particular configured default is.
Someone using a particular installation would be rightly annoyed to have no
way to discern their compiler's default behavior short of resorting to
source code or experimentation.


Thanks,
Roland
diff mbox

Patch

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/install.texi b/gcc/doc/install.texi
index fc9b988..59386c1 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1665,6 +1665,10 @@  enabled together with @option{--enable-lto}, an additional directory
 plugin for gold that allows the link-time optimizer to extract object
 files with LTO information out of library archives.  See
 @option{-flto} and @option{-fwhopr} for details.
+
+@item --enable-default-dwarf=@var{version}
+Emit DWARF format @var{version} (rather than 2) for @option{-g}
+when no @option{-gdwarf-@var{version}} option is passed to the compiler.
 @end table
 
 @subheading Cross-Compiler-Specific Options
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 73051de..ef4f5d5 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -4587,7 +4587,11 @@  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
+depends on the configuration with which GCC was built.
+@ifset default_dwarf
+In this system's GCC, the default @var{version} is @value{default_dwarf}.
+@end ifset
 
 Note that with DWARF version 2 some ports require, and will always
 use, some non-conflicting DWARF 3 extensions in the unwind tables.
diff --git a/maintainer-scripts/update_web_docs_svn b/maintainer-scripts/update_web_docs_svn
index a8fb395..9a3338c 100755
--- a/maintainer-scripts/update_web_docs_svn
+++ b/maintainer-scripts/update_web_docs_svn
@@ -149,6 +149,9 @@  fi
    echo "@set BUGURL @uref{http://gcc.gnu.org/bugs/}"
 ) > $includedir/gcc-vers.texi
 
+# Empty config is default config.
+> $includedir/gcc-config.texi
+
 # Now convert the relevant files from texi to HTML, PDF and PostScript.
 for file in $MANUALS; do
   filename=`find . -name ${file}.texi`