* [build, driver] RFC: Support compressed debug sections @ 2013-04-11 12:36 Rainer Orth 2013-04-11 12:36 ` Andi Kleen 2013-04-26 22:43 ` Joseph S. Myers 0 siblings, 2 replies; 25+ messages in thread From: Rainer Orth @ 2013-04-11 12:36 UTC (permalink / raw) To: gcc-patches; +Cc: Paolo Bonzini, Joseph S. Myers [-- Attachment #1: Type: text/plain, Size: 1856 bytes --] There's some interest inside Oracle to support compressed debug sections inside their toolchain, both on Solaris and Linux. So far, there's the GNU style supported by gas, gld, gold, and gdb, which mangles section names (.debug_* -> .zdebug_*), but consultation with the Solaris linker engineers resulted in a different style, now (almost) approved for the ELF gABI. The final proposal can be found here: https://groups.google.com/forum/#!msg/generic-abi/dBOS1H47Q64/Fm_Jh9vOlG8J I've now started to implement this for gcc and probably other parts of the GNU toolchain. This patch proposes to add a -gz[=none|zlib|zlib-gnu] option to gcc, enabling (or disabling) compressed debug sections in either format, and passing the necessary options to assembler and/or linker. It probably has rough edges since this is the first time I've been dealing with the option handling machinery, and may or may not be appropriate for approval at this time. I'm asking for both comments on the general approach and specific review comments. So far, the patch has been tested on i386-pc-solaris2.11 with gas 2.23.2 and a version of the Solaris linker that supports -z compress-debug-sections. Rainer 2013-04-10 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> * configure.ac (gcc_cv_as_compress_debug): Check for assembler compressed debug support. (gcc_cv_ld_compress_debug): Check for linker compressed debug support. * configure: Regenerate. * config.in: Regenerate. * common.opt (gz, gz=): New options. * gcc.c (LINK_COMPRESS_DEBUG_SPEC, ASM_COMPRESS_DEBUG_SPEC): Define. (LINK_COMMAND_SPEC): Invoke LINK_COMPRESS_DEBUG_SPEC. (asm_options): Invoke ASM_COMPRESS_DEBUG_SPEC. * opts.c (common_handle_option): Handle OPT_gz, OPT_gz_. * doc/invoke.texi (Option Summary, Debugging Options): Add -gz[=type]. (Debugging Options): Document -gz[=type]. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: compress-debug-sections.patch --] [-- Type: text/x-patch, Size: 8912 bytes --] # HG changeset patch # Parent 6d495f6205ff6ab3888d907d7891cce8f7593878 Enable --compress-debug-sections diff --git a/gcc/common.opt b/gcc/common.opt --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2375,6 +2375,14 @@ gxcoff+ Common JoinedOrMissing Negative(gcoff) Generate debug information in extended XCOFF format +gz +Common Driver +Generate compressed debug sections + +gz= +Common Driver JoinedOrMissing +-gz=<format> Generate compressed debug sections in format <format> + h Driver Joined Separate diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -4261,6 +4261,27 @@ if test x"$insn" != x; then [Define if your assembler supports the --debug-prefix-map option.])]) fi +gcc_GAS_CHECK_FEATURE([compressed debug sections], + gcc_cv_as_compress_debug,, [--compress-debug-sections],, + [# gas compiled without zlib cannot compress debug sections and warns + # about it, but still exits successfully. So check for this. + if AC_TRY_COMMAND([$gcc_cv_as --compress-debug-sections -o conftest.o conftest.s 2>&1 | grep -i warning > /dev/null]) + then + gcc_cv_as_compress_debug=0 + else + gcc_cv_as_compress_debug=1 + gcc_cv_as_compress_debug_option="--compress-debug-sections" + gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections" + # FIXME: Future gas versions will support ELF gABI style via + # --compress-debug-sections[=type]. + fi]) +AC_DEFINE_UNQUOTED(HAVE_AS_COMPRESS_DEBUG, $gcc_cv_as_compress_debug, +[Define to the level of your assembler's compressed debug section support.]) +AC_DEFINE_UNQUOTED(AS_COMPRESS_DEBUG_OPTION, "$gcc_cv_as_compress_debug_option", +[Define to the assembler option to enable compressed debug sections.]) +AC_DEFINE_UNQUOTED(AS_NO_COMPRESS_DEBUG_OPTION, "$gcc_cv_as_no_compress_debug_option", +[Define to the assembler option to disable compressed debug sections.]) + gcc_GAS_CHECK_FEATURE([.lcomm with alignment], gcc_cv_as_lcomm_with_alignment, ,, [.lcomm bar,4,16],, @@ -4531,6 +4552,56 @@ if test x$gcc_cv_ld_eh_gc_sections_bug = fi AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections_bug) +# gold/gld support compressed debug sections since binutils 2.19/2.21 +if test $in_tree_ld = yes ; then + gcc_cv_ld_compress_debug=0 + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 19 -o "$gcc_cv_gld_major_version" -gt 2 \ + && test $in_tree_ld_is_elf = yes && test $ld_is_gold = yes; then + gcc_cv_ld_compress_debug=2 + gcc_cv_ld_compress_debug_option="--compress-debug-sections" + elif test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 21 -o "$gcc_cv_gld_major_version" -gt 2 \ + && test $in_tree_ld_is_elf = yes; then + gcc_cv_ld_compress_debug=1 + fi +elif echo "$ld_ver" | grep GNU > /dev/null; then + gcc_cv_ld_compress_debug=1 + if test 0"$ld_date" -lt 20050308; then + if test -n "$ld_date"; then + # If there was date string, but was earlier than 2005-03-08, fail + gcc_cv_ld_compress_debug=0 + elif test "$ld_vers_major" -lt 2; then + gcc_cv_ld_compress_debug=0 + elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then + gcc_cv_ld_compress_debug=0 + fi + fi + if test $ld_is_gold = yes; then + gcc_cv_ld_compress_debug=2 + gcc_cv_ld_compress_debug_option="--compress-debug-sections" + fi +else +changequote(,)dnl + case "${target}" in + *-*-solaris2*) + # Introduced in Solaris 11.2. + if $gcc_cv_ld --help 2>&1 | grep -- '-z compress-debug-sections' > /dev/null; then + gcc_cv_ld_compress_debug=3 + gcc_cv_ld_compress_debug_option="-z compress-debug-sections" + fi + ;; + *) + # Assume linkers other than GNU ld don't support compessed debug + # sections. + gcc_cv_ld_compress_debug=0 + ;; + esac +changequote([,])dnl +fi +AC_DEFINE_UNQUOTED(HAVE_LD_COMPRESS_DEBUG, $gcc_cv_ld_compress_debug, +[Define to the level of your linker's compressed debug section support.]) +AC_DEFINE_UNQUOTED(LD_COMPRESS_DEBUG_OPTION, "$gcc_cv_ld_compress_debug_option", +[Define to the linker option to enable compressed debug sections.]) + # -------- # UNSORTED # -------- diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -337,7 +337,7 @@ Objective-C and Objective-C++ Dialects}. -g -g@var{level} -gtoggle -gcoff -gdwarf-@var{version} @gol -ggdb -grecord-gcc-switches -gno-record-gcc-switches @gol -gstabs -gstabs+ -gstrict-dwarf -gno-strict-dwarf @gol --gvms -gxcoff -gxcoff+ @gol +-gvms -gxcoff -gxcoff+ -gz@r{[}=@var{type}@r{]} @gol -fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol -fdebug-prefix-map=@var{old}=@var{new} @gol -femit-struct-debug-baseonly -femit-struct-debug-reduced @gol @@ -4999,6 +4999,15 @@ DWARF extensions from later standard ver Allow using extensions of later DWARF standard version than selected with @option{-gdwarf-@var{version}}. +@item -gz@r{[}=@var{type}@r{]} +@opindex gz +Produce compressed debug sections in DWARF format (if that is +supported). If @var{type} is not given, the default type depends on the +capabilities of the assembler and linker used. @var{type} may be one of +@option{none} (don't compress debug sections), @option{zlib} (use zlib +compression in ELF gABI format), or @option{zlib-gnu} (use zlib +compression in tradition GNU format). + @item -gvms @opindex gvms Produce debugging information in Alpha/VMS debug format (if that is diff --git a/gcc/gcc.c b/gcc/gcc.c --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -586,6 +586,31 @@ proper position among the other output f #define LIBTSAN_EARLY_SPEC "" #endif +/* Linker options for compressed debug sections. */ +#if HAVE_LD_COMPRESS_DEBUG == 0 +/* No linker support. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz*:%e-gz is not supported in this configuration}" +#elif HAVE_LD_COMPRESS_DEBUG == 1 +/* GNU style, GNU ld options. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib-gnu:}" \ + " %{gz=none:%e-gz=none is not supported in this configuration}" \ + " %{gz=zlib:%e-gz=zlib is not supported in this configuration}" +#elif HAVE_LD_COMPRESS_DEBUG == 2 +/* GNU style, GNU gold options. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib-gnu:" LD_COMPRESS_DEBUG_OPTION "=zlib}" \ + " %{gz=none:" LD_COMPRESS_DEBUG_OPTION "=none}" \ + " %{gz=zlib:%e-gz=zlib is not supported in this configuration}" +#else +/* ELF gABI style. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib:" LD_COMPRESS_DEBUG_OPTION "=zlib}" \ + " %{gz=none:" LD_COMPRESS_DEBUG_OPTION "=none}" \ + " %{gz=zlib-gnu:" LD_COMPRESS_DEBUG_OPTION "=zlib-gnu}" +#endif + /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is included. */ #ifndef LIBGCC_SPEC @@ -620,6 +645,25 @@ proper position among the other output f #define ASM_MAP "" #endif +/* Assembler options for compressed debug sections. */ +#if HAVE_AS_COMPRESS_DEBUG == 0 +/* No assembler support. */ +#define ASM_COMPRESS_DEBUG_SPEC \ + " %{gz*:%e-gz is not supported in this configuration}" +#elif HAVE_AS_COMPRESS_DEBUG == 1 +/* GNU style, GNU as options. */ +#define ASM_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib-gnu:" AS_COMPRESS_DEBUG_OPTION "}" \ + " %{gz=none:" AS_NO_COMPRESS_DEBUG_OPTION "}" \ + " %{gz=zlib:%e-gz=zlib is not supported in this configuration}" +#else +/* ELF gABI style. */ +#define ASM_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib:" AS_COMPRESS_DEBUG_OPTION "=zlib}" \ + " %{gz=none:" AS_COMPRESS_DEBUG_OPTION "=none}" \ + " %{gz=zlib-gnu:" AS_COMPRESS_DEBUG_OPTION "=zlib-gnu}" +#endif + /* Define ASM_DEBUG_SPEC to be a spec suitable for translating '-g' to the assembler. */ #ifndef ASM_DEBUG_SPEC @@ -737,8 +781,8 @@ proper position among the other output f LINK_PLUGIN_SPEC \ "%{flto|flto=*:%<fcompare-debug*} \ %{flto} %{flto=*} %l " LINK_PIE_SPEC \ - "%{fuse-ld=*:-fuse-ld=%*}\ - %X %{o*} %{e*} %{N} %{n} %{r}\ + "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ + "%X %{o*} %{e*} %{N} %{n} %{r}\ %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}}\ %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\ %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\ @@ -865,6 +909,7 @@ static const char *asm_options = to the assembler equivalents. */ "%{v} %{w:-W} %{I*} " #endif +ASM_COMPRESS_DEBUG_SPEC "%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}"; static const char *invoke_as = diff --git a/gcc/opts.c b/gcc/opts.c --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1732,6 +1732,11 @@ common_handle_option (struct gcc_options loc); break; + case OPT_gz: + case OPT_gz_: + /* Handled completely via specs. */ + break; + case OPT_pedantic_errors: dc->pedantic_errors = 1; control_warning_option (OPT_Wpedantic, DK_ERROR, value, [-- Attachment #3: Type: text/plain, Size: 143 bytes --] -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2013-04-11 12:36 [build, driver] RFC: Support compressed debug sections Rainer Orth @ 2013-04-11 12:36 ` Andi Kleen 2013-04-11 12:54 ` Rainer Orth 2013-04-26 22:43 ` Joseph S. Myers 1 sibling, 1 reply; 25+ messages in thread From: Andi Kleen @ 2013-04-11 12:36 UTC (permalink / raw) To: Rainer Orth; +Cc: gcc-patches, Paolo Bonzini, Joseph S. Myers Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes: > There's some interest inside Oracle to support compressed debug sections > inside their toolchain, both on Solaris and Linux. So far, there's the > GNU style supported by gas, gld, gold, and gdb, which mangles section > names (.debug_* -> .zdebug_*), but consultation with the Solaris linker > engineers resulted in a different style, now (almost) approved for the > ELF gABI. The final proposal can be found here: > > https://groups.google.com/forum/#!msg/generic-abi/dBOS1H47Q64/Fm_Jh9vOlG8J None of the messages explains why the new format is better than the existing one. For GNU this seems to have zero value. -Andi -- ak@linux.intel.com -- Speaking for myself only ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2013-04-11 12:36 ` Andi Kleen @ 2013-04-11 12:54 ` Rainer Orth 0 siblings, 0 replies; 25+ messages in thread From: Rainer Orth @ 2013-04-11 12:54 UTC (permalink / raw) To: Andi Kleen; +Cc: gcc-patches, Paolo Bonzini, Joseph S. Myers Andi Kleen <andi@firstfloor.org> writes: > Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes: > >> There's some interest inside Oracle to support compressed debug sections >> inside their toolchain, both on Solaris and Linux. So far, there's the >> GNU style supported by gas, gld, gold, and gdb, which mangles section >> names (.debug_* -> .zdebug_*), but consultation with the Solaris linker >> engineers resulted in a different style, now (almost) approved for the >> ELF gABI. The final proposal can be found here: >> >> https://groups.google.com/forum/#!msg/generic-abi/dBOS1H47Q64/Fm_Jh9vOlG8J > > None of the messages explains why the new format is better than the > existing one. For GNU this seems to have zero value. It's at the beginning of the first message. Besides, if you look at binutils sources with several large tables mapping .debug_* to .zdebug_* sections, there's lots of complexitiy involved in the traditional format and the name mangling involved. Anyway, this is now part of the gABI, and the patch at hand also works with the old GNU style (-gz=zlib-gnu), so it has value even when the gABI style isn't supported. Having users invoke gcc -Wa,--compress-debug-sections -Wl,--compress-debug-sections instead of -gz doesn't seem to be a good user interface to me. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2013-04-11 12:36 [build, driver] RFC: Support compressed debug sections Rainer Orth 2013-04-11 12:36 ` Andi Kleen @ 2013-04-26 22:43 ` Joseph S. Myers 2013-04-30 15:06 ` Rainer Orth 1 sibling, 1 reply; 25+ messages in thread From: Joseph S. Myers @ 2013-04-26 22:43 UTC (permalink / raw) To: Rainer Orth; +Cc: gcc-patches, Paolo Bonzini On Thu, 11 Apr 2013, Rainer Orth wrote: > +gz= > +Common Driver JoinedOrMissing > +-gz=<format> Generate compressed debug sections in format <format> Although handled entirely in specs, I think it's best to use the Enum .opt facility to list the valid arguments to this option, so the option handling machinery can properly detect invalid arguments. (And, since an empty argument isn't meaningful, use Joined rather than JoinedOrMissing.) The integer values assigned to each valid argument string are of course arbitrary since nothing will use them. > +@item -gz@r{[}=@var{type}@r{]} > +@opindex gz > +Produce compressed debug sections in DWARF format (if that is > +supported). If @var{type} is not given, the default type depends on the > +capabilities of the assembler and linker used. @var{type} may be one of > +@option{none} (don't compress debug sections), @option{zlib} (use zlib > +compression in ELF gABI format), or @option{zlib-gnu} (use zlib > +compression in tradition GNU format). "traditional". -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2013-04-26 22:43 ` Joseph S. Myers @ 2013-04-30 15:06 ` Rainer Orth 2013-05-03 20:01 ` Joseph S. Myers 0 siblings, 1 reply; 25+ messages in thread From: Rainer Orth @ 2013-04-30 15:06 UTC (permalink / raw) To: Joseph S. Myers; +Cc: gcc-patches, Paolo Bonzini [-- Attachment #1: Type: text/plain, Size: 3068 bytes --] "Joseph S. Myers" <joseph@codesourcery.com> writes: > On Thu, 11 Apr 2013, Rainer Orth wrote: > >> +gz= >> +Common Driver JoinedOrMissing >> +-gz=<format> Generate compressed debug sections in format <format> > > Although handled entirely in specs, I think it's best to use the Enum .opt > facility to list the valid arguments to this option, so the option > handling machinery can properly detect invalid arguments. (And, since an I already wondered how to do this with specs, but your suggestion worked seamlessly, thanks. > empty argument isn't meaningful, use Joined rather than JoinedOrMissing.) Done. This was a leftover from a failed attempt to handle -gz[=format] in a single clause. > The integer values assigned to each valid argument string are of course > arbitrary since nothing will use them. Right, so I've just used numeric constants. >> +@item -gz@r{[}=@var{type}@r{]} >> +@opindex gz >> +Produce compressed debug sections in DWARF format (if that is >> +supported). If @var{type} is not given, the default type depends on the >> +capabilities of the assembler and linker used. @var{type} may be one of >> +@option{none} (don't compress debug sections), @option{zlib} (use zlib >> +compression in ELF gABI format), or @option{zlib-gnu} (use zlib >> +compression in tradition GNU format). > > "traditional". Fixed. The patch now underwent additonal testing on i386-pc-solaris2.11. The following tools were handled correctly: * Solaris as: not yet capable of generating compressed debug sections. Planned, but command line options not yet known. * GNU as 2.23.1 built without zlib: just warns about --compressed-debug-sections, but exits successfully. * GNU as 2.23.2 with zlib. * Solaris 11.2 ld: no compressed debug support yet. * Test version of Solaris 12/11.2 ld: almost final now, command line option changed to -z compress-sections since the ELF gABI spec allows compresion of any non-allocable section. I may follow this lead for gas/gld/gold, so the default for --compress-debug-sections (zlib-gnu) can remain unchanged, but the --compress-sections default would be zlib, following the gABI. * GNU ld 2.23.2: I hadn't realized that gld can decompress on input, but always produces uncompressed output. * GNU gold 2.23.2: can read and write compressed sections. Ok for mainline now? Thanks. Rainer 2013-04-10 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> * configure.ac (gcc_cv_as_compress_debug): Check for assembler compressed debug support. (gcc_cv_ld_compress_debug): Check for linker compressed debug support. * configure: Regenerate. * config.in: Regenerate. * common.opt (compressed_debug_sections): New enum. (gz, gz=): New options. * gcc.c (LINK_COMPRESS_DEBUG_SPEC, ASM_COMPRESS_DEBUG_SPEC): Define. (LINK_COMMAND_SPEC): Invoke LINK_COMPRESS_DEBUG_SPEC. (asm_options): Invoke ASM_COMPRESS_DEBUG_SPEC. * opts.c (common_handle_option): Handle OPT_gz, OPT_gz_. * doc/invoke.texi (Option Summary, Debugging Options): Add -gz[=type]. (Debugging Options): Document -gz[=type]. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: compress-debug-sections.patch --] [-- Type: text/x-patch, Size: 9593 bytes --] # HG changeset patch # Parent a871a025093e293206f64a1d3b34ac7db53ee187 Enable --compress-debug-sections diff --git a/gcc/common.opt b/gcc/common.opt --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2407,6 +2407,28 @@ gxcoff+ Common JoinedOrMissing Negative(gcoff) Generate debug information in extended XCOFF format +Enum +Name(compressed_debug_sections) Type(int) + +; Since -gz= is completely handled in specs, the values aren't used and we +; assign arbitrary constants. +EnumValue +Enum(compressed_debug_sections) String(none) Value(0) + +EnumValue +Enum(compressed_debug_sections) String(zlib) Value(1) + +EnumValue +Enum(compressed_debug_sections) String(zlib-gnu) Value(2) + +gz +Common Driver +Generate compressed debug sections + +gz= +Common Driver Joined Enum(compressed_debug_sections) +-gz=<format> Generate compressed debug sections in format <format> + h Driver Joined Separate diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -4261,6 +4261,30 @@ if test x"$insn" != x; then [Define if your assembler supports the --debug-prefix-map option.])]) fi +gcc_GAS_CHECK_FEATURE([compressed debug sections], + gcc_cv_as_compress_debug,,,, + [# gas compiled without zlib cannot compress debug sections and warns + # about it, but still exits successfully. So check for this, too. + if $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s 2>&1 | grep -i warning > /dev/null + then + gcc_cv_as_compress_debug=0 + elif $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s > /dev/null 2>&1 + then + gcc_cv_as_compress_debug=1 + gcc_cv_as_compress_debug_option="--compress-debug-sections" + gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections" + else + gcc_cv_as_compress_debug=0 + # FIXME: Future gas versions will support ELF gABI style via + # --compress-debug-sections[=type]. + fi]) +AC_DEFINE_UNQUOTED(HAVE_AS_COMPRESS_DEBUG, $gcc_cv_as_compress_debug, +[Define to the level of your assembler's compressed debug section support.]) +AC_DEFINE_UNQUOTED(AS_COMPRESS_DEBUG_OPTION, "$gcc_cv_as_compress_debug_option", +[Define to the assembler option to enable compressed debug sections.]) +AC_DEFINE_UNQUOTED(AS_NO_COMPRESS_DEBUG_OPTION, "$gcc_cv_as_no_compress_debug_option", +[Define to the assembler option to disable compressed debug sections.]) + gcc_GAS_CHECK_FEATURE([.lcomm with alignment], gcc_cv_as_lcomm_with_alignment, ,, [.lcomm bar,4,16],, @@ -4531,6 +4555,60 @@ if test x$gcc_cv_ld_eh_gc_sections_bug = fi AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections_bug) +AC_MSG_CHECKING(linker for compressed debug sections) +# gold/gld support compressed debug sections since binutils 2.19/2.21 +if test $in_tree_ld = yes ; then + gcc_cv_ld_compress_debug=0 + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 19 -o "$gcc_cv_gld_major_version" -gt 2 \ + && test $in_tree_ld_is_elf = yes && test $ld_is_gold = yes; then + gcc_cv_ld_compress_debug=2 + gcc_cv_ld_compress_debug_option="--compress-debug-sections" + elif test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 21 -o "$gcc_cv_gld_major_version" -gt 2 \ + && test $in_tree_ld_is_elf = yes; then + gcc_cv_ld_compress_debug=1 + fi +elif echo "$ld_ver" | grep GNU > /dev/null; then + gcc_cv_ld_compress_debug=1 + if test 0"$ld_date" -lt 20050308; then + if test -n "$ld_date"; then + # If there was date string, but was earlier than 2005-03-08, fail + gcc_cv_ld_compress_debug=0 + elif test "$ld_vers_major" -lt 2; then + gcc_cv_ld_compress_debug=0 + elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then + gcc_cv_ld_compress_debug=0 + fi + fi + if test $ld_is_gold = yes; then + gcc_cv_ld_compress_debug=2 + gcc_cv_ld_compress_debug_option="--compress-debug-sections" + fi +else +changequote(,)dnl + case "${target}" in + *-*-solaris2*) + # Introduced in Solaris 11.2. + if $gcc_cv_ld --help 2>&1 | grep -- '-z compress-sections' > /dev/null; then + gcc_cv_ld_compress_debug=3 + gcc_cv_ld_compress_debug_option="-z compress-sections" + else + gcc_cv_ld_compress_debug=0 + fi + ;; + *) + # Assume linkers other than GNU ld don't support compessed debug + # sections. + gcc_cv_ld_compress_debug=0 + ;; + esac +changequote([,])dnl +fi +AC_DEFINE_UNQUOTED(HAVE_LD_COMPRESS_DEBUG, $gcc_cv_ld_compress_debug, +[Define to the level of your linker's compressed debug section support.]) +AC_DEFINE_UNQUOTED(LD_COMPRESS_DEBUG_OPTION, "$gcc_cv_ld_compress_debug_option", +[Define to the linker option to enable compressed debug sections.]) +AC_MSG_RESULT($gcc_cv_ld_compress_debug) + # -------- # UNSORTED # -------- diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -338,7 +338,7 @@ Objective-C and Objective-C++ Dialects}. -g -g@var{level} -gtoggle -gcoff -gdwarf-@var{version} @gol -ggdb -grecord-gcc-switches -gno-record-gcc-switches @gol -gstabs -gstabs+ -gstrict-dwarf -gno-strict-dwarf @gol --gvms -gxcoff -gxcoff+ @gol +-gvms -gxcoff -gxcoff+ -gz@r{[}=@var{type}@r{]} @gol -fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol -fdebug-prefix-map=@var{old}=@var{new} @gol -femit-struct-debug-baseonly -femit-struct-debug-reduced @gol @@ -5072,6 +5072,15 @@ DWARF extensions from later standard ver Allow using extensions of later DWARF standard version than selected with @option{-gdwarf-@var{version}}. +@item -gz@r{[}=@var{type}@r{]} +@opindex gz +Produce compressed debug sections in DWARF format (if that is +supported). If @var{type} is not given, the default type depends on the +capabilities of the assembler and linker used. @var{type} may be one of +@option{none} (don't compress debug sections), @option{zlib} (use zlib +compression in ELF gABI format), or @option{zlib-gnu} (use zlib +compression in traditional GNU format). + @item -gvms @opindex gvms Produce debugging information in Alpha/VMS debug format (if that is diff --git a/gcc/gcc.c b/gcc/gcc.c --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -586,6 +586,32 @@ proper position among the other output f #define LIBTSAN_EARLY_SPEC "" #endif +/* Linker options for compressed debug sections. */ +#if HAVE_LD_COMPRESS_DEBUG == 0 +/* No linker support. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz*:%e-gz is not supported in this configuration}" +#elif HAVE_LD_COMPRESS_DEBUG == 1 +/* GNU style on input, GNU ld options. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz:%e-gz is not supported in this configuration}" \ + " %{gz=none:}" \ + " %{gz=zlib:%e-gz=zlib is not supported in this configuration}" \ + " %{gz=zlib-gnu:%e-gz=zlib-gnu is not supported in this configuration}" +#elif HAVE_LD_COMPRESS_DEBUG == 2 +/* GNU style, GNU gold options. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib-gnu:" LD_COMPRESS_DEBUG_OPTION "=zlib}" \ + " %{gz=none:" LD_COMPRESS_DEBUG_OPTION "=none}" \ + " %{gz=zlib:%e-gz=zlib is not supported in this configuration}" +#else +/* ELF gABI style. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib:" LD_COMPRESS_DEBUG_OPTION "=zlib}" \ + " %{gz=none:" LD_COMPRESS_DEBUG_OPTION "=none}" \ + " %{gz=zlib-gnu:" LD_COMPRESS_DEBUG_OPTION "=zlib-gnu}" +#endif + /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is included. */ #ifndef LIBGCC_SPEC @@ -620,6 +646,25 @@ proper position among the other output f #define ASM_MAP "" #endif +/* Assembler options for compressed debug sections. */ +#if HAVE_AS_COMPRESS_DEBUG == 0 +/* No assembler support. */ +#define ASM_COMPRESS_DEBUG_SPEC \ + " %{gz*:%e-gz is not supported in this configuration}" +#elif HAVE_AS_COMPRESS_DEBUG == 1 +/* GNU style, GNU as options. */ +#define ASM_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib-gnu:" AS_COMPRESS_DEBUG_OPTION "}" \ + " %{gz=none:" AS_NO_COMPRESS_DEBUG_OPTION "}" \ + " %{gz=zlib:%e-gz=zlib is not supported in this configuration}" +#else +/* ELF gABI style. */ +#define ASM_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib:" AS_COMPRESS_DEBUG_OPTION "=zlib}" \ + " %{gz=none:" AS_COMPRESS_DEBUG_OPTION "=none}" \ + " %{gz=zlib-gnu:" AS_COMPRESS_DEBUG_OPTION "=zlib-gnu}" +#endif + /* Define ASM_DEBUG_SPEC to be a spec suitable for translating '-g' to the assembler. */ #ifndef ASM_DEBUG_SPEC @@ -737,8 +782,8 @@ proper position among the other output f LINK_PLUGIN_SPEC \ "%{flto|flto=*:%<fcompare-debug*} \ %{flto} %{flto=*} %l " LINK_PIE_SPEC \ - "%{fuse-ld=*:-fuse-ld=%*}\ - %X %{o*} %{e*} %{N} %{n} %{r}\ + "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ + "%X %{o*} %{e*} %{N} %{n} %{r}\ %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}}\ %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\ %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\ @@ -865,6 +910,7 @@ static const char *asm_options = to the assembler equivalents. */ "%{v} %{w:-W} %{I*} " #endif +ASM_COMPRESS_DEBUG_SPEC "%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}"; static const char *invoke_as = diff --git a/gcc/opts.c b/gcc/opts.c --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1750,6 +1750,11 @@ common_handle_option (struct gcc_options loc); break; + case OPT_gz: + case OPT_gz_: + /* Handled completely via specs. */ + break; + case OPT_pedantic_errors: dc->pedantic_errors = 1; control_warning_option (OPT_Wpedantic, DK_ERROR, value, [-- Attachment #3: Type: text/plain, Size: 143 bytes --] -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2013-04-30 15:06 ` Rainer Orth @ 2013-05-03 20:01 ` Joseph S. Myers 2013-05-04 21:20 ` Rainer Orth 0 siblings, 1 reply; 25+ messages in thread From: Joseph S. Myers @ 2013-05-03 20:01 UTC (permalink / raw) To: Rainer Orth; +Cc: gcc-patches, Paolo Bonzini On Tue, 30 Apr 2013, Rainer Orth wrote: > * gcc.c (LINK_COMPRESS_DEBUG_SPEC, ASM_COMPRESS_DEBUG_SPEC): > Define. > (LINK_COMMAND_SPEC): Invoke LINK_COMPRESS_DEBUG_SPEC. > (asm_options): Invoke ASM_COMPRESS_DEBUG_SPEC. Note that there are separate copies of LINK_COMMAND_SPEC in darwin.h and i386/djgpp.h, which maybe should include the new spec. It's not clear to me from the documentation added by this patch whether users are meant to specify their -gz options when compiling, when linking, or both - and whether there might be cases when such an option is accepted for one of compiling and linking but not the other (which would be especially confusing). -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2013-05-03 20:01 ` Joseph S. Myers @ 2013-05-04 21:20 ` Rainer Orth 2013-05-05 14:15 ` Joseph S. Myers 0 siblings, 1 reply; 25+ messages in thread From: Rainer Orth @ 2013-05-04 21:20 UTC (permalink / raw) To: Joseph S. Myers; +Cc: gcc-patches, Paolo Bonzini [-- Attachment #1: Type: text/plain, Size: 1364 bytes --] "Joseph S. Myers" <joseph@codesourcery.com> writes: > On Tue, 30 Apr 2013, Rainer Orth wrote: > >> * gcc.c (LINK_COMPRESS_DEBUG_SPEC, ASM_COMPRESS_DEBUG_SPEC): >> Define. >> (LINK_COMMAND_SPEC): Invoke LINK_COMPRESS_DEBUG_SPEC. >> (asm_options): Invoke ASM_COMPRESS_DEBUG_SPEC. > > Note that there are separate copies of LINK_COMMAND_SPEC in darwin.h and > i386/djgpp.h, which maybe should include the new spec. I hadn't thought about that. Here's what I found: * Darwin is Mach-O, but current gas supports DWARF-in-Mach-O. Unfortunately, current gcc mainline only supports Apple as: i386/darwin.h hardcodes as-only options in ASM_SPEC, which causes gas to barf. If you manually invoke gas on gcc -gdwarf output, you get compressed debug sections, though objdump cannot handle them. * DJGPP is COFF, but again gas seems to support DWARF. Unfortunately, current gcc mainline doesn't even build: gcc/config/i386/i386.c: In function 'void ix86_code_end()': gcc/config/i386/i386.c:8667: error: 'ASM_DECLARE_FUNCTION_NAME' was not declared in this scope I didn't look further from here. Anyway, I tried a i386-pc-solaris2.11 x i686-pc-darwin build with the following patch to check it doesn't break the build: * config/darwin.h (LINK_COMMAND_SPEC_A): Invoke LINK_COMPRESS_DEBUG_SPEC. * config/i386/djgpp.h (LINK_COMMAND_SPEC): Likewise. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: dd.patch --] [-- Type: text/x-patch, Size: 948 bytes --] diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -171,7 +171,8 @@ extern GTY(()) int darwin_ms_struct; LINK_PLUGIN_SPEC \ "%{flto*:%<fcompare-debug*} \ %{flto*} \ - %l %X %{s} %{t} %{Z} %{u*} \ + %l " LINK_COMPRESS_DEBUG_SPEC \ + "%X %{s} %{t} %{Z} %{u*} \ %{e*} %{r} \ %{o*}%{!o:-o a.out} \ %{!nostdlib:%{!nostartfiles:%S}} \ diff --git a/gcc/config/i386/djgpp.h b/gcc/config/i386/djgpp.h --- a/gcc/config/i386/djgpp.h +++ b/gcc/config/i386/djgpp.h @@ -80,7 +80,8 @@ along with GCC; see the file COPYING3. #undef LINK_COMMAND_SPEC #define LINK_COMMAND_SPEC \ "%{!fsyntax-only: \ -%{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{e*} %{N} %{n} \ +%{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l " LINK_COMPRESS_DEBUG_SPEC \ +"%X %{o*} %{e*} %{N} %{n} \ \t%{r} %{s} %{t} %{u*} %{z} %{Z}\ \t%{!nostdlib:%{!nostartfiles:%S}}\ \t%{static:} %{L*} %D %o\ [-- Attachment #3: Type: text/plain, Size: 2343 bytes --] Especially darwin.h LINK_COMMAND_SPEC_A is a total mess: it's a copy of gcc.c LINK_COMMAND_SPEC with various changes not carried forward and other parts done in a slightly different syntax for no apparent reason. I'm pretty sure the two could be merged to avoid problems from duplication in the future, but I'll leave that to the Darwin maintainers. I can include the snippet above for symmetry, if only to reject -gz as on ELF targets without the toolchain support, if you prefer. > It's not clear to me from the documentation added by this patch whether > users are meant to specify their -gz options when compiling, when linking, > or both - and whether there might be cases when such an option is accepted > for one of compiling and linking but not the other (which would be > especially confusing). The goal is to have -gz work for both compilation and linking, but unfortunately, the current situation very much depends on both the toolchain used and your intentions. The following matrix shows read and write support in the GNU and Solaris toolchains. For the latter, full support for zlib and zlib-gnu formats is being worked on, with ld already there. GNU Solaris gas gld gold gdb as ld dbx w r w r w r w r w r none x x x x x x x x x x zlib-gnu x x x x x x x zlib x x I plan to add zlib support first to gas and gdb, eventually to gld (which also means adding support for compression on output, though I had a very hard time finding my way through bfd and gld in the past), but will rely on Cary Coutant and/or Ian, who were involved in the zlib/ELF gABI format design, to handle gold. Right now, the gas/gold combination supports -gz just fine (producing the zlib-gnu format), while gas/gld only support -gz in the assemble step. I know this is highly undesirable, but whether or not it's acceptable depends on your goals: * If you mean to trade compilation/assembly speed for disk usage, -gz for compilation only is ok. * If your primary goal is space savings for executables and shared objects while still allowing debugability, you need to use gold for -gz at link time to work. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2013-05-04 21:20 ` Rainer Orth @ 2013-05-05 14:15 ` Joseph S. Myers 2013-05-15 15:38 ` Rainer Orth 2014-05-22 11:45 ` Rainer Orth 0 siblings, 2 replies; 25+ messages in thread From: Joseph S. Myers @ 2013-05-05 14:15 UTC (permalink / raw) To: Rainer Orth; +Cc: gcc-patches, Paolo Bonzini I still have no idea from your answer how a user is meant to know whether to use the option when compiling, linking or both, which is what needs to be clear from invoke.texi. What does it mean for the option to be supported for compiling but not linking? What in that case will the linker do with compressed debug sections on input? Combine them in some way, good or bad? Uncompress them? Likewise, for it to be supported for linking but not compiling? Will the linker then compress the uncompressed sections it receives on input? I think it would be better if the option semantics are more like "if you pass the same option when both compiling and linking, the linked output will have the sections appropriately compressed as specified by the option, whether or not the individual .o files do" - and if this can't be supported with the tools being used, don't allow the option. -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2013-05-05 14:15 ` Joseph S. Myers @ 2013-05-15 15:38 ` Rainer Orth 2014-05-22 11:45 ` Rainer Orth 1 sibling, 0 replies; 25+ messages in thread From: Rainer Orth @ 2013-05-15 15:38 UTC (permalink / raw) To: Joseph S. Myers; +Cc: gcc-patches, Paolo Bonzini Hi Joseph, > I still have no idea from your answer how a user is meant to know whether > to use the option when compiling, linking or both, which is what needs to > be clear from invoke.texi. > > What does it mean for the option to be supported for compiling but not > linking? What in that case will the linker do with compressed debug > sections on input? Combine them in some way, good or bad? Uncompress > them? a linker that doesn't understand compressed debug sections will probably combine them in a useless way. If, like gld, it can read but not write them, they will be written in uncompressed form. > Likewise, for it to be supported for linking but not compiling? Will the > linker then compress the uncompressed sections it receives on input? Yes, that will work in all cases. > I think it would be better if the option semantics are more like "if you > pass the same option when both compiling and linking, the linked output > will have the sections appropriately compressed as specified by the > option, whether or not the individual .o files do" - and if this can't be > supported with the tools being used, don't allow the option. That's certainly an option, as in the following table (taking the zlib-gnu format as an example, but omitting hypothetical linkers that can write but not read compressed debug sections): assembler linker action example w r w - - - reject as/ld - x - reject, useless as/gld - x x ok, warn about no-op as -gz? as/gold x - - reject, harmful gas/ld x x - reject, useless gas/gld x x x ok gas/gold The only problem I see is that for an assembler not supporting compression -gz would be a silent no-op. I'd rather warn about this instead, but still accept it so you can both compile and link with -gz. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2013-05-05 14:15 ` Joseph S. Myers 2013-05-15 15:38 ` Rainer Orth @ 2014-05-22 11:45 ` Rainer Orth 2014-05-22 15:49 ` Joseph S. Myers 1 sibling, 1 reply; 25+ messages in thread From: Rainer Orth @ 2014-05-22 11:45 UTC (permalink / raw) To: Joseph S. Myers; +Cc: gcc-patches, Paolo Bonzini [-- Attachment #1: Type: text/plain, Size: 2781 bytes --] "Joseph S. Myers" <joseph@codesourcery.com> writes: [Sorry for dropping the ball on this for so long.] > I still have no idea from your answer how a user is meant to know whether > to use the option when compiling, linking or both, which is what needs to > be clear from invoke.texi. > > What does it mean for the option to be supported for compiling but not > linking? What in that case will the linker do with compressed debug > sections on input? Combine them in some way, good or bad? Uncompress > them? > > Likewise, for it to be supported for linking but not compiling? Will the > linker then compress the uncompressed sections it receives on input? > > I think it would be better if the option semantics are more like "if you > pass the same option when both compiling and linking, the linked output > will have the sections appropriately compressed as specified by the > option, whether or not the individual .o files do" - and if this can't be > supported with the tools being used, don't allow the option. Ok, makes sense: although it may lose some of the capabilities of the toolchain (like gas/gld, where gas can write compressed debug, gld can read, but not write it), the user experience is certainly better. I thought about warning for an assembler not supporting compressed debug when -gz is passed, but that would only produce noise. So here's the revised patch. Tested on * i386-pc-solaris2.10 with gas/ld: gas could write but ld cannot read compressed debug, so reject all -gz options. * i386-pc-solaris2.11 with gas/ld: gas can write zlib-gnu format, ld can read and write all of them * x86_64-unknown-linux-gnu with gas/gold: gas can write, gold can read and write zlib-gnu format In every case, -gz and -gz=<format> behaved as expected as checked by inspecting the assembler and linker invocations and the resulting object files and executables. Ok for mainline now? Thanks. Rainer 2013-04-10 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> gcc: * configure.ac (gcc_cv_as_compress_debug): Check for assembler compressed debug support. (gcc_cv_ld_compress_debug): Check for linker compressed debug support. * configure: Regenerate. * config.in: Regenerate. * common.opt (compressed_debug_sections): New enum. (gz, gz=): New options. * gcc.c (LINK_COMPRESS_DEBUG_SPEC, ASM_COMPRESS_DEBUG_SPEC): Define. (LINK_COMMAND_SPEC): Invoke LINK_COMPRESS_DEBUG_SPEC. (asm_options): Invoke ASM_COMPRESS_DEBUG_SPEC. * config/darwin.h (LINK_COMMAND_SPEC_A): Invoke LINK_COMPRESS_DEBUG_SPEC. * config/i386/djgpp.h (LINK_COMMAND_SPEC): Likewise. * opts.c (common_handle_option): Handle OPT_gz, OPT_gz_. * doc/invoke.texi (Option Summary, Debugging Options): Add -gz[=type]. (Debugging Options): Document -gz[=type]. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: compress-debug-sections.patch --] [-- Type: text/x-patch, Size: 11066 bytes --] # HG changeset patch # Parent 461334df01269c96bf9f041380cfc901c395307d Enable --compress-debug-sections diff --git a/gcc/common.opt b/gcc/common.opt --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2518,6 +2518,28 @@ gxcoff+ Common JoinedOrMissing Negative(gcoff) Generate debug information in extended XCOFF format +Enum +Name(compressed_debug_sections) Type(int) + +; Since -gz= is completely handled in specs, the values aren't used and we +; assign arbitrary constants. +EnumValue +Enum(compressed_debug_sections) String(none) Value(0) + +EnumValue +Enum(compressed_debug_sections) String(zlib) Value(1) + +EnumValue +Enum(compressed_debug_sections) String(zlib-gnu) Value(2) + +gz +Common Driver +Generate compressed debug sections + +gz= +Common Driver Joined Enum(compressed_debug_sections) +-gz=<format> Generate compressed debug sections in format <format> + h Driver Joined Separate diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -171,7 +171,8 @@ extern GTY(()) int darwin_ms_struct; LINK_PLUGIN_SPEC \ "%{flto*:%<fcompare-debug*} \ %{flto*} \ - %l %X %{s} %{t} %{Z} %{u*} \ + %l " LINK_COMPRESS_DEBUG_SPEC \ + "%X %{s} %{t} %{Z} %{u*} \ %{e*} %{r} \ %{o*}%{!o:-o a.out} \ %{!nostdlib:%{!nostartfiles:%S}} \ diff --git a/gcc/config/i386/djgpp.h b/gcc/config/i386/djgpp.h --- a/gcc/config/i386/djgpp.h +++ b/gcc/config/i386/djgpp.h @@ -80,7 +80,8 @@ along with GCC; see the file COPYING3. #undef LINK_COMMAND_SPEC #define LINK_COMMAND_SPEC \ "%{!fsyntax-only: \ -%{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{e*} %{N} %{n} \ +%{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l " LINK_COMPRESS_DEBUG_SPEC \ +"%X %{o*} %{e*} %{N} %{n} \ \t%{r} %{s} %{t} %{u*} %{z} %{Z}\ \t%{!nostdlib:%{!nostartfiles:%S}}\ \t%{static:} %{L*} %D %o\ diff --git a/gcc/configure.ac b/gcc/configure.ac --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -4370,6 +4370,30 @@ if test x"$insn" != x; then [Define if your assembler supports the --debug-prefix-map option.])]) fi +gcc_GAS_CHECK_FEATURE([compressed debug sections], + gcc_cv_as_compress_debug,,[--compress-debug-sections],, + [# gas compiled without zlib cannot compress debug sections and warns + # about it, but still exits successfully. So check for this, too. + if $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s 2>&1 | grep -i warning > /dev/null + then + gcc_cv_as_compress_debug=0 + elif $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s > /dev/null 2>&1 + then + gcc_cv_as_compress_debug=1 + gcc_cv_as_compress_debug_option="--compress-debug-sections" + gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections" + else + gcc_cv_as_compress_debug=0 + # FIXME: Future gas versions will support ELF gABI style via + # --compress-debug-sections[=type]. + fi]) +AC_DEFINE_UNQUOTED(HAVE_AS_COMPRESS_DEBUG, $gcc_cv_as_compress_debug, +[Define to the level of your assembler's compressed debug section support.]) +AC_DEFINE_UNQUOTED(AS_COMPRESS_DEBUG_OPTION, "$gcc_cv_as_compress_debug_option", +[Define to the assembler option to enable compressed debug sections.]) +AC_DEFINE_UNQUOTED(AS_NO_COMPRESS_DEBUG_OPTION, "$gcc_cv_as_no_compress_debug_option", +[Define to the assembler option to disable compressed debug sections.]) + gcc_GAS_CHECK_FEATURE([.lcomm with alignment], gcc_cv_as_lcomm_with_alignment, ,, [.lcomm bar,4,16],, @@ -4676,6 +4700,60 @@ if test x$gcc_cv_ld_eh_gc_sections_bug = fi AC_MSG_RESULT($gcc_cv_ld_eh_gc_sections_bug) +AC_MSG_CHECKING(linker for compressed debug sections) +# gold/gld support compressed debug sections since binutils 2.19/2.21 +if test $in_tree_ld = yes ; then + gcc_cv_ld_compress_debug=0 + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 19 -o "$gcc_cv_gld_major_version" -gt 2 \ + && test $in_tree_ld_is_elf = yes && test $ld_is_gold = yes; then + gcc_cv_ld_compress_debug=2 + gcc_cv_ld_compress_debug_option="--compress-debug-sections" + elif test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 21 -o "$gcc_cv_gld_major_version" -gt 2 \ + && test $in_tree_ld_is_elf = yes; then + gcc_cv_ld_compress_debug=1 + fi +elif echo "$ld_ver" | grep GNU > /dev/null; then + gcc_cv_ld_compress_debug=1 + if test 0"$ld_date" -lt 20050308; then + if test -n "$ld_date"; then + # If there was date string, but was earlier than 2005-03-08, fail + gcc_cv_ld_compress_debug=0 + elif test "$ld_vers_major" -lt 2; then + gcc_cv_ld_compress_debug=0 + elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then + gcc_cv_ld_compress_debug=0 + fi + fi + if test $ld_is_gold = yes; then + gcc_cv_ld_compress_debug=2 + gcc_cv_ld_compress_debug_option="--compress-debug-sections" + fi +else +changequote(,)dnl + case "${target}" in + *-*-solaris2*) + # Introduced in Solaris 11.2. + if $gcc_cv_ld --help 2>&1 | grep -- '-z compress-sections' > /dev/null; then + gcc_cv_ld_compress_debug=3 + gcc_cv_ld_compress_debug_option="-z compress-sections" + else + gcc_cv_ld_compress_debug=0 + fi + ;; + *) + # Assume linkers other than GNU ld don't support compessed debug + # sections. + gcc_cv_ld_compress_debug=0 + ;; + esac +changequote([,])dnl +fi +AC_DEFINE_UNQUOTED(HAVE_LD_COMPRESS_DEBUG, $gcc_cv_ld_compress_debug, +[Define to the level of your linker's compressed debug section support.]) +AC_DEFINE_UNQUOTED(LD_COMPRESS_DEBUG_OPTION, "$gcc_cv_ld_compress_debug_option", +[Define to the linker option to enable compressed debug sections.]) +AC_MSG_RESULT($gcc_cv_ld_compress_debug) + # -------- # UNSORTED # -------- diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -344,7 +344,7 @@ Objective-C and Objective-C++ Dialects}. -g -g@var{level} -gtoggle -gcoff -gdwarf-@var{version} @gol -ggdb -grecord-gcc-switches -gno-record-gcc-switches @gol -gstabs -gstabs+ -gstrict-dwarf -gno-strict-dwarf @gol --gvms -gxcoff -gxcoff+ @gol +-gvms -gxcoff -gxcoff+ -gz@r{[}=@var{type}@r{]} @gol -fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol -fdebug-prefix-map=@var{old}=@var{new} @gol -femit-struct-debug-baseonly -femit-struct-debug-reduced @gol @@ -5274,6 +5274,18 @@ DWARF extensions from later standard ver Allow using extensions of later DWARF standard version than selected with @option{-gdwarf-@var{version}}. +@item -gz@r{[}=@var{type}@r{]} +@opindex gz +Produce compressed debug sections in DWARF format, if that is supported. +If @var{type} is not given, the default type depends on the capabilities +of the assembler and linker used. If the linker doesn't support writing +compressed debug sections, the option is rejected. Otherwise, if the +assembler doesn't support them, @option{-gz} is silently ignored when +producing object files. @var{type} may be one of @option{none} (don't +compress debug sections), @option{zlib} (use zlib compression in ELF +gABI format), or @option{zlib-gnu} (use zlib compression in traditional +GNU format). + @item -gvms @opindex gvms Produce debugging information in Alpha/VMS debug format (if that is diff --git a/gcc/gcc.c b/gcc/gcc.c --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -597,6 +597,31 @@ proper position among the other output f #endif #endif +/* Linker options for compressed debug sections. */ +#if HAVE_LD_COMPRESS_DEBUG == 0 +/* No linker support. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz*:%e-gz is not supported in this configuration} " +#elif HAVE_LD_COMPRESS_DEBUG == 1 +/* GNU style on input, GNU ld options. Reject, not useful. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz*:%e-gz is not supported in this configuration} " +#elif HAVE_LD_COMPRESS_DEBUG == 2 +/* GNU style, GNU gold options. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib-gnu:" LD_COMPRESS_DEBUG_OPTION "=zlib}" \ + " %{gz=none:" LD_COMPRESS_DEBUG_OPTION "=none}" \ + " %{gz=zlib:%e-gz=zlib is not supported in this configuration} " +#elif HAVE_LD_COMPRESS_DEBUG == 3 +/* ELF gABI style. */ +#define LINK_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib:" LD_COMPRESS_DEBUG_OPTION "=zlib}" \ + " %{gz=none:" LD_COMPRESS_DEBUG_OPTION "=none}" \ + " %{gz=zlib-gnu:" LD_COMPRESS_DEBUG_OPTION "=zlib-gnu} " +#else +#error Unknown value for HAVE_LD_COMPRESS_DEBUG. +#endif + /* config.h can define LIBGCC_SPEC to override how and when libgcc.a is included. */ #ifndef LIBGCC_SPEC @@ -631,6 +656,33 @@ proper position among the other output f #define ASM_MAP "" #endif +/* Assembler options for compressed debug sections. */ +#if HAVE_LD_COMPRESS_DEBUG < 2 +/* Reject if the linker cannot write compressed debug sections. */ +#define ASM_COMPRESS_DEBUG_SPEC \ + " %{gz*:%e-gz is not supported in this configuration} " +#else /* HAVE_LD_COMPRESS_DEBUG >= 2 */ +#if HAVE_AS_COMPRESS_DEBUG == 0 +/* No assembler support. Ignore silently. */ +#define ASM_COMPRESS_DEBUG_SPEC \ + " %{gz*:} " +#elif HAVE_AS_COMPRESS_DEBUG == 1 +/* GNU style, GNU as options. */ +#define ASM_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib-gnu:" AS_COMPRESS_DEBUG_OPTION "}" \ + " %{gz=none:" AS_NO_COMPRESS_DEBUG_OPTION "}" \ + " %{gz=zlib:%e-gz=zlib is not supported in this configuration} " +#elif HAVE_AS_COMPRESS_DEBUG == 2 +/* ELF gABI style. */ +#define ASM_COMPRESS_DEBUG_SPEC \ + " %{gz|gz=zlib:" AS_COMPRESS_DEBUG_OPTION "=zlib}" \ + " %{gz=none:" AS_COMPRESS_DEBUG_OPTION "=none}" \ + " %{gz=zlib-gnu:" AS_COMPRESS_DEBUG_OPTION "=zlib-gnu} " +#else +#error Unknown value for HAVE_AS_COMPRESS_DEBUG. +#endif +#endif /* HAVE_LD_COMPRESS_DEBUG >= 2 */ + /* Define ASM_DEBUG_SPEC to be a spec suitable for translating '-g' to the assembler. */ #ifndef ASM_DEBUG_SPEC @@ -761,8 +813,8 @@ proper position among the other output f LINK_PLUGIN_SPEC \ "%{flto|flto=*:%<fcompare-debug*} \ %{flto} %{flto=*} %l " LINK_PIE_SPEC \ - "%{fuse-ld=*:-fuse-ld=%*}\ - %X %{o*} %{e*} %{N} %{n} %{r}\ + "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ + "%X %{o*} %{e*} %{N} %{n} %{r}\ %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} " VTABLE_VERIFICATION_SPEC " \ %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\ %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\ @@ -885,6 +937,7 @@ static const char *asm_options = to the assembler equivalents. */ "%{v} %{w:-W} %{I*} " #endif +ASM_COMPRESS_DEBUG_SPEC "%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}"; static const char *invoke_as = diff --git a/gcc/opts.c b/gcc/opts.c --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1867,6 +1867,11 @@ common_handle_option (struct gcc_options loc); break; + case OPT_gz: + case OPT_gz_: + /* Handled completely via specs. */ + break; + case OPT_pedantic_errors: dc->pedantic_errors = 1; control_warning_option (OPT_Wpedantic, DK_ERROR, value, [-- Attachment #3: Type: text/plain, Size: 143 bytes --] -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-05-22 11:45 ` Rainer Orth @ 2014-05-22 15:49 ` Joseph S. Myers 2014-05-22 16:19 ` Rainer Orth 0 siblings, 1 reply; 25+ messages in thread From: Joseph S. Myers @ 2014-05-22 15:49 UTC (permalink / raw) To: Rainer Orth; +Cc: gcc-patches, Paolo Bonzini On Thu, 22 May 2014, Rainer Orth wrote: > * common.opt (compressed_debug_sections): New enum. > (gz, gz=): New options. > * opts.c (common_handle_option): Handle OPT_gz, OPT_gz_. Given that the options are completely handled via specs, why can't they just be Driver options (without Common) and so not mentioned in common_handle_option? -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-05-22 15:49 ` Joseph S. Myers @ 2014-05-22 16:19 ` Rainer Orth 2014-05-22 16:33 ` Joseph S. Myers 0 siblings, 1 reply; 25+ messages in thread From: Rainer Orth @ 2014-05-22 16:19 UTC (permalink / raw) To: Joseph S. Myers; +Cc: gcc-patches, Paolo Bonzini "Joseph S. Myers" <joseph@codesourcery.com> writes: > On Thu, 22 May 2014, Rainer Orth wrote: > >> * common.opt (compressed_debug_sections): New enum. >> (gz, gz=): New options. > >> * opts.c (common_handle_option): Handle OPT_gz, OPT_gz_. > > Given that the options are completely handled via specs, why can't they > just be Driver options (without Common) and so not mentioned in > common_handle_option? If I do this, -gz still gets passed to e.g. cc1, which errors out like this: cc1: error: unrecognised debug output level "z" It seems my way of handling this is clearer than doing this in opts.c (set_debug_level). Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-05-22 16:19 ` Rainer Orth @ 2014-05-22 16:33 ` Joseph S. Myers 2014-05-27 8:11 ` Rainer Orth 0 siblings, 1 reply; 25+ messages in thread From: Joseph S. Myers @ 2014-05-22 16:33 UTC (permalink / raw) To: Rainer Orth; +Cc: gcc-patches, Paolo Bonzini On Thu, 22 May 2014, Rainer Orth wrote: > "Joseph S. Myers" <joseph@codesourcery.com> writes: > > > On Thu, 22 May 2014, Rainer Orth wrote: > > > >> * common.opt (compressed_debug_sections): New enum. > >> (gz, gz=): New options. > > > >> * opts.c (common_handle_option): Handle OPT_gz, OPT_gz_. > > > > Given that the options are completely handled via specs, why can't they > > just be Driver options (without Common) and so not mentioned in > > common_handle_option? > > If I do this, -gz still gets passed to e.g. cc1, which errors out like > this: > > cc1: error: unrecognised debug output level "z" > > It seems my way of handling this is clearer than doing this in opts.c > (set_debug_level). Thanks for the explanation. The driver changes are OK. -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-05-22 16:33 ` Joseph S. Myers @ 2014-05-27 8:11 ` Rainer Orth 2014-05-27 17:06 ` DJ Delorie 2014-06-03 10:40 ` Rainer Orth 0 siblings, 2 replies; 25+ messages in thread From: Rainer Orth @ 2014-05-27 8:11 UTC (permalink / raw) To: Joseph S. Myers; +Cc: gcc-patches, Paolo Bonzini, Mike Stump, DJ Delorie "Joseph S. Myers" <joseph@codesourcery.com> writes: > On Thu, 22 May 2014, Rainer Orth wrote: > >> "Joseph S. Myers" <joseph@codesourcery.com> writes: >> >> > On Thu, 22 May 2014, Rainer Orth wrote: >> > >> >> * common.opt (compressed_debug_sections): New enum. >> >> (gz, gz=): New options. >> > >> >> * opts.c (common_handle_option): Handle OPT_gz, OPT_gz_. >> > >> > Given that the options are completely handled via specs, why can't they >> > just be Driver options (without Common) and so not mentioned in >> > common_handle_option? >> >> If I do this, -gz still gets passed to e.g. cc1, which errors out like >> this: >> >> cc1: error: unrecognised debug output level "z" >> >> It seems my way of handling this is clearer than doing this in opts.c >> (set_debug_level). > > Thanks for the explanation. The driver changes are OK. Thanks. I still need approval for the doc and build parts, as well as the Darwin and DJGPP changes. For the latter two, I've included the patch in a x86_64-apple-darwin11.4.2 build, verifying that -gz is rejected as expected (no idea if the are any working gas and gold ports that would support the option). For DJGPP, I've tried a i386-pc-solaris2.11 x i586-pc-msdosdjgpp cross. While the specs additions look correct, trying to compile even the most trivial program SEGVs: ro@snoopy 319 > ./xgcc -B./ -o hello hello.c <built-in>: internal compiler error: Segmentation Fault 0x87549df crash_signal /vol/gcc/src/hg/trunk/local/gcc/toplev.c:337 0x82b8270 contains_struct_check /vol/gcc/src/hg/trunk/local/gcc/tree.h:2841 0x82b8270 c_common_nodes_and_builtins() /vol/gcc/src/hg/trunk/local/gcc/c-family/c-common.c:5619 0x82437be c_init_decl_processing() /vol/gcc/src/hg/trunk/local/gcc/c/c-decl.c:3567 0x827fe1a c_objc_common_init() /vol/gcc/src/hg/trunk/local/gcc/c/c-objc-common.c:63 0x8756333 lang_dependent_init /vol/gcc/src/hg/trunk/local/gcc/toplev.c:1712 0x8756333 do_compile /vol/gcc/src/hg/trunk/local/gcc/toplev.c:1901 Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-05-27 8:11 ` Rainer Orth @ 2014-05-27 17:06 ` DJ Delorie 2014-06-03 10:40 ` Rainer Orth 1 sibling, 0 replies; 25+ messages in thread From: DJ Delorie @ 2014-05-27 17:06 UTC (permalink / raw) To: Rainer Orth; +Cc: gcc-patches > Thanks. I still need approval for the doc and build parts, as well > as the Darwin and DJGPP changes. For the latter two, I've included > the I'll approve the DJGPP change, despite the segv. I suspect it's unrelated. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-05-27 8:11 ` Rainer Orth 2014-05-27 17:06 ` DJ Delorie @ 2014-06-03 10:40 ` Rainer Orth 2014-06-03 16:20 ` Mike Stump 2014-06-03 23:47 ` Gerald Pfeifer 1 sibling, 2 replies; 25+ messages in thread From: Rainer Orth @ 2014-06-03 10:40 UTC (permalink / raw) To: Joseph S. Myers Cc: gcc-patches, Paolo Bonzini, Mike Stump, DJ Delorie, Nathanael Nerode, Alexandre Oliva, Gerald Pfeifer Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes: > "Joseph S. Myers" <joseph@codesourcery.com> writes: [...] >> Thanks for the explanation. The driver changes are OK. > > Thanks. I still need approval for the doc and build parts, as well as > the Darwin and DJGPP changes. For the latter two, I've included the > patch in a x86_64-apple-darwin11.4.2 build, verifying that -gz is > rejected as expected (no idea if the are any working gas and gold ports > that would support the option). For DJGPP, I've tried a > i386-pc-solaris2.11 x i586-pc-msdosdjgpp cross. While the specs > additions look correct, trying to compile even the most trivial program > SEGVs: [...] It's been another week, and I still need approval for the build, doc, and Darwin changes: https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01860.html Thanks. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-06-03 10:40 ` Rainer Orth @ 2014-06-03 16:20 ` Mike Stump 2014-06-04 8:54 ` Rainer Orth 2014-06-03 23:47 ` Gerald Pfeifer 1 sibling, 1 reply; 25+ messages in thread From: Mike Stump @ 2014-06-03 16:20 UTC (permalink / raw) To: Rainer Orth Cc: Joseph S. Myers, gcc-patches, Paolo Bonzini, DJ Delorie, Nathanael Nerode, Alexandre Oliva, Gerald Pfeifer On Jun 3, 2014, at 3:40 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote: > It's been another week, and I still need approval for the build, doc, > and Darwin changes: So, the darwin bits look trivial enough, if the entire scheme is what people want to do. My question would be, why do we want an option for this? If the scheme works, why not just turn it on unconditionally? If it doesn’t work, why add it? If it isn’t good, why add it? If it is good, why not do it? If it is just to reach compatibility with the debugger, then I’d rather either just mandate a certain debugger or autoconf for what the current debugger supports. As of late people seem to just break the debugging experience with non-updated gdbs and assume that a newer gdb is used. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-06-03 16:20 ` Mike Stump @ 2014-06-04 8:54 ` Rainer Orth 2014-06-04 11:08 ` Mike Stump 2014-06-04 18:09 ` Eric Christopher 0 siblings, 2 replies; 25+ messages in thread From: Rainer Orth @ 2014-06-04 8:54 UTC (permalink / raw) To: Mike Stump Cc: Joseph S. Myers, gcc-patches, Paolo Bonzini, DJ Delorie, Nathanael Nerode, Alexandre Oliva, Gerald Pfeifer Mike Stump <mikestump@comcast.net> writes: > On Jun 3, 2014, at 3:40 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote: >> It's been another week, and I still need approval for the build, doc, >> and Darwin changes: > > So, the darwin bits look trivial enough, if the entire scheme is what > people want to do. My question would be, why do we want an option for > this? If the scheme works, why not just turn it on unconditionally? If it > doesn’t work, why add it? If it isn’t good, why add it? If it is good, > why not do it? It works in very specific circumstances, like assembler and linker versions. > If it is just to reach compatibility with the debugger, then I’d rather > either just mandate a certain debugger or autoconf for what the current > debugger supports. As of late people seem to just break the debugging > experience with non-updated gdbs and assume that a newer gdb is used. You cannot do that: unlike the assembler and linker used, which are often hardcoded into gcc, the debugger can easily be changed below the compiler's feet, so to speak. Besides, on several platforms, you have more than one debugger available (like gdb and dbx, or others), so this isn't an option. Apart from that, the debugging experience when e.g. emitting very recent DWARF extensions and trying to use them with a gdb that doesn't understand them usually leads to some debug info missing. In this case, emitting compressed debug with a debugger that cannot read it leads to the debugger claiming (correctly, from its point of view) that there's no debugging info present. I don't want to tell users who come complaining `I compiled with -g, but my debugger tells me there's no debug info present': `look, your debugger lies, it is present, but it cannot read it'. That's a lot worse than the DWARF extensions scenario above. On top of all that, compressed debug is a tradeoff: in some cases it may be worth it to save space on debug info if disk space is at a premium for some reason (e.g. for release builds), but in others you want to compile as fast as possible, but assembling and linking compressed debug takes more CPU time. Otherwise we could just as well default to -Os, telling our users it's better for them since it generates faster and smaller code, not minding the compile time cost and worse debugging experience. I at least don't wont to patronize our users like this. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-06-04 8:54 ` Rainer Orth @ 2014-06-04 11:08 ` Mike Stump 2014-06-04 18:09 ` Eric Christopher 1 sibling, 0 replies; 25+ messages in thread From: Mike Stump @ 2014-06-04 11:08 UTC (permalink / raw) To: Rainer Orth Cc: Joseph S. Myers, gcc-patches, Paolo Bonzini, DJ Delorie, Nathanael Nerode, Alexandre Oliva, Gerald Pfeifer On Jun 4, 2014, at 1:54 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote: > Mike Stump <mikestump@comcast.net> writes: >> On Jun 3, 2014, at 3:40 AM, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote: >>> It's been another week, and I still need approval for the build, doc, >>> and Darwin changes: >> >> So, the darwin bits look trivial enough, if the entire scheme is what >> people want to do. The darwin bits are Ok. ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-06-04 8:54 ` Rainer Orth 2014-06-04 11:08 ` Mike Stump @ 2014-06-04 18:09 ` Eric Christopher 2014-06-26 13:32 ` Rainer Orth 1 sibling, 1 reply; 25+ messages in thread From: Eric Christopher @ 2014-06-04 18:09 UTC (permalink / raw) To: Rainer Orth Cc: Mike Stump, Joseph S. Myers, gcc-patches, Paolo Bonzini, DJ Delorie, Nathanael Nerode, Alexandre Oliva, Gerald Pfeifer >> If it is just to reach compatibility with the debugger, then I’d rather >> either just mandate a certain debugger or autoconf for what the current >> debugger supports. As of late people seem to just break the debugging >> experience with non-updated gdbs and assume that a newer gdb is used. > > You cannot do that: unlike the assembler and linker used, which are > often hardcoded into gcc, the debugger can easily be changed below the > compiler's feet, so to speak. Besides, on several platforms, you have > more than one debugger available (like gdb and dbx, or others), so this > isn't an option. Apart from that, the debugging experience when > e.g. emitting very recent DWARF extensions and trying to use them with a > gdb that doesn't understand them usually leads to some debug info > missing. In this case, emitting compressed debug with a debugger that > cannot read it leads to the debugger claiming (correctly, from its > point of view) that there's no debugging info present. I don't want to > tell users who come complaining `I compiled with -g, but my debugger > tells me there's no debug info present': `look, your debugger lies, it > is present, but it cannot read it'. That's a lot worse than the > DWARF extensions scenario above. > Agreed :) FWIW it's already a gas/assembler option, I'm curious about wanting to expose it via the compiler? > On top of all that, compressed debug is a tradeoff: in some cases it may > be worth it to save space on debug info if disk space is at a premium > for some reason (e.g. for release builds), but in others you want to > compile as fast as possible, but assembling and linking compressed debug > takes more CPU time. Otherwise we could just as well default to -Os, > telling our users it's better for them since it generates faster and > smaller code, not minding the compile time cost and worse debugging > experience. > FWIW I've found in some limited timing that compression is nearly always worth it here at Google - even for compile time given the cost of writing files versus cpu time. Might be worth making it a default at some point in the future and making sure the option is invertible. -eric ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-06-04 18:09 ` Eric Christopher @ 2014-06-26 13:32 ` Rainer Orth 2014-06-27 16:33 ` Eric Christopher 0 siblings, 1 reply; 25+ messages in thread From: Rainer Orth @ 2014-06-26 13:32 UTC (permalink / raw) To: Eric Christopher Cc: Mike Stump, Joseph S. Myers, gcc-patches, Paolo Bonzini, DJ Delorie, Nathanael Nerode, Alexandre Oliva, Gerald Pfeifer Eric Christopher <echristo@gmail.com> writes: >>> If it is just to reach compatibility with the debugger, then I’d rather >>> either just mandate a certain debugger or autoconf for what the current >>> debugger supports. As of late people seem to just break the debugging >>> experience with non-updated gdbs and assume that a newer gdb is used. >> >> You cannot do that: unlike the assembler and linker used, which are >> often hardcoded into gcc, the debugger can easily be changed below the >> compiler's feet, so to speak. Besides, on several platforms, you have >> more than one debugger available (like gdb and dbx, or others), so this >> isn't an option. Apart from that, the debugging experience when >> e.g. emitting very recent DWARF extensions and trying to use them with a >> gdb that doesn't understand them usually leads to some debug info >> missing. In this case, emitting compressed debug with a debugger that >> cannot read it leads to the debugger claiming (correctly, from its >> point of view) that there's no debugging info present. I don't want to >> tell users who come complaining `I compiled with -g, but my debugger >> tells me there's no debug info present': `look, your debugger lies, it >> is present, but it cannot read it'. That's a lot worse than the >> DWARF extensions scenario above. > > Agreed :) > > FWIW it's already a gas/assembler option, I'm curious about wanting to > expose it via the compiler? One reason: ease of use: * -gz is far easier to use/type than -Wa,--compress-debug-sections + -Wl,--compress-debug-sections, and * one common option irrespective of assemblers (the Solaris assembler will gain eventually gain compressed debug support, too) and linkers used (Solaris ld requires -z compress-sections=<type>), and even the Apple assembler might at some point ;-) >> On top of all that, compressed debug is a tradeoff: in some cases it may >> be worth it to save space on debug info if disk space is at a premium >> for some reason (e.g. for release builds), but in others you want to >> compile as fast as possible, but assembling and linking compressed debug >> takes more CPU time. Otherwise we could just as well default to -Os, >> telling our users it's better for them since it generates faster and >> smaller code, not minding the compile time cost and worse debugging >> experience. > > FWIW I've found in some limited timing that compression is nearly > always worth it here at Google - even for compile time given the cost > of writing files versus cpu time. Might be worth making it a default > at some point in the future and making sure the option is invertible. One might be not so lucky with different/slower CPUs, though. I wonder how this would affect bootstrap times on my current SPARC systems ;-( But yes, a configure option to default -gz to on would certainly be helpful at some point. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-06-26 13:32 ` Rainer Orth @ 2014-06-27 16:33 ` Eric Christopher 0 siblings, 0 replies; 25+ messages in thread From: Eric Christopher @ 2014-06-27 16:33 UTC (permalink / raw) To: Rainer Orth Cc: Mike Stump, Joseph S. Myers, gcc-patches, Paolo Bonzini, DJ Delorie, Nathanael Nerode, Alexandre Oliva, Gerald Pfeifer On Thu, Jun 26, 2014 at 6:32 AM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote: > Eric Christopher <echristo@gmail.com> writes: > >>>> If it is just to reach compatibility with the debugger, then I’d rather >>>> either just mandate a certain debugger or autoconf for what the current >>>> debugger supports. As of late people seem to just break the debugging >>>> experience with non-updated gdbs and assume that a newer gdb is used. >>> >>> You cannot do that: unlike the assembler and linker used, which are >>> often hardcoded into gcc, the debugger can easily be changed below the >>> compiler's feet, so to speak. Besides, on several platforms, you have >>> more than one debugger available (like gdb and dbx, or others), so this >>> isn't an option. Apart from that, the debugging experience when >>> e.g. emitting very recent DWARF extensions and trying to use them with a >>> gdb that doesn't understand them usually leads to some debug info >>> missing. In this case, emitting compressed debug with a debugger that >>> cannot read it leads to the debugger claiming (correctly, from its >>> point of view) that there's no debugging info present. I don't want to >>> tell users who come complaining `I compiled with -g, but my debugger >>> tells me there's no debug info present': `look, your debugger lies, it >>> is present, but it cannot read it'. That's a lot worse than the >>> DWARF extensions scenario above. >> >> Agreed :) >> >> FWIW it's already a gas/assembler option, I'm curious about wanting to >> expose it via the compiler? > > One reason: ease of use: > > * -gz is far easier to use/type than -Wa,--compress-debug-sections + > -Wl,--compress-debug-sections, and > Very true. Maybe make it a -gcompress-dwarf-sections? > * one common option irrespective of assemblers (the Solaris assembler > will gain eventually gain compressed debug support, too) and linkers > used (Solaris ld requires -z compress-sections=<type>), and even the > Apple assembler might at some point ;-) > The assembler itself does, but as far as I know none of the consumers can deal with it. Right now it supports the same options as gas. >>> On top of all that, compressed debug is a tradeoff: in some cases it may >>> be worth it to save space on debug info if disk space is at a premium >>> for some reason (e.g. for release builds), but in others you want to >>> compile as fast as possible, but assembling and linking compressed debug >>> takes more CPU time. Otherwise we could just as well default to -Os, >>> telling our users it's better for them since it generates faster and >>> smaller code, not minding the compile time cost and worse debugging >>> experience. >> >> FWIW I've found in some limited timing that compression is nearly >> always worth it here at Google - even for compile time given the cost >> of writing files versus cpu time. Might be worth making it a default >> at some point in the future and making sure the option is invertible. > > One might be not so lucky with different/slower CPUs, though. I wonder > how this would affect bootstrap times on my current SPARC systems ;-( > I'd have thought you'd still largely be write bound for compilation. *shrug* > But yes, a configure option to default -gz to on would certainly be > helpful at some point. *nod* -eric ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-06-03 10:40 ` Rainer Orth 2014-06-03 16:20 ` Mike Stump @ 2014-06-03 23:47 ` Gerald Pfeifer 2014-06-26 13:16 ` Rainer Orth 1 sibling, 1 reply; 25+ messages in thread From: Gerald Pfeifer @ 2014-06-03 23:47 UTC (permalink / raw) To: Rainer Orth Cc: Joseph S. Myers, gcc-patches, Paolo Bonzini, Mike Stump, DJ Delorie, Nathanael Nerode, Alexandre Oliva On Tue, 3 Jun 2014, Rainer Orth wrote: > It's been another week, and I still need approval for the build, doc, > and Darwin changes: > > https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01860.html On the doc side, things are fine. Just a suggestion or two: +Produce compressed debug sections in DWARF format, if that is supported. Supported by what? "doesn't" -> "does not", especially given the emphasis we want to make here. And could the "If the linker doesn't support writing compressed debug sections, the option is rejected. Otherwise, if the assembler doesn't support them, @option{-gz} is silently ignored when producing object files." be moved to the very end, or is this only applicable to the case where no type has been specified? Gerald ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-06-03 23:47 ` Gerald Pfeifer @ 2014-06-26 13:16 ` Rainer Orth 2014-06-27 13:01 ` Paolo Bonzini 0 siblings, 1 reply; 25+ messages in thread From: Rainer Orth @ 2014-06-26 13:16 UTC (permalink / raw) To: Gerald Pfeifer Cc: Joseph S. Myers, gcc-patches, Paolo Bonzini, Mike Stump, DJ Delorie, Nathanael Nerode, Alexandre Oliva Hi Gerald, sorry for the delay, I've been away for a couple of days. > On Tue, 3 Jun 2014, Rainer Orth wrote: >> It's been another week, and I still need approval for the build, doc, >> and Darwin changes: >> >> https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01860.html > > On the doc side, things are fine. > > Just a suggestion or two: > > +Produce compressed debug sections in DWARF format, if that is supported. > > Supported by what? By the toolchain used. TBH, I just copied that fragment from various other debug options (-gstabs, -gcoff, -gdwarf-N). Given the precedent and the verbosity of a more detailed explanation, I'd leave this as is. > "doesn't" -> "does not", especially given the emphasis we want to make > here. Good point, fixed. > And could the "If the linker doesn't support writing compressed debug > sections, the option is rejected. Otherwise, if the assembler doesn't > support them, @option{-gz} is silently ignored when producing object > files." be moved to the very end, or is this only applicable to the > case where no type has been specified? No, you're right: it's better to first explain the values for type in the working case, then explain potential error scenarios. The section now reads @item -gz@r{[}=@var{type}@r{]} @opindex gz Produce compressed debug sections in DWARF format, if that is supported. If @var{type} is not given, the default type depends on the capabilities of the assembler and linker used. @var{type} may be one of @option{none} (don't compress debug sections), @option{zlib} (use zlib compression in ELF gABI format), or @option{zlib-gnu} (use zlib compression in traditional GNU format). If the linker doesn't support writing compressed debug sections, the option is rejected. Otherwise, if the assembler does not support them, @option{-gz} is silently ignored when producing object files. Thanks for your comments. I'm still missing review of the build parts after three weeks and several reminders, though. Paolo, Nathanael, Alexandre, could one of you please have a look? Thanks. Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [build, driver] RFC: Support compressed debug sections 2014-06-26 13:16 ` Rainer Orth @ 2014-06-27 13:01 ` Paolo Bonzini 0 siblings, 0 replies; 25+ messages in thread From: Paolo Bonzini @ 2014-06-27 13:01 UTC (permalink / raw) To: Rainer Orth, Gerald Pfeifer Cc: Joseph S. Myers, gcc-patches, Mike Stump, DJ Delorie, Nathanael Nerode, Alexandre Oliva Il 26/06/2014 15:16, Rainer Orth ha scritto: > Hi Gerald, > > sorry for the delay, I've been away for a couple of days. > >> On Tue, 3 Jun 2014, Rainer Orth wrote: >>> It's been another week, and I still need approval for the build, doc, >>> and Darwin changes: >>> >>> https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01860.html >> >> On the doc side, things are fine. >> >> Just a suggestion or two: >> >> +Produce compressed debug sections in DWARF format, if that is supported. >> >> Supported by what? > > By the toolchain used. TBH, I just copied that fragment from various > other debug options (-gstabs, -gcoff, -gdwarf-N). Given the precedent > and the verbosity of a more detailed explanation, I'd leave this as is. > >> "doesn't" -> "does not", especially given the emphasis we want to make >> here. > > Good point, fixed. > >> And could the "If the linker doesn't support writing compressed debug >> sections, the option is rejected. Otherwise, if the assembler doesn't >> support them, @option{-gz} is silently ignored when producing object >> files." be moved to the very end, or is this only applicable to the >> case where no type has been specified? > > No, you're right: it's better to first explain the values for type in > the working case, then explain potential error scenarios. > > The section now reads > > @item -gz@r{[}=@var{type}@r{]} > @opindex gz > Produce compressed debug sections in DWARF format, if that is supported. > If @var{type} is not given, the default type depends on the capabilities > of the assembler and linker used. @var{type} may be one of > @option{none} (don't compress debug sections), @option{zlib} (use zlib > compression in ELF gABI format), or @option{zlib-gnu} (use zlib > compression in traditional GNU format). If the linker doesn't support > writing compressed debug sections, the option is rejected. Otherwise, > if the assembler does not support them, @option{-gz} is silently ignored > when producing object files. > > Thanks for your comments. > > I'm still missing review of the build parts after three weeks and > several reminders, though. Paolo, Nathanael, Alexandre, could one of > you please have a look? Build changes are good, thanks. Paolo ^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2014-06-27 16:33 UTC | newest] Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-04-11 12:36 [build, driver] RFC: Support compressed debug sections Rainer Orth 2013-04-11 12:36 ` Andi Kleen 2013-04-11 12:54 ` Rainer Orth 2013-04-26 22:43 ` Joseph S. Myers 2013-04-30 15:06 ` Rainer Orth 2013-05-03 20:01 ` Joseph S. Myers 2013-05-04 21:20 ` Rainer Orth 2013-05-05 14:15 ` Joseph S. Myers 2013-05-15 15:38 ` Rainer Orth 2014-05-22 11:45 ` Rainer Orth 2014-05-22 15:49 ` Joseph S. Myers 2014-05-22 16:19 ` Rainer Orth 2014-05-22 16:33 ` Joseph S. Myers 2014-05-27 8:11 ` Rainer Orth 2014-05-27 17:06 ` DJ Delorie 2014-06-03 10:40 ` Rainer Orth 2014-06-03 16:20 ` Mike Stump 2014-06-04 8:54 ` Rainer Orth 2014-06-04 11:08 ` Mike Stump 2014-06-04 18:09 ` Eric Christopher 2014-06-26 13:32 ` Rainer Orth 2014-06-27 16:33 ` Eric Christopher 2014-06-03 23:47 ` Gerald Pfeifer 2014-06-26 13:16 ` Rainer Orth 2014-06-27 13:01 ` Paolo Bonzini
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).