Patchwork Add --enable-default-dwarf=N configury

login
register
mail settings
Submitter Roland McGrath
Date July 27, 2010, 11:05 a.m.
Message ID <20100727110509.C8EDC400DD@magilla.sf.frob.com>
Download mbox | patch
Permalink /patch/59995/
State New
Headers show

Comments

Roland McGrath - July 27, 2010, 11:05 a.m.
This adds an --enable-default-dwarf=N configure option
to set the default setting of -gdwarf-N.

This includes some general configure infrastructure for passing
configure-time variables into Texinfo for use as @value{foobar},
which might be of use for other things too at some point.


Thanks,
Roland

---

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}.
Joseph S. Myers - July 27, 2010, 11:59 a.m.
On Tue, 27 Jul 2010, Roland McGrath wrote:

> This adds an --enable-default-dwarf=N configure option
> to set the default setting of -gdwarf-N.
> 
> This includes some general configure infrastructure for passing
> configure-time variables into Texinfo for use as @value{foobar},
> which might be of use for other things too at some point.

When making such changes to how the manuals are built you also need to 
update maintainer-scripts/update_web_docs_svn to generate appropriate 
files when generating GCC's online documentation.

There is also the general issue of whether the manual is documenting this 
particular installation of GCC, or GCC in general.  So far it has been 
documenting GCC in general (for example, unconditionally including 
documentation of command-line options for all targets) - and given that 
people will commonly be reading the manuals on gcc.gnu.org or some manual 
other than the one with their installation, at least there it seems 
appropriate for the manual to say that the default depends on a particular 
configure option (cross-reference to the installation manual where all 
configure options need to be documented - this patch appears to be missing 
that documentation for the new option) rather than giving an individual 
value.  Maybe there should be a single section in the manual describing 
things about how this copy of GCC was configured (or saying it is a 
generic manual in the case of the copies on gcc.gnu.org).

The assembler manual has support for documenting only selected features, 
but the default (and so probably the only case that is normally used and 
is not bitrotten) is a generic manual.

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/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.