public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Remove legacy -gz=zlib-gnu
@ 2022-07-01  6:57 Fangrui Song
  2022-07-01  7:03 ` Andrew Pinski
  0 siblings, 1 reply; 14+ messages in thread
From: Fangrui Song @ 2022-07-01  6:57 UTC (permalink / raw)
  To: gcc-patches, H.J. Lu, Rainer Orth; +Cc: Fangrui Song

From: Fangrui Song <i@maskray.me>

SHF_COMPRESSED style zlib has been supported since binutils 2.26
and the legacy zlib-gnu option hasn't gain adoption.
According to Debian Code Search (`gz=zlib-gnu`), no project uses
-gz=zlib-gnu (valgrind has a configure to use -gz=zlib).
Remove support for the legacy zlib-gnu and simplify configure.ac by
removing zlib-gnu ld/as check.
---
 gcc/common.opt      |  3 ---
 gcc/configure       | 33 ++++++---------------------------
 gcc/configure.ac    | 29 ++++-------------------------
 gcc/doc/invoke.texi | 11 +++++------
 gcc/gcc.cc          | 22 ++--------------------
 5 files changed, 17 insertions(+), 81 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index e7a51e882ba..8754d93d545 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -3424,9 +3424,6 @@ 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.
diff --git a/gcc/configure b/gcc/configure
index 62872d132ea..ca87e875e9d 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -19674,7 +19674,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19679 "configure"
+#line 19677 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19780,7 +19780,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19785 "configure"
+#line 19783 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -29711,20 +29711,13 @@ else
    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
-   # Since binutils 2.26, gas supports --compress-debug-sections=type,
+   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
    # defaulting to the ELF gABI format.
-   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
+   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
    then
      gcc_cv_as_compress_debug=2
      gcc_cv_as_compress_debug_option="--compress-debug-sections"
      gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
-   # Before binutils 2.26, gas only supported --compress-debug-options and
-   # emitted the traditional GNU format.
-   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
    fi
@@ -30238,42 +30231,28 @@ $as_echo "$gcc_cv_ld_eh_gc_sections_bug" >&6; }
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for compressed debug sections" >&5
 $as_echo_n "checking linker for compressed debug sections... " >&6; }
-# gold/gld support compressed debug sections since binutils 2.19/2.21
-# In binutils 2.26, gld gained support for the ELF gABI format.
+# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
 if test $in_tree_ld = yes ; then
   gcc_cv_ld_compress_debug=0
   if test $ld_is_mold = yes; then
     gcc_cv_ld_compress_debug=3
     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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
      && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
     gcc_cv_ld_compress_debug=3
     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
   if test $ld_is_mold = yes; then
     gcc_cv_ld_compress_debug=3
     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
   elif test "$ld_vers_major" -lt 2 \
-     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
+     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
     gcc_cv_ld_compress_debug=0
-  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
-    gcc_cv_ld_compress_debug=1
   else
     gcc_cv_ld_compress_debug=3
     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
   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
   case "${target}" in
     *-*-solaris2*)
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 446747311a6..f40f75271c2 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5733,20 +5733,13 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
    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
-   # Since binutils 2.26, gas supports --compress-debug-sections=type,
+   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
    # defaulting to the ELF gABI format.
-   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
+   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
    then
      gcc_cv_as_compress_debug=2
      gcc_cv_as_compress_debug_option="--compress-debug-sections"
      gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
-   # Before binutils 2.26, gas only supported --compress-debug-options and
-   # emitted the traditional GNU format.
-   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
    fi])
@@ -6131,42 +6124,28 @@ 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
-# In binutils 2.26, gld gained support for the ELF gABI format.
+# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
 if test $in_tree_ld = yes ; then
   gcc_cv_ld_compress_debug=0
   if test $ld_is_mold = yes; then
     gcc_cv_ld_compress_debug=3
     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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
      && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
     gcc_cv_ld_compress_debug=3
     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
   if test $ld_is_mold = yes; then
     gcc_cv_ld_compress_debug=3
     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
   elif test "$ld_vers_major" -lt 2 \
-     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
+     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
     gcc_cv_ld_compress_debug=0
-  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
-    gcc_cv_ld_compress_debug=1
   else
     gcc_cv_ld_compress_debug=3
     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
   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
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 757775ea576..467659cb094 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -10775,12 +10775,11 @@ location views are enabled.
 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
-@samp{none} (don't compress debug sections), @samp{zlib} (use zlib
-compression in ELF gABI format), or @samp{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.
+@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
+compression in ELF gABI 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.
 
 @item -femit-struct-debug-baseonly
 @opindex femit-struct-debug-baseonly
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 5cbb38560b2..660cd6f4ef4 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -827,22 +827,11 @@ proper position among the other output files.  */
 /* 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} "
+	" %{gz=none:"	  LD_COMPRESS_DEBUG_OPTION "=none}"
 #else
 #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
 #endif
@@ -891,18 +880,11 @@ proper position among the other output files.  */
 /* 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} "
+	" %{gz=none:"	  AS_COMPRESS_DEBUG_OPTION "=none}"
 #else
 #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
 #endif
-- 
2.37.0.rc0.161.g10f37bed90-goog


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Remove legacy -gz=zlib-gnu
  2022-07-01  6:57 [PATCH] Remove legacy -gz=zlib-gnu Fangrui Song
@ 2022-07-01  7:03 ` Andrew Pinski
  2022-07-01  7:20   ` Fangrui Song
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Pinski @ 2022-07-01  7:03 UTC (permalink / raw)
  To: Fangrui Song; +Cc: GCC Patches, H.J. Lu, Rainer Orth, Fangrui Song

On Thu, Jun 30, 2022 at 11:58 PM Fangrui Song via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> From: Fangrui Song <i@maskray.me>
>
> SHF_COMPRESSED style zlib has been supported since binutils 2.26
> and the legacy zlib-gnu option hasn't gain adoption.
> According to Debian Code Search (`gz=zlib-gnu`), no project uses
> -gz=zlib-gnu (valgrind has a configure to use -gz=zlib).
> Remove support for the legacy zlib-gnu and simplify configure.ac by
> removing zlib-gnu ld/as check.

A couple of things, you are missing a changelog.
Second, why remove something which is still working?
Third, why not just make gz=zlib-gnu as an alias to gz=zlib instead so
if someone used it before it will still work. we try not to remove
options; have them emit a warning and be ignored (or moved over to the
closed option).

Thanks,
Andrew

> ---
>  gcc/common.opt      |  3 ---
>  gcc/configure       | 33 ++++++---------------------------
>  gcc/configure.ac    | 29 ++++-------------------------
>  gcc/doc/invoke.texi | 11 +++++------
>  gcc/gcc.cc          | 22 ++--------------------
>  5 files changed, 17 insertions(+), 81 deletions(-)
>
> diff --git a/gcc/common.opt b/gcc/common.opt
> index e7a51e882ba..8754d93d545 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -3424,9 +3424,6 @@ 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.
> diff --git a/gcc/configure b/gcc/configure
> index 62872d132ea..ca87e875e9d 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -19674,7 +19674,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 19679 "configure"
> +#line 19677 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> @@ -19780,7 +19780,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 19785 "configure"
> +#line 19783 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> @@ -29711,20 +29711,13 @@ else
>     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
> -   # Since binutils 2.26, gas supports --compress-debug-sections=type,
> +   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
>     # defaulting to the ELF gABI format.
> -   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
> +   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
>     then
>       gcc_cv_as_compress_debug=2
>       gcc_cv_as_compress_debug_option="--compress-debug-sections"
>       gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
> -   # Before binutils 2.26, gas only supported --compress-debug-options and
> -   # emitted the traditional GNU format.
> -   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
>     fi
> @@ -30238,42 +30231,28 @@ $as_echo "$gcc_cv_ld_eh_gc_sections_bug" >&6; }
>
>  { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for compressed debug sections" >&5
>  $as_echo_n "checking linker for compressed debug sections... " >&6; }
> -# gold/gld support compressed debug sections since binutils 2.19/2.21
> -# In binutils 2.26, gld gained support for the ELF gABI format.
> +# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
>  if test $in_tree_ld = yes ; then
>    gcc_cv_ld_compress_debug=0
>    if test $ld_is_mold = yes; then
>      gcc_cv_ld_compress_debug=3
>      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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
>       && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
>      gcc_cv_ld_compress_debug=3
>      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
>    if test $ld_is_mold = yes; then
>      gcc_cv_ld_compress_debug=3
>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>    elif test "$ld_vers_major" -lt 2 \
> -     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
> +     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
>      gcc_cv_ld_compress_debug=0
> -  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
> -    gcc_cv_ld_compress_debug=1
>    else
>      gcc_cv_ld_compress_debug=3
>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>    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
>    case "${target}" in
>      *-*-solaris2*)
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 446747311a6..f40f75271c2 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -5733,20 +5733,13 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
>     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
> -   # Since binutils 2.26, gas supports --compress-debug-sections=type,
> +   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
>     # defaulting to the ELF gABI format.
> -   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
> +   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
>     then
>       gcc_cv_as_compress_debug=2
>       gcc_cv_as_compress_debug_option="--compress-debug-sections"
>       gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
> -   # Before binutils 2.26, gas only supported --compress-debug-options and
> -   # emitted the traditional GNU format.
> -   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
>     fi])
> @@ -6131,42 +6124,28 @@ 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
> -# In binutils 2.26, gld gained support for the ELF gABI format.
> +# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
>  if test $in_tree_ld = yes ; then
>    gcc_cv_ld_compress_debug=0
>    if test $ld_is_mold = yes; then
>      gcc_cv_ld_compress_debug=3
>      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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
>       && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
>      gcc_cv_ld_compress_debug=3
>      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
>    if test $ld_is_mold = yes; then
>      gcc_cv_ld_compress_debug=3
>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>    elif test "$ld_vers_major" -lt 2 \
> -     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
> +     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
>      gcc_cv_ld_compress_debug=0
> -  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
> -    gcc_cv_ld_compress_debug=1
>    else
>      gcc_cv_ld_compress_debug=3
>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>    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
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 757775ea576..467659cb094 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -10775,12 +10775,11 @@ location views are enabled.
>  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
> -@samp{none} (don't compress debug sections), @samp{zlib} (use zlib
> -compression in ELF gABI format), or @samp{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.
> +@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
> +compression in ELF gABI 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.
>
>  @item -femit-struct-debug-baseonly
>  @opindex femit-struct-debug-baseonly
> diff --git a/gcc/gcc.cc b/gcc/gcc.cc
> index 5cbb38560b2..660cd6f4ef4 100644
> --- a/gcc/gcc.cc
> +++ b/gcc/gcc.cc
> @@ -827,22 +827,11 @@ proper position among the other output files.  */
>  /* 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} "
> +       " %{gz=none:"     LD_COMPRESS_DEBUG_OPTION "=none}"
>  #else
>  #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
>  #endif
> @@ -891,18 +880,11 @@ proper position among the other output files.  */
>  /* 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} "
> +       " %{gz=none:"     AS_COMPRESS_DEBUG_OPTION "=none}"
>  #else
>  #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
>  #endif
> --
> 2.37.0.rc0.161.g10f37bed90-goog
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Remove legacy -gz=zlib-gnu
  2022-07-01  7:03 ` Andrew Pinski
@ 2022-07-01  7:20   ` Fangrui Song
  2022-09-20 12:55     ` Martin Liška
  0 siblings, 1 reply; 14+ messages in thread
From: Fangrui Song @ 2022-07-01  7:20 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches, H.J. Lu, Rainer Orth, Fangrui Song

On 2022-07-01, Andrew Pinski wrote:
>On Thu, Jun 30, 2022 at 11:58 PM Fangrui Song via Gcc-patches
><gcc-patches@gcc.gnu.org> wrote:
>>
>> From: Fangrui Song <i@maskray.me>
>>
>> SHF_COMPRESSED style zlib has been supported since binutils 2.26
>> and the legacy zlib-gnu option hasn't gain adoption.
>> According to Debian Code Search (`gz=zlib-gnu`), no project uses
>> -gz=zlib-gnu (valgrind has a configure to use -gz=zlib).
>> Remove support for the legacy zlib-gnu and simplify configure.ac by
>> removing zlib-gnu ld/as check.
>
>A couple of things, you are missing a changelog.

Sorry.

>Second, why remove something which is still working?

It's unused and its existence causes confusion: the paradox of choice.
People may assume the support may be good but newer DWARF consumers may
not support the legacy format.

The other motivation is to clean up it a bit.  I foresee that someone
will add --compress-debug-sections=zstd to binutils and configure.ac and
gcc/gcc.cc would become more messy.

>Third, why not just make gz=zlib-gnu as an alias to gz=zlib instead so
>if someone used it before it will still work. we try not to remove
>options; have them emit a warning and be ignored (or moved over to the
>closed option).

Changing the semantics of -gz=zlib-gnu would be even more confusing.

>Thanks,
>Andrew
>
>> ---
>>  gcc/common.opt      |  3 ---
>>  gcc/configure       | 33 ++++++---------------------------
>>  gcc/configure.ac    | 29 ++++-------------------------
>>  gcc/doc/invoke.texi | 11 +++++------
>>  gcc/gcc.cc          | 22 ++--------------------
>>  5 files changed, 17 insertions(+), 81 deletions(-)
>>
>> diff --git a/gcc/common.opt b/gcc/common.opt
>> index e7a51e882ba..8754d93d545 100644
>> --- a/gcc/common.opt
>> +++ b/gcc/common.opt
>> @@ -3424,9 +3424,6 @@ 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.
>> diff --git a/gcc/configure b/gcc/configure
>> index 62872d132ea..ca87e875e9d 100755
>> --- a/gcc/configure
>> +++ b/gcc/configure
>> @@ -19674,7 +19674,7 @@ else
>>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>>    lt_status=$lt_dlunknown
>>    cat > conftest.$ac_ext <<_LT_EOF
>> -#line 19679 "configure"
>> +#line 19677 "configure"
>>  #include "confdefs.h"
>>
>>  #if HAVE_DLFCN_H
>> @@ -19780,7 +19780,7 @@ else
>>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>>    lt_status=$lt_dlunknown
>>    cat > conftest.$ac_ext <<_LT_EOF
>> -#line 19785 "configure"
>> +#line 19783 "configure"
>>  #include "confdefs.h"
>>
>>  #if HAVE_DLFCN_H
>> @@ -29711,20 +29711,13 @@ else
>>     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
>> -   # Since binutils 2.26, gas supports --compress-debug-sections=type,
>> +   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
>>     # defaulting to the ELF gABI format.
>> -   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
>> +   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
>>     then
>>       gcc_cv_as_compress_debug=2
>>       gcc_cv_as_compress_debug_option="--compress-debug-sections"
>>       gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
>> -   # Before binutils 2.26, gas only supported --compress-debug-options and
>> -   # emitted the traditional GNU format.
>> -   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
>>     fi
>> @@ -30238,42 +30231,28 @@ $as_echo "$gcc_cv_ld_eh_gc_sections_bug" >&6; }
>>
>>  { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for compressed debug sections" >&5
>>  $as_echo_n "checking linker for compressed debug sections... " >&6; }
>> -# gold/gld support compressed debug sections since binutils 2.19/2.21
>> -# In binutils 2.26, gld gained support for the ELF gABI format.
>> +# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
>>  if test $in_tree_ld = yes ; then
>>    gcc_cv_ld_compress_debug=0
>>    if test $ld_is_mold = yes; then
>>      gcc_cv_ld_compress_debug=3
>>      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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
>>       && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
>>      gcc_cv_ld_compress_debug=3
>>      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
>>    if test $ld_is_mold = yes; then
>>      gcc_cv_ld_compress_debug=3
>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>>    elif test "$ld_vers_major" -lt 2 \
>> -     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
>> +     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
>>      gcc_cv_ld_compress_debug=0
>> -  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
>> -    gcc_cv_ld_compress_debug=1
>>    else
>>      gcc_cv_ld_compress_debug=3
>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>>    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
>>    case "${target}" in
>>      *-*-solaris2*)
>> diff --git a/gcc/configure.ac b/gcc/configure.ac
>> index 446747311a6..f40f75271c2 100644
>> --- a/gcc/configure.ac
>> +++ b/gcc/configure.ac
>> @@ -5733,20 +5733,13 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
>>     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
>> -   # Since binutils 2.26, gas supports --compress-debug-sections=type,
>> +   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
>>     # defaulting to the ELF gABI format.
>> -   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
>> +   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
>>     then
>>       gcc_cv_as_compress_debug=2
>>       gcc_cv_as_compress_debug_option="--compress-debug-sections"
>>       gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
>> -   # Before binutils 2.26, gas only supported --compress-debug-options and
>> -   # emitted the traditional GNU format.
>> -   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
>>     fi])
>> @@ -6131,42 +6124,28 @@ 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
>> -# In binutils 2.26, gld gained support for the ELF gABI format.
>> +# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
>>  if test $in_tree_ld = yes ; then
>>    gcc_cv_ld_compress_debug=0
>>    if test $ld_is_mold = yes; then
>>      gcc_cv_ld_compress_debug=3
>>      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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
>>       && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
>>      gcc_cv_ld_compress_debug=3
>>      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
>>    if test $ld_is_mold = yes; then
>>      gcc_cv_ld_compress_debug=3
>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>>    elif test "$ld_vers_major" -lt 2 \
>> -     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
>> +     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
>>      gcc_cv_ld_compress_debug=0
>> -  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
>> -    gcc_cv_ld_compress_debug=1
>>    else
>>      gcc_cv_ld_compress_debug=3
>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>>    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
>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>> index 757775ea576..467659cb094 100644
>> --- a/gcc/doc/invoke.texi
>> +++ b/gcc/doc/invoke.texi
>> @@ -10775,12 +10775,11 @@ location views are enabled.
>>  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
>> -@samp{none} (don't compress debug sections), @samp{zlib} (use zlib
>> -compression in ELF gABI format), or @samp{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.
>> +@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
>> +compression in ELF gABI 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.
>>
>>  @item -femit-struct-debug-baseonly
>>  @opindex femit-struct-debug-baseonly
>> diff --git a/gcc/gcc.cc b/gcc/gcc.cc
>> index 5cbb38560b2..660cd6f4ef4 100644
>> --- a/gcc/gcc.cc
>> +++ b/gcc/gcc.cc
>> @@ -827,22 +827,11 @@ proper position among the other output files.  */
>>  /* 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} "
>> +       " %{gz=none:"     LD_COMPRESS_DEBUG_OPTION "=none}"
>>  #else
>>  #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
>>  #endif
>> @@ -891,18 +880,11 @@ proper position among the other output files.  */
>>  /* 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} "
>> +       " %{gz=none:"     AS_COMPRESS_DEBUG_OPTION "=none}"
>>  #else
>>  #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
>>  #endif
>> --
>> 2.37.0.rc0.161.g10f37bed90-goog
>>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Remove legacy -gz=zlib-gnu
  2022-07-01  7:20   ` Fangrui Song
@ 2022-09-20 12:55     ` Martin Liška
  2022-09-21  7:36       ` Richard Biener
  0 siblings, 1 reply; 14+ messages in thread
From: Martin Liška @ 2022-09-20 12:55 UTC (permalink / raw)
  To: Fangrui Song, Andrew Pinski; +Cc: Fangrui Song, GCC Patches, Richard Biener

On 7/1/22 09:20, Fangrui Song via Gcc-patches wrote:
> On 2022-07-01, Andrew Pinski wrote:
>> On Thu, Jun 30, 2022 at 11:58 PM Fangrui Song via Gcc-patches
>> <gcc-patches@gcc.gnu.org> wrote:
>>>
>>> From: Fangrui Song <i@maskray.me>
>>>
>>> SHF_COMPRESSED style zlib has been supported since binutils 2.26
>>> and the legacy zlib-gnu option hasn't gain adoption.
>>> According to Debian Code Search (`gz=zlib-gnu`), no project uses
>>> -gz=zlib-gnu (valgrind has a configure to use -gz=zlib).
>>> Remove support for the legacy zlib-gnu and simplify configure.ac by
>>> removing zlib-gnu ld/as check.
>>
>> A couple of things, you are missing a changelog.
> 
> Sorry.
> 
>> Second, why remove something which is still working?

Hi.

I do support the option removal, while I would replace the removal with a warning
saying no compression will be used.

> 
> It's unused and its existence causes confusion: the paradox of choice.
> People may assume the support may be good but newer DWARF consumers may
> not support the legacy format.

Agree, the compression format is legacy. I verified all openSUSE packages (15k)
and there's no project actively using it.

> 
> The other motivation is to clean up it a bit.  I foresee that someone
> will add --compress-debug-sections=zstd to binutils and configure.ac and
> gcc/gcc.cc would become more messy.

The argument makes sense, it will be even bigger mess.

@Richi: Is it something we can deprecate for GCC 13?

Martin

> 
>> Third, why not just make gz=zlib-gnu as an alias to gz=zlib instead so
>> if someone used it before it will still work. we try not to remove
>> options; have them emit a warning and be ignored (or moved over to the
>> closed option).
> 
> Changing the semantics of -gz=zlib-gnu would be even more confusing.
> 
>> Thanks,
>> Andrew
>>
>>> ---
>>>  gcc/common.opt      |  3 ---
>>>  gcc/configure       | 33 ++++++---------------------------
>>>  gcc/configure.ac    | 29 ++++-------------------------
>>>  gcc/doc/invoke.texi | 11 +++++------
>>>  gcc/gcc.cc          | 22 ++--------------------
>>>  5 files changed, 17 insertions(+), 81 deletions(-)
>>>
>>> diff --git a/gcc/common.opt b/gcc/common.opt
>>> index e7a51e882ba..8754d93d545 100644
>>> --- a/gcc/common.opt
>>> +++ b/gcc/common.opt
>>> @@ -3424,9 +3424,6 @@ 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.
>>> diff --git a/gcc/configure b/gcc/configure
>>> index 62872d132ea..ca87e875e9d 100755
>>> --- a/gcc/configure
>>> +++ b/gcc/configure
>>> @@ -19674,7 +19674,7 @@ else
>>>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>>>    lt_status=$lt_dlunknown
>>>    cat > conftest.$ac_ext <<_LT_EOF
>>> -#line 19679 "configure"
>>> +#line 19677 "configure"
>>>  #include "confdefs.h"
>>>
>>>  #if HAVE_DLFCN_H
>>> @@ -19780,7 +19780,7 @@ else
>>>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>>>    lt_status=$lt_dlunknown
>>>    cat > conftest.$ac_ext <<_LT_EOF
>>> -#line 19785 "configure"
>>> +#line 19783 "configure"
>>>  #include "confdefs.h"
>>>
>>>  #if HAVE_DLFCN_H
>>> @@ -29711,20 +29711,13 @@ else
>>>     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
>>> -   # Since binutils 2.26, gas supports --compress-debug-sections=type,
>>> +   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
>>>     # defaulting to the ELF gABI format.
>>> -   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
>>> +   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
>>>     then
>>>       gcc_cv_as_compress_debug=2
>>>       gcc_cv_as_compress_debug_option="--compress-debug-sections"
>>>       gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
>>> -   # Before binutils 2.26, gas only supported --compress-debug-options and
>>> -   # emitted the traditional GNU format.
>>> -   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
>>>     fi
>>> @@ -30238,42 +30231,28 @@ $as_echo "$gcc_cv_ld_eh_gc_sections_bug" >&6; }
>>>
>>>  { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for compressed debug sections" >&5
>>>  $as_echo_n "checking linker for compressed debug sections... " >&6; }
>>> -# gold/gld support compressed debug sections since binutils 2.19/2.21
>>> -# In binutils 2.26, gld gained support for the ELF gABI format.
>>> +# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
>>>  if test $in_tree_ld = yes ; then
>>>    gcc_cv_ld_compress_debug=0
>>>    if test $ld_is_mold = yes; then
>>>      gcc_cv_ld_compress_debug=3
>>>      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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
>>>       && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
>>>      gcc_cv_ld_compress_debug=3
>>>      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
>>>    if test $ld_is_mold = yes; then
>>>      gcc_cv_ld_compress_debug=3
>>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>>>    elif test "$ld_vers_major" -lt 2 \
>>> -     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
>>> +     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
>>>      gcc_cv_ld_compress_debug=0
>>> -  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
>>> -    gcc_cv_ld_compress_debug=1
>>>    else
>>>      gcc_cv_ld_compress_debug=3
>>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>>>    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
>>>    case "${target}" in
>>>      *-*-solaris2*)
>>> diff --git a/gcc/configure.ac b/gcc/configure.ac
>>> index 446747311a6..f40f75271c2 100644
>>> --- a/gcc/configure.ac
>>> +++ b/gcc/configure.ac
>>> @@ -5733,20 +5733,13 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
>>>     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
>>> -   # Since binutils 2.26, gas supports --compress-debug-sections=type,
>>> +   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
>>>     # defaulting to the ELF gABI format.
>>> -   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
>>> +   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
>>>     then
>>>       gcc_cv_as_compress_debug=2
>>>       gcc_cv_as_compress_debug_option="--compress-debug-sections"
>>>       gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
>>> -   # Before binutils 2.26, gas only supported --compress-debug-options and
>>> -   # emitted the traditional GNU format.
>>> -   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
>>>     fi])
>>> @@ -6131,42 +6124,28 @@ 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
>>> -# In binutils 2.26, gld gained support for the ELF gABI format.
>>> +# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
>>>  if test $in_tree_ld = yes ; then
>>>    gcc_cv_ld_compress_debug=0
>>>    if test $ld_is_mold = yes; then
>>>      gcc_cv_ld_compress_debug=3
>>>      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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
>>>       && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
>>>      gcc_cv_ld_compress_debug=3
>>>      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
>>>    if test $ld_is_mold = yes; then
>>>      gcc_cv_ld_compress_debug=3
>>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>>>    elif test "$ld_vers_major" -lt 2 \
>>> -     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
>>> +     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
>>>      gcc_cv_ld_compress_debug=0
>>> -  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
>>> -    gcc_cv_ld_compress_debug=1
>>>    else
>>>      gcc_cv_ld_compress_debug=3
>>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
>>>    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
>>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>>> index 757775ea576..467659cb094 100644
>>> --- a/gcc/doc/invoke.texi
>>> +++ b/gcc/doc/invoke.texi
>>> @@ -10775,12 +10775,11 @@ location views are enabled.
>>>  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
>>> -@samp{none} (don't compress debug sections), @samp{zlib} (use zlib
>>> -compression in ELF gABI format), or @samp{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.
>>> +@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
>>> +compression in ELF gABI 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.
>>>
>>>  @item -femit-struct-debug-baseonly
>>>  @opindex femit-struct-debug-baseonly
>>> diff --git a/gcc/gcc.cc b/gcc/gcc.cc
>>> index 5cbb38560b2..660cd6f4ef4 100644
>>> --- a/gcc/gcc.cc
>>> +++ b/gcc/gcc.cc
>>> @@ -827,22 +827,11 @@ proper position among the other output files.  */
>>>  /* 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} "
>>> +       " %{gz=none:"     LD_COMPRESS_DEBUG_OPTION "=none}"
>>>  #else
>>>  #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
>>>  #endif
>>> @@ -891,18 +880,11 @@ proper position among the other output files.  */
>>>  /* 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} "
>>> +       " %{gz=none:"     AS_COMPRESS_DEBUG_OPTION "=none}"
>>>  #else
>>>  #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
>>>  #endif
>>> -- 
>>> 2.37.0.rc0.161.g10f37bed90-goog
>>>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Remove legacy -gz=zlib-gnu
  2022-09-20 12:55     ` Martin Liška
@ 2022-09-21  7:36       ` Richard Biener
  2022-09-21  7:45         ` Fangrui Song
  2022-09-21  7:49         ` Martin Liška
  0 siblings, 2 replies; 14+ messages in thread
From: Richard Biener @ 2022-09-21  7:36 UTC (permalink / raw)
  To: Martin Liška; +Cc: Fangrui Song, Andrew Pinski, Fangrui Song, GCC Patches

On Tue, Sep 20, 2022 at 2:55 PM Martin Liška <mliska@suse.cz> wrote:
>
> On 7/1/22 09:20, Fangrui Song via Gcc-patches wrote:
> > On 2022-07-01, Andrew Pinski wrote:
> >> On Thu, Jun 30, 2022 at 11:58 PM Fangrui Song via Gcc-patches
> >> <gcc-patches@gcc.gnu.org> wrote:
> >>>
> >>> From: Fangrui Song <i@maskray.me>
> >>>
> >>> SHF_COMPRESSED style zlib has been supported since binutils 2.26
> >>> and the legacy zlib-gnu option hasn't gain adoption.
> >>> According to Debian Code Search (`gz=zlib-gnu`), no project uses
> >>> -gz=zlib-gnu (valgrind has a configure to use -gz=zlib).
> >>> Remove support for the legacy zlib-gnu and simplify configure.ac by
> >>> removing zlib-gnu ld/as check.
> >>
> >> A couple of things, you are missing a changelog.
> >
> > Sorry.
> >
> >> Second, why remove something which is still working?
>
> Hi.
>
> I do support the option removal, while I would replace the removal with a warning
> saying no compression will be used.
>
> >
> > It's unused and its existence causes confusion: the paradox of choice.
> > People may assume the support may be good but newer DWARF consumers may
> > not support the legacy format.
>
> Agree, the compression format is legacy. I verified all openSUSE packages (15k)
> and there's no project actively using it.
>
> >
> > The other motivation is to clean up it a bit.  I foresee that someone
> > will add --compress-debug-sections=zstd to binutils and configure.ac and
> > gcc/gcc.cc would become more messy.
>
> The argument makes sense, it will be even bigger mess.
>
> @Richi: Is it something we can deprecate for GCC 13?

What's the practical difference between zlib and zlib-gnu?  Can we just
map zlib-gnu to zlib?  If it's all configure time what's the point in
"deprecating" it?

Richard.

>
> Martin
>
> >
> >> Third, why not just make gz=zlib-gnu as an alias to gz=zlib instead so
> >> if someone used it before it will still work. we try not to remove
> >> options; have them emit a warning and be ignored (or moved over to the
> >> closed option).
> >
> > Changing the semantics of -gz=zlib-gnu would be even more confusing.
> >
> >> Thanks,
> >> Andrew
> >>
> >>> ---
> >>>  gcc/common.opt      |  3 ---
> >>>  gcc/configure       | 33 ++++++---------------------------
> >>>  gcc/configure.ac    | 29 ++++-------------------------
> >>>  gcc/doc/invoke.texi | 11 +++++------
> >>>  gcc/gcc.cc          | 22 ++--------------------
> >>>  5 files changed, 17 insertions(+), 81 deletions(-)
> >>>
> >>> diff --git a/gcc/common.opt b/gcc/common.opt
> >>> index e7a51e882ba..8754d93d545 100644
> >>> --- a/gcc/common.opt
> >>> +++ b/gcc/common.opt
> >>> @@ -3424,9 +3424,6 @@ 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.
> >>> diff --git a/gcc/configure b/gcc/configure
> >>> index 62872d132ea..ca87e875e9d 100755
> >>> --- a/gcc/configure
> >>> +++ b/gcc/configure
> >>> @@ -19674,7 +19674,7 @@ else
> >>>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> >>>    lt_status=$lt_dlunknown
> >>>    cat > conftest.$ac_ext <<_LT_EOF
> >>> -#line 19679 "configure"
> >>> +#line 19677 "configure"
> >>>  #include "confdefs.h"
> >>>
> >>>  #if HAVE_DLFCN_H
> >>> @@ -19780,7 +19780,7 @@ else
> >>>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> >>>    lt_status=$lt_dlunknown
> >>>    cat > conftest.$ac_ext <<_LT_EOF
> >>> -#line 19785 "configure"
> >>> +#line 19783 "configure"
> >>>  #include "confdefs.h"
> >>>
> >>>  #if HAVE_DLFCN_H
> >>> @@ -29711,20 +29711,13 @@ else
> >>>     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
> >>> -   # Since binutils 2.26, gas supports --compress-debug-sections=type,
> >>> +   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
> >>>     # defaulting to the ELF gABI format.
> >>> -   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
> >>> +   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
> >>>     then
> >>>       gcc_cv_as_compress_debug=2
> >>>       gcc_cv_as_compress_debug_option="--compress-debug-sections"
> >>>       gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
> >>> -   # Before binutils 2.26, gas only supported --compress-debug-options and
> >>> -   # emitted the traditional GNU format.
> >>> -   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
> >>>     fi
> >>> @@ -30238,42 +30231,28 @@ $as_echo "$gcc_cv_ld_eh_gc_sections_bug" >&6; }
> >>>
> >>>  { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for compressed debug sections" >&5
> >>>  $as_echo_n "checking linker for compressed debug sections... " >&6; }
> >>> -# gold/gld support compressed debug sections since binutils 2.19/2.21
> >>> -# In binutils 2.26, gld gained support for the ELF gABI format.
> >>> +# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
> >>>  if test $in_tree_ld = yes ; then
> >>>    gcc_cv_ld_compress_debug=0
> >>>    if test $ld_is_mold = yes; then
> >>>      gcc_cv_ld_compress_debug=3
> >>>      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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
> >>>       && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
> >>>      gcc_cv_ld_compress_debug=3
> >>>      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
> >>>    if test $ld_is_mold = yes; then
> >>>      gcc_cv_ld_compress_debug=3
> >>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> >>>    elif test "$ld_vers_major" -lt 2 \
> >>> -     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
> >>> +     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
> >>>      gcc_cv_ld_compress_debug=0
> >>> -  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
> >>> -    gcc_cv_ld_compress_debug=1
> >>>    else
> >>>      gcc_cv_ld_compress_debug=3
> >>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> >>>    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
> >>>    case "${target}" in
> >>>      *-*-solaris2*)
> >>> diff --git a/gcc/configure.ac b/gcc/configure.ac
> >>> index 446747311a6..f40f75271c2 100644
> >>> --- a/gcc/configure.ac
> >>> +++ b/gcc/configure.ac
> >>> @@ -5733,20 +5733,13 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
> >>>     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
> >>> -   # Since binutils 2.26, gas supports --compress-debug-sections=type,
> >>> +   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
> >>>     # defaulting to the ELF gABI format.
> >>> -   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
> >>> +   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
> >>>     then
> >>>       gcc_cv_as_compress_debug=2
> >>>       gcc_cv_as_compress_debug_option="--compress-debug-sections"
> >>>       gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
> >>> -   # Before binutils 2.26, gas only supported --compress-debug-options and
> >>> -   # emitted the traditional GNU format.
> >>> -   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
> >>>     fi])
> >>> @@ -6131,42 +6124,28 @@ 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
> >>> -# In binutils 2.26, gld gained support for the ELF gABI format.
> >>> +# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
> >>>  if test $in_tree_ld = yes ; then
> >>>    gcc_cv_ld_compress_debug=0
> >>>    if test $ld_is_mold = yes; then
> >>>      gcc_cv_ld_compress_debug=3
> >>>      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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
> >>>       && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
> >>>      gcc_cv_ld_compress_debug=3
> >>>      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
> >>>    if test $ld_is_mold = yes; then
> >>>      gcc_cv_ld_compress_debug=3
> >>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> >>>    elif test "$ld_vers_major" -lt 2 \
> >>> -     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
> >>> +     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
> >>>      gcc_cv_ld_compress_debug=0
> >>> -  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
> >>> -    gcc_cv_ld_compress_debug=1
> >>>    else
> >>>      gcc_cv_ld_compress_debug=3
> >>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> >>>    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
> >>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> >>> index 757775ea576..467659cb094 100644
> >>> --- a/gcc/doc/invoke.texi
> >>> +++ b/gcc/doc/invoke.texi
> >>> @@ -10775,12 +10775,11 @@ location views are enabled.
> >>>  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
> >>> -@samp{none} (don't compress debug sections), @samp{zlib} (use zlib
> >>> -compression in ELF gABI format), or @samp{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.
> >>> +@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
> >>> +compression in ELF gABI 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.
> >>>
> >>>  @item -femit-struct-debug-baseonly
> >>>  @opindex femit-struct-debug-baseonly
> >>> diff --git a/gcc/gcc.cc b/gcc/gcc.cc
> >>> index 5cbb38560b2..660cd6f4ef4 100644
> >>> --- a/gcc/gcc.cc
> >>> +++ b/gcc/gcc.cc
> >>> @@ -827,22 +827,11 @@ proper position among the other output files.  */
> >>>  /* 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} "
> >>> +       " %{gz=none:"     LD_COMPRESS_DEBUG_OPTION "=none}"
> >>>  #else
> >>>  #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
> >>>  #endif
> >>> @@ -891,18 +880,11 @@ proper position among the other output files.  */
> >>>  /* 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} "
> >>> +       " %{gz=none:"     AS_COMPRESS_DEBUG_OPTION "=none}"
> >>>  #else
> >>>  #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
> >>>  #endif
> >>> --
> >>> 2.37.0.rc0.161.g10f37bed90-goog
> >>>
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Remove legacy -gz=zlib-gnu
  2022-09-21  7:36       ` Richard Biener
@ 2022-09-21  7:45         ` Fangrui Song
  2022-09-21  7:49         ` Martin Liška
  1 sibling, 0 replies; 14+ messages in thread
From: Fangrui Song @ 2022-09-21  7:45 UTC (permalink / raw)
  To: Richard Biener
  Cc: Martin Liška, Andrew Pinski, Fangrui Song, GCC Patches

On Wed, Sep 21, 2022 at 12:37 AM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Tue, Sep 20, 2022 at 2:55 PM Martin Liška <mliska@suse.cz> wrote:
> >
> > On 7/1/22 09:20, Fangrui Song via Gcc-patches wrote:
> > > On 2022-07-01, Andrew Pinski wrote:
> > >> On Thu, Jun 30, 2022 at 11:58 PM Fangrui Song via Gcc-patches
> > >> <gcc-patches@gcc.gnu.org> wrote:
> > >>>
> > >>> From: Fangrui Song <i@maskray.me>
> > >>>
> > >>> SHF_COMPRESSED style zlib has been supported since binutils 2.26
> > >>> and the legacy zlib-gnu option hasn't gain adoption.
> > >>> According to Debian Code Search (`gz=zlib-gnu`), no project uses
> > >>> -gz=zlib-gnu (valgrind has a configure to use -gz=zlib).
> > >>> Remove support for the legacy zlib-gnu and simplify configure.ac by
> > >>> removing zlib-gnu ld/as check.
> > >>
> > >> A couple of things, you are missing a changelog.
> > >
> > > Sorry.
> > >
> > >> Second, why remove something which is still working?
> >
> > Hi.
> >
> > I do support the option removal, while I would replace the removal with a warning
> > saying no compression will be used.
> >
> > >
> > > It's unused and its existence causes confusion: the paradox of choice.
> > > People may assume the support may be good but newer DWARF consumers may
> > > not support the legacy format.
> >
> > Agree, the compression format is legacy. I verified all openSUSE packages (15k)
> > and there's no project actively using it.
> >
> > >
> > > The other motivation is to clean up it a bit.  I foresee that someone
> > > will add --compress-debug-sections=zstd to binutils and configure.ac and
> > > gcc/gcc.cc would become more messy.
> >
> > The argument makes sense, it will be even bigger mess.
> >
> > @Richi: Is it something we can deprecate for GCC 13?
>
> What's the practical difference between zlib and zlib-gnu?  Can we just
> map zlib-gnu to zlib?  If it's all configure time what's the point in
> "deprecating" it?

zlib-gnu uses the legacy .zdebug section name with a "ZLIB" magic:
http://www.linker-aliens.org/blogs/ali/entry/elf_section_compression/
https://maskray.me/blog/2022-01-23-compressed-debug-sections has some
history about how the zlib-gabi replacement: ELFCOMPRESS_ZLIB .

FWIW I removed -gz=zlib-gnu from clang and .zdebug support from
various llvm-project tools.

I cannot really find uses of -gz=zlib-gnu in the wild. Users can
always fallback to -Wa, and -Wl, if their tools are so old that
ELFCOMPRESS_ZLIB is unsupported.

> Richard.
>
> >
> > Martin
> >
> > >
> > >> Third, why not just make gz=zlib-gnu as an alias to gz=zlib instead so
> > >> if someone used it before it will still work. we try not to remove
> > >> options; have them emit a warning and be ignored (or moved over to the
> > >> closed option).
> > >
> > > Changing the semantics of -gz=zlib-gnu would be even more confusing.
> > >
> > >> Thanks,
> > >> Andrew
> > >>
> > >>> ---
> > >>>  gcc/common.opt      |  3 ---
> > >>>  gcc/configure       | 33 ++++++---------------------------
> > >>>  gcc/configure.ac    | 29 ++++-------------------------
> > >>>  gcc/doc/invoke.texi | 11 +++++------
> > >>>  gcc/gcc.cc          | 22 ++--------------------
> > >>>  5 files changed, 17 insertions(+), 81 deletions(-)
> > >>>
> > >>> diff --git a/gcc/common.opt b/gcc/common.opt
> > >>> index e7a51e882ba..8754d93d545 100644
> > >>> --- a/gcc/common.opt
> > >>> +++ b/gcc/common.opt
> > >>> @@ -3424,9 +3424,6 @@ 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.
> > >>> diff --git a/gcc/configure b/gcc/configure
> > >>> index 62872d132ea..ca87e875e9d 100755
> > >>> --- a/gcc/configure
> > >>> +++ b/gcc/configure
> > >>> @@ -19674,7 +19674,7 @@ else
> > >>>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> > >>>    lt_status=$lt_dlunknown
> > >>>    cat > conftest.$ac_ext <<_LT_EOF
> > >>> -#line 19679 "configure"
> > >>> +#line 19677 "configure"
> > >>>  #include "confdefs.h"
> > >>>
> > >>>  #if HAVE_DLFCN_H
> > >>> @@ -19780,7 +19780,7 @@ else
> > >>>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> > >>>    lt_status=$lt_dlunknown
> > >>>    cat > conftest.$ac_ext <<_LT_EOF
> > >>> -#line 19785 "configure"
> > >>> +#line 19783 "configure"
> > >>>  #include "confdefs.h"
> > >>>
> > >>>  #if HAVE_DLFCN_H
> > >>> @@ -29711,20 +29711,13 @@ else
> > >>>     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
> > >>> -   # Since binutils 2.26, gas supports --compress-debug-sections=type,
> > >>> +   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
> > >>>     # defaulting to the ELF gABI format.
> > >>> -   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
> > >>> +   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
> > >>>     then
> > >>>       gcc_cv_as_compress_debug=2
> > >>>       gcc_cv_as_compress_debug_option="--compress-debug-sections"
> > >>>       gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
> > >>> -   # Before binutils 2.26, gas only supported --compress-debug-options and
> > >>> -   # emitted the traditional GNU format.
> > >>> -   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
> > >>>     fi
> > >>> @@ -30238,42 +30231,28 @@ $as_echo "$gcc_cv_ld_eh_gc_sections_bug" >&6; }
> > >>>
> > >>>  { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for compressed debug sections" >&5
> > >>>  $as_echo_n "checking linker for compressed debug sections... " >&6; }
> > >>> -# gold/gld support compressed debug sections since binutils 2.19/2.21
> > >>> -# In binutils 2.26, gld gained support for the ELF gABI format.
> > >>> +# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
> > >>>  if test $in_tree_ld = yes ; then
> > >>>    gcc_cv_ld_compress_debug=0
> > >>>    if test $ld_is_mold = yes; then
> > >>>      gcc_cv_ld_compress_debug=3
> > >>>      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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
> > >>>       && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
> > >>>      gcc_cv_ld_compress_debug=3
> > >>>      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
> > >>>    if test $ld_is_mold = yes; then
> > >>>      gcc_cv_ld_compress_debug=3
> > >>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> > >>>    elif test "$ld_vers_major" -lt 2 \
> > >>> -     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
> > >>> +     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
> > >>>      gcc_cv_ld_compress_debug=0
> > >>> -  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
> > >>> -    gcc_cv_ld_compress_debug=1
> > >>>    else
> > >>>      gcc_cv_ld_compress_debug=3
> > >>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> > >>>    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
> > >>>    case "${target}" in
> > >>>      *-*-solaris2*)
> > >>> diff --git a/gcc/configure.ac b/gcc/configure.ac
> > >>> index 446747311a6..f40f75271c2 100644
> > >>> --- a/gcc/configure.ac
> > >>> +++ b/gcc/configure.ac
> > >>> @@ -5733,20 +5733,13 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
> > >>>     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
> > >>> -   # Since binutils 2.26, gas supports --compress-debug-sections=type,
> > >>> +   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
> > >>>     # defaulting to the ELF gABI format.
> > >>> -   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
> > >>> +   elif $gcc_cv_as --compress-debug-sections=zlib -o conftest.o conftest.s > /dev/null 2>&1
> > >>>     then
> > >>>       gcc_cv_as_compress_debug=2
> > >>>       gcc_cv_as_compress_debug_option="--compress-debug-sections"
> > >>>       gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
> > >>> -   # Before binutils 2.26, gas only supported --compress-debug-options and
> > >>> -   # emitted the traditional GNU format.
> > >>> -   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
> > >>>     fi])
> > >>> @@ -6131,42 +6124,28 @@ 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
> > >>> -# In binutils 2.26, gld gained support for the ELF gABI format.
> > >>> +# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
> > >>>  if test $in_tree_ld = yes ; then
> > >>>    gcc_cv_ld_compress_debug=0
> > >>>    if test $ld_is_mold = yes; then
> > >>>      gcc_cv_ld_compress_debug=3
> > >>>      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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
> > >>>       && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
> > >>>      gcc_cv_ld_compress_debug=3
> > >>>      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
> > >>>    if test $ld_is_mold = yes; then
> > >>>      gcc_cv_ld_compress_debug=3
> > >>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> > >>>    elif test "$ld_vers_major" -lt 2 \
> > >>> -     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
> > >>> +     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
> > >>>      gcc_cv_ld_compress_debug=0
> > >>> -  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
> > >>> -    gcc_cv_ld_compress_debug=1
> > >>>    else
> > >>>      gcc_cv_ld_compress_debug=3
> > >>>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> > >>>    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
> > >>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> > >>> index 757775ea576..467659cb094 100644
> > >>> --- a/gcc/doc/invoke.texi
> > >>> +++ b/gcc/doc/invoke.texi
> > >>> @@ -10775,12 +10775,11 @@ location views are enabled.
> > >>>  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
> > >>> -@samp{none} (don't compress debug sections), @samp{zlib} (use zlib
> > >>> -compression in ELF gABI format), or @samp{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.
> > >>> +@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
> > >>> +compression in ELF gABI 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.
> > >>>
> > >>>  @item -femit-struct-debug-baseonly
> > >>>  @opindex femit-struct-debug-baseonly
> > >>> diff --git a/gcc/gcc.cc b/gcc/gcc.cc
> > >>> index 5cbb38560b2..660cd6f4ef4 100644
> > >>> --- a/gcc/gcc.cc
> > >>> +++ b/gcc/gcc.cc
> > >>> @@ -827,22 +827,11 @@ proper position among the other output files.  */
> > >>>  /* 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} "
> > >>> +       " %{gz=none:"     LD_COMPRESS_DEBUG_OPTION "=none}"
> > >>>  #else
> > >>>  #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
> > >>>  #endif
> > >>> @@ -891,18 +880,11 @@ proper position among the other output files.  */
> > >>>  /* 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} "
> > >>> +       " %{gz=none:"     AS_COMPRESS_DEBUG_OPTION "=none}"
> > >>>  #else
> > >>>  #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
> > >>>  #endif
> > >>> --
> > >>> 2.37.0.rc0.161.g10f37bed90-goog
> > >>>
> >



-- 
宋方睿

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Remove legacy -gz=zlib-gnu
  2022-09-21  7:36       ` Richard Biener
  2022-09-21  7:45         ` Fangrui Song
@ 2022-09-21  7:49         ` Martin Liška
  2022-09-21  9:35           ` Richard Biener
  1 sibling, 1 reply; 14+ messages in thread
From: Martin Liška @ 2022-09-21  7:49 UTC (permalink / raw)
  To: Richard Biener; +Cc: Fangrui Song, Andrew Pinski, Fangrui Song, GCC Patches

On 9/21/22 09:36, Richard Biener wrote:
> If it's all configure time what's the point in
> "deprecating" it?

Note it's one of our options -gz where 'zlib-gnu' is one of the possible option values.

Martin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Remove legacy -gz=zlib-gnu
  2022-09-21  7:49         ` Martin Liška
@ 2022-09-21  9:35           ` Richard Biener
  2022-09-22 11:10             ` [PATCH] remove -gz=zlib-gnu option value Martin Liška
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Biener @ 2022-09-21  9:35 UTC (permalink / raw)
  To: Martin Liška; +Cc: Fangrui Song, Andrew Pinski, Fangrui Song, GCC Patches

On Wed, Sep 21, 2022 at 9:49 AM Martin Liška <mliska@suse.cz> wrote:
>
> On 9/21/22 09:36, Richard Biener wrote:
> > If it's all configure time what's the point in
> > "deprecating" it?
>
> Note it's one of our options -gz where 'zlib-gnu' is one of the possible option values.

I see.  Not sure if deprecating is really necessary, you need to keep
recognizing
zlib-gnu as no-op anyway.  So I'd just go ahead and remove support for it.

> Martin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] remove -gz=zlib-gnu option value
  2022-09-21  9:35           ` Richard Biener
@ 2022-09-22 11:10             ` Martin Liška
  2022-09-22 12:26               ` [PATCH v2] " Martin Liška
  0 siblings, 1 reply; 14+ messages in thread
From: Martin Liška @ 2022-09-22 11:10 UTC (permalink / raw)
  To: Richard Biener; +Cc: Fangrui Song, Andrew Pinski, Fangrui Song, GCC Patches

[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

On 9/21/22 11:35, Richard Biener wrote:
> On Wed, Sep 21, 2022 at 9:49 AM Martin Liška <mliska@suse.cz> wrote:
>>
>> On 9/21/22 09:36, Richard Biener wrote:
>>> If it's all configure time what's the point in
>>> "deprecating" it?
>>
>> Note it's one of our options -gz where 'zlib-gnu' is one of the possible option values.
> 
> I see.  Not sure if deprecating is really necessary, you need to keep
> recognizing
> zlib-gnu as no-op anyway.  So I'd just go ahead and remove support for it.

Hi.

I'm sending patch that makes it no-op and simplifies more the configure.ac detection.

Tested with both ld.bfd and mold:

$ ./xgcc -B. ~/Programming/testcases/a.c -c -gz=zlib --save-temps --verbose 2>&1 | grep =zlib | grep -v COLLECT_GCC_OPTIONS
 ./cc1 -fpreprocessed a.i -quiet -dumpbase a.c -dumpbase-ext .c -mtune=generic -march=x86-64 -gz=zlib -version -o a.s
 ./as -v --compress-debug-sections=zlib --64 -o a.o a.s

$ ./xgcc -B. ~/Programming/testcases/a.c -c -gz=zlib-gnu --save-temps --verbose 2>&1 | grep =zlib | grep -v COLLECT_GCC_OPTIONS
 ./cc1 -fpreprocessed a.i -quiet -dumpbase a.c -dumpbase-ext .c -mtune=generic -march=x86-64 -gz=zlib-gnu -version -o a.s

Ready after it finishes tests?
Thanks,
Martin

> 
>> Martin

[-- Attachment #2: 0001-remove-gz-zlib-gnu-option-value.patch --]
[-- Type: text/x-patch, Size: 12396 bytes --]

From 979ab57b853cee002d29d1ac9199021a1866e4fb Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 22 Sep 2022 13:04:57 +0200
Subject: [PATCH] remove -gz=zlib-gnu option value

The option value is legacy and probably not used at all,
thus ignore it.

gcc/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Simplify to gcc_cv_ld_compress_debug={0,1}
	and gcc_cv_as_compress_debug={0,1}.
	* doc/invoke.texi: Document the removal.
	* gcc.cc (LINK_COMPRESS_DEBUG_SPEC): Simplify and ignore
	  zlib-gnu.
	(ASM_COMPRESS_DEBUG_SPEC): Likewise.

Co-Authored-By: Fangrui Song <i@maskray.me>
---
 gcc/configure       | 39 +++++++++------------------------------
 gcc/configure.ac    | 39 +++++++++------------------------------
 gcc/doc/invoke.texi | 11 +++++------
 gcc/gcc.cc          | 26 +++++---------------------
 4 files changed, 28 insertions(+), 87 deletions(-)

diff --git a/gcc/configure b/gcc/configure
index 817d765568e..3cea801d5a7 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -29727,16 +29727,9 @@ else
    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
-   # Since binutils 2.26, gas supports --compress-debug-sections=type,
+   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
    # defaulting to the ELF gABI format.
-   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
-   then
-     gcc_cv_as_compress_debug=2
-     gcc_cv_as_compress_debug_option="--compress-debug-sections"
-     gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
-   # Before binutils 2.26, gas only supported --compress-debug-options and
-   # emitted the traditional GNU format.
-   elif $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s > /dev/null 2>&1
+   elif $gcc_cv_as --compress-debug-sections=zlib -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"
@@ -30254,40 +30247,26 @@ $as_echo "$gcc_cv_ld_eh_gc_sections_bug" >&6; }
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for compressed debug sections" >&5
 $as_echo_n "checking linker for compressed debug sections... " >&6; }
-# gold/gld support compressed debug sections since binutils 2.19/2.21
-# In binutils 2.26, gld gained support for the ELF gABI format.
+# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
 if test $in_tree_ld = yes ; then
   gcc_cv_ld_compress_debug=0
   if test $ld_is_mold = yes; then
-    gcc_cv_ld_compress_debug=3
-    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 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=1
     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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
      && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
-    gcc_cv_ld_compress_debug=3
-    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
+    gcc_cv_ld_compress_debug_option="--compress-debug-sections"
   fi
 elif echo "$ld_ver" | grep GNU > /dev/null; then
   if test $ld_is_mold = yes; then
-    gcc_cv_ld_compress_debug=3
+    gcc_cv_ld_compress_debug=1
     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
   elif test "$ld_vers_major" -lt 2 \
-     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
+     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
     gcc_cv_ld_compress_debug=0
-  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
-    gcc_cv_ld_compress_debug=1
   else
-    gcc_cv_ld_compress_debug=3
-    gcc_cv_ld_compress_debug_option="--compress-debug-sections"
-  fi
-  if test $ld_is_gold = yes; then
-    gcc_cv_ld_compress_debug=2
+    gcc_cv_ld_compress_debug=1
     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
   fi
 else
@@ -30295,7 +30274,7 @@ else
     *-*-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=1
         gcc_cv_ld_compress_debug_option="-z compress-sections"
       else
         gcc_cv_ld_compress_debug=0
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 59f205a1781..b9a39d62d30 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5732,16 +5732,9 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
    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
-   # Since binutils 2.26, gas supports --compress-debug-sections=type,
+   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
    # defaulting to the ELF gABI format.
-   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
-   then
-     gcc_cv_as_compress_debug=2
-     gcc_cv_as_compress_debug_option="--compress-debug-sections"
-     gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
-   # Before binutils 2.26, gas only supported --compress-debug-options and
-   # emitted the traditional GNU format.
-   elif $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s > /dev/null 2>&1
+   elif $gcc_cv_as --compress-debug-sections=zlib -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"
@@ -6130,40 +6123,26 @@ 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
-# In binutils 2.26, gld gained support for the ELF gABI format.
+# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
 if test $in_tree_ld = yes ; then
   gcc_cv_ld_compress_debug=0
   if test $ld_is_mold = yes; then
-    gcc_cv_ld_compress_debug=3
-    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 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=1
     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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
      && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
-    gcc_cv_ld_compress_debug=3
-    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
+    gcc_cv_ld_compress_debug_option="--compress-debug-sections"
   fi
 elif echo "$ld_ver" | grep GNU > /dev/null; then
   if test $ld_is_mold = yes; then
-    gcc_cv_ld_compress_debug=3
+    gcc_cv_ld_compress_debug=1
     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
   elif test "$ld_vers_major" -lt 2 \
-     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
+     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
     gcc_cv_ld_compress_debug=0
-  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
-    gcc_cv_ld_compress_debug=1
   else
-    gcc_cv_ld_compress_debug=3
-    gcc_cv_ld_compress_debug_option="--compress-debug-sections"
-  fi
-  if test $ld_is_gold = yes; then
-    gcc_cv_ld_compress_debug=2
+    gcc_cv_ld_compress_debug=1
     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
   fi
 else
@@ -6172,7 +6151,7 @@ changequote(,)dnl
     *-*-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=1
         gcc_cv_ld_compress_debug_option="-z compress-sections"
       else
         gcc_cv_ld_compress_debug=0
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index aa5655764a0..9fdcb5f60d9 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -11077,12 +11077,11 @@ location views are enabled.
 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
-@samp{none} (don't compress debug sections), @samp{zlib} (use zlib
-compression in ELF gABI format), or @samp{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.
+@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
+compression in ELF gABI 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.
 
 @item -femit-struct-debug-baseonly
 @opindex femit-struct-debug-baseonly
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 15846116795..7578988efa9 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -831,21 +831,11 @@ proper position among the other output files.  */
 #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} "
+	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
 #else
 #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
 #endif
@@ -885,31 +875,25 @@ proper position among the other output files.  */
 #endif
 
 /* Assembler options for compressed debug sections.  */
-#if HAVE_LD_COMPRESS_DEBUG < 2
+#if HAVE_LD_COMPRESS_DEBUG == 0
 /* 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 */
+#else /* HAVE_LD_COMPRESS_DEBUG >= 1 */
 #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} "
+	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
 #else
 #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
 #endif
-#endif /* HAVE_LD_COMPRESS_DEBUG >= 2 */
+#endif /* HAVE_LD_COMPRESS_DEBUG >= 1 */
 
 /* Define ASM_DEBUG_SPEC to be a spec suitable for translating '-g'
    to the assembler, when compiling assembly sources only.  */
-- 
2.37.3


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2] remove -gz=zlib-gnu option value
  2022-09-22 11:10             ` [PATCH] remove -gz=zlib-gnu option value Martin Liška
@ 2022-09-22 12:26               ` Martin Liška
  2022-09-22 12:35                 ` Richard Biener
  0 siblings, 1 reply; 14+ messages in thread
From: Martin Liška @ 2022-09-22 12:26 UTC (permalink / raw)
  To: Richard Biener; +Cc: Fangrui Song, GCC Patches

[-- Attachment #1: Type: text/plain, Size: 255 bytes --]

Hi.

I have a better version of the patch where section compression detection is based
on ld --help, rather than a particular binutils version.
That's much easier and all ld, ld.bfd and mold use the very same option.

Ready to be installed?
Thanks,
Martin

[-- Attachment #2: 0001-remove-gz-zlib-gnu-option-value-v2.patch --]
[-- Type: text/x-patch, Size: 12136 bytes --]

From d2314c942c5c19a5fd5d6b2d45750d863636873c Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 22 Sep 2022 13:04:57 +0200
Subject: [PATCH] remove -gz=zlib-gnu option value

The option value is legacy and probably not used at all,
thus ignore it.

gcc/ChangeLog:

	* configure: Regenerate.
	* configure.ac: Simplify to gcc_cv_ld_compress_debug={0,1}
	and gcc_cv_as_compress_debug={0,1}.
	* doc/invoke.texi: Document the removal.
	* gcc.cc (LINK_COMPRESS_DEBUG_SPEC): Simplify and ignore
	  zlib-gnu.
	(ASM_COMPRESS_DEBUG_SPEC): Likewise.

Co-Authored-By: Fangrui Song <i@maskray.me>
---
 gcc/configure       | 49 +++++----------------------------------------
 gcc/configure.ac    | 49 +++++----------------------------------------
 gcc/doc/invoke.texi | 11 +++++-----
 gcc/gcc.cc          | 26 +++++-------------------
 4 files changed, 20 insertions(+), 115 deletions(-)

diff --git a/gcc/configure b/gcc/configure
index 817d765568e..70a013e9a30 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -29727,16 +29727,9 @@ else
    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
-   # Since binutils 2.26, gas supports --compress-debug-sections=type,
+   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
    # defaulting to the ELF gABI format.
-   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
-   then
-     gcc_cv_as_compress_debug=2
-     gcc_cv_as_compress_debug_option="--compress-debug-sections"
-     gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
-   # Before binutils 2.26, gas only supported --compress-debug-options and
-   # emitted the traditional GNU format.
-   elif $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s > /dev/null 2>&1
+   elif $gcc_cv_as --compress-debug-sections=zlib -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"
@@ -30254,48 +30247,16 @@ $as_echo "$gcc_cv_ld_eh_gc_sections_bug" >&6; }
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker for compressed debug sections" >&5
 $as_echo_n "checking linker for compressed debug sections... " >&6; }
-# gold/gld support compressed debug sections since binutils 2.19/2.21
-# In binutils 2.26, gld gained support for the ELF gABI format.
-if test $in_tree_ld = yes ; then
-  gcc_cv_ld_compress_debug=0
-  if test $ld_is_mold = yes; then
-    gcc_cv_ld_compress_debug=3
-    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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
-     && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
-    gcc_cv_ld_compress_debug=3
-    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
+# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
+if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zlib-gabi\>' > /dev/null; then
     gcc_cv_ld_compress_debug=1
-  fi
-elif echo "$ld_ver" | grep GNU > /dev/null; then
-  if test $ld_is_mold = yes; then
-    gcc_cv_ld_compress_debug=3
-    gcc_cv_ld_compress_debug_option="--compress-debug-sections"
-  elif test "$ld_vers_major" -lt 2 \
-     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
-    gcc_cv_ld_compress_debug=0
-  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
-    gcc_cv_ld_compress_debug=1
-  else
-    gcc_cv_ld_compress_debug=3
-    gcc_cv_ld_compress_debug_option="--compress-debug-sections"
-  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
   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=1
         gcc_cv_ld_compress_debug_option="-z compress-sections"
       else
         gcc_cv_ld_compress_debug=0
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 59f205a1781..96e10d7c194 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5732,16 +5732,9 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
    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
-   # Since binutils 2.26, gas supports --compress-debug-sections=type,
+   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
    # defaulting to the ELF gABI format.
-   elif $gcc_cv_as --compress-debug-sections=zlib-gnu -o conftest.o conftest.s > /dev/null 2>&1
-   then
-     gcc_cv_as_compress_debug=2
-     gcc_cv_as_compress_debug_option="--compress-debug-sections"
-     gcc_cv_as_no_compress_debug_option="--nocompress-debug-sections"
-   # Before binutils 2.26, gas only supported --compress-debug-options and
-   # emitted the traditional GNU format.
-   elif $gcc_cv_as --compress-debug-sections -o conftest.o conftest.s > /dev/null 2>&1
+   elif $gcc_cv_as --compress-debug-sections=zlib -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"
@@ -6130,49 +6123,17 @@ 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
-# In binutils 2.26, gld gained support for the ELF gABI format.
-if test $in_tree_ld = yes ; then
-  gcc_cv_ld_compress_debug=0
-  if test $ld_is_mold = yes; then
-    gcc_cv_ld_compress_debug=3
-    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 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 26 -o "$gcc_cv_gld_major_version" -gt 2 \
-     && test $in_tree_ld_is_elf = yes && test $ld_is_gold = no; then
-    gcc_cv_ld_compress_debug=3
-    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
+# GNU ld/gold support --compressed-debug-sections=zlib since binutils 2.26.
+if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zlib-gabi\>' > /dev/null; then
     gcc_cv_ld_compress_debug=1
-  fi
-elif echo "$ld_ver" | grep GNU > /dev/null; then
-  if test $ld_is_mold = yes; then
-    gcc_cv_ld_compress_debug=3
-    gcc_cv_ld_compress_debug_option="--compress-debug-sections"
-  elif test "$ld_vers_major" -lt 2 \
-     || test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 21; then
-    gcc_cv_ld_compress_debug=0
-  elif test "$ld_vers_major" -eq 2 -a "$ld_vers_minor" -lt 26; then
-    gcc_cv_ld_compress_debug=1
-  else
-    gcc_cv_ld_compress_debug=3
-    gcc_cv_ld_compress_debug_option="--compress-debug-sections"
-  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=1
         gcc_cv_ld_compress_debug_option="-z compress-sections"
       else
         gcc_cv_ld_compress_debug=0
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index aa5655764a0..9fdcb5f60d9 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -11077,12 +11077,11 @@ location views are enabled.
 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
-@samp{none} (don't compress debug sections), @samp{zlib} (use zlib
-compression in ELF gABI format), or @samp{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.
+@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
+compression in ELF gABI 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.
 
 @item -femit-struct-debug-baseonly
 @opindex femit-struct-debug-baseonly
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 15846116795..7578988efa9 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -831,21 +831,11 @@ proper position among the other output files.  */
 #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} "
+	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
 #else
 #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
 #endif
@@ -885,31 +875,25 @@ proper position among the other output files.  */
 #endif
 
 /* Assembler options for compressed debug sections.  */
-#if HAVE_LD_COMPRESS_DEBUG < 2
+#if HAVE_LD_COMPRESS_DEBUG == 0
 /* 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 */
+#else /* HAVE_LD_COMPRESS_DEBUG >= 1 */
 #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} "
+	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
 #else
 #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
 #endif
-#endif /* HAVE_LD_COMPRESS_DEBUG >= 2 */
+#endif /* HAVE_LD_COMPRESS_DEBUG >= 1 */
 
 /* Define ASM_DEBUG_SPEC to be a spec suitable for translating '-g'
    to the assembler, when compiling assembly sources only.  */
-- 
2.37.3


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2] remove -gz=zlib-gnu option value
  2022-09-22 12:26               ` [PATCH v2] " Martin Liška
@ 2022-09-22 12:35                 ` Richard Biener
  2022-09-22 12:51                   ` [PATCH] support -gz=zstd for both linker and assembler Martin Liška
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Biener @ 2022-09-22 12:35 UTC (permalink / raw)
  To: Martin Liška; +Cc: Fangrui Song, GCC Patches

On Thu, Sep 22, 2022 at 2:26 PM Martin Liška <mliska@suse.cz> wrote:
>
> Hi.
>
> I have a better version of the patch where section compression detection is based
> on ld --help, rather than a particular binutils version.
> That's much easier and all ld, ld.bfd and mold use the very same option.
>
> Ready to be installed?

OK.  Can you document the change in changes.html?

> Thanks,
> Martin

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] support -gz=zstd for both linker and assembler
  2022-09-22 12:35                 ` Richard Biener
@ 2022-09-22 12:51                   ` Martin Liška
  2022-09-27 13:54                     ` Martin Liška
  0 siblings, 1 reply; 14+ messages in thread
From: Martin Liška @ 2022-09-22 12:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: Fangrui Song, Richard Biener

Hi.

Tested with Fangrui's patch set sent to binutils ML and mold linker.

$ gcc -g -gz=zstd a.c --save-temps --verbose 2>&1 | grep debug-sections
 /home/marxin/Programming/binutils/objdir/gas/as-new -v --gdwarf-5 --compress-debug-sections=zstd --64 -o a.o a.s
 /home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/collect2 -plugin /home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/liblto_plugin.so -plugin-opt=/home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper -plugin-opt=-fresolution=a.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 --compress-debug-sections=zstd /lib/../lib64/crt1.o /lib/../lib64/crti.o /home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/crtbegin.o -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0 -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/../../.. a.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/crtend.o /lib/../lib64/crtn.o

$ gdb a.out
...
BFD: /home/marxin/Programming/testcases/a.out: unable to initialize decompress status for section .debug_abbrev
BFD: /home/marxin/Programming/testcases/a.out: unable to initialize decompress status for section .debug_abbrev
"/home/marxin/Programming/testcases/a.out": not in executable format: file format not recognized

So it's really compressed with zstd. I'm going to write ChangeLog entry for zlib-gnu once this gets merged as well.

Ready to be installed?
Thanks,
Martin

	PR driver/106897

gcc/ChangeLog:

	* common.opt: Add -gz=zstd value.
	* configure.ac: Detect --compress-debug-sections=zstd
	for both linker and assembler.
	* configure: Regenerate.
	* gcc.cc (LINK_COMPRESS_DEBUG_SPEC): Handle -gz=zstd.
	(ASM_COMPRESS_DEBUG_SPEC): Likewise.
---
 gcc/common.opt   |  5 ++++-
 gcc/configure    | 11 +++++++++--
 gcc/configure.ac | 11 +++++++++--
 gcc/gcc.cc       | 15 +++++++++++++++
 4 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 06ef768ab78..68370db816b 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -3419,7 +3419,10 @@ EnumValue
 Enum(compressed_debug_sections) String(zlib) Value(1)
 
 EnumValue
-Enum(compressed_debug_sections) String(zlib-gnu) Value(2)
+Enum(compressed_debug_sections) String(zstd) Value(2)
+
+EnumValue
+Enum(compressed_debug_sections) String(zlib-gnu) Value(3)
 
 gz
 Common Driver
diff --git a/gcc/configure b/gcc/configure
index 70a013e9a30..ce4e1859e1f 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -29727,13 +29727,16 @@ else
    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
-   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
-   # defaulting to the ELF gABI format.
    elif $gcc_cv_as --compress-debug-sections=zlib -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"
+     # Since binutils 2.40, gas supports --compress-debug-sections=zstd.
+     if $gcc_cv_as --compress-debug-sections=zstd -o conftest.o conftest.s > /dev/null 2>&1
+     then
+       gcc_cv_as_compress_debug=2
+     fi
    else
      gcc_cv_as_compress_debug=0
    fi
@@ -30251,6 +30254,10 @@ $as_echo_n "checking linker for compressed debug sections... " >&6; }
 if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zlib-gabi\>' > /dev/null; then
     gcc_cv_ld_compress_debug=1
     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
+    # Detect zstd debug section compression support
+    if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zstd\>' > /dev/null; then
+      gcc_cv_ld_compress_debug=2
+    fi
 else
   case "${target}" in
     *-*-solaris2*)
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 96e10d7c194..b6bafa8b7d6 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5732,13 +5732,16 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
    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
-   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
-   # defaulting to the ELF gABI format.
    elif $gcc_cv_as --compress-debug-sections=zlib -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"
+     # Since binutils 2.40, gas supports --compress-debug-sections=zstd.
+     if $gcc_cv_as --compress-debug-sections=zstd -o conftest.o conftest.s > /dev/null 2>&1
+     then
+       gcc_cv_as_compress_debug=2
+     fi
    else
      gcc_cv_as_compress_debug=0
    fi])
@@ -6127,6 +6130,10 @@ AC_MSG_CHECKING(linker for compressed debug sections)
 if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zlib-gabi\>' > /dev/null; then
     gcc_cv_ld_compress_debug=1
     gcc_cv_ld_compress_debug_option="--compress-debug-sections"
+    # Detect zstd debug section compression support
+    if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zstd\>' > /dev/null; then
+      gcc_cv_ld_compress_debug=2
+    fi
 else
 changequote(,)dnl
   case "${target}" in
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 7578988efa9..2ffbbc0bf2a 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -835,6 +835,14 @@ proper position among the other output files.  */
 #define LINK_COMPRESS_DEBUG_SPEC \
 	" %{gz|gz=zlib:"  LD_COMPRESS_DEBUG_OPTION "=zlib}" \
 	" %{gz=none:"	  LD_COMPRESS_DEBUG_OPTION "=none}" \
+	" %{gz*:%e-gz=zstd is not supported in this configuration} " \
+	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
+#elif HAVE_LD_COMPRESS_DEBUG == 2
+/* ELF gABI style and ZSTD.  */
+#define LINK_COMPRESS_DEBUG_SPEC \
+	" %{gz|gz=zlib:"  LD_COMPRESS_DEBUG_OPTION "=zlib}" \
+	" %{gz=none:"	  LD_COMPRESS_DEBUG_OPTION "=none}" \
+	" %{gz=zstd:"	  LD_COMPRESS_DEBUG_OPTION "=zstd}" \
 	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
 #else
 #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
@@ -890,6 +898,13 @@ proper position among the other output files.  */
 	" %{gz|gz=zlib:"  AS_COMPRESS_DEBUG_OPTION "=zlib}" \
 	" %{gz=none:"	  AS_COMPRESS_DEBUG_OPTION "=none}" \
 	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
+#elif HAVE_AS_COMPRESS_DEBUG == 2
+/* ELF gABI style and ZSTD.  */
+#define ASM_COMPRESS_DEBUG_SPEC \
+	" %{gz|gz=zlib:"  AS_COMPRESS_DEBUG_OPTION "=zlib}" \
+	" %{gz=none:"	  AS_COMPRESS_DEBUG_OPTION "=none}" \
+	" %{gz=zstd:"	  AS_COMPRESS_DEBUG_OPTION "=zstd}" \
+	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
 #else
 #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
 #endif
-- 
2.37.3


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] support -gz=zstd for both linker and assembler
  2022-09-22 12:51                   ` [PATCH] support -gz=zstd for both linker and assembler Martin Liška
@ 2022-09-27 13:54                     ` Martin Liška
  2022-09-28 19:21                       ` Richard Biener
  0 siblings, 1 reply; 14+ messages in thread
From: Martin Liška @ 2022-09-27 13:54 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Biener

PING^1

On 9/22/22 14:51, Martin Liška wrote:
> Hi.
> 
> Tested with Fangrui's patch set sent to binutils ML and mold linker.
> 
> $ gcc -g -gz=zstd a.c --save-temps --verbose 2>&1 | grep debug-sections
>  /home/marxin/Programming/binutils/objdir/gas/as-new -v --gdwarf-5 --compress-debug-sections=zstd --64 -o a.o a.s
>  /home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/collect2 -plugin /home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/liblto_plugin.so -plugin-opt=/home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper -plugin-opt=-fresolution=a.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 --compress-debug-sections=zstd /lib/../lib64/crt1.o /lib/../lib64/crti.o /home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/crtbegin.o -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0 -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/../../.. a.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/crtend.o /lib/../lib64/crtn.o
> 
> $ gdb a.out
> ...
> BFD: /home/marxin/Programming/testcases/a.out: unable to initialize decompress status for section .debug_abbrev
> BFD: /home/marxin/Programming/testcases/a.out: unable to initialize decompress status for section .debug_abbrev
> "/home/marxin/Programming/testcases/a.out": not in executable format: file format not recognized
> 
> So it's really compressed with zstd. I'm going to write ChangeLog entry for zlib-gnu once this gets merged as well.
> 
> Ready to be installed?
> Thanks,
> Martin
> 
> 	PR driver/106897
> 
> gcc/ChangeLog:
> 
> 	* common.opt: Add -gz=zstd value.
> 	* configure.ac: Detect --compress-debug-sections=zstd
> 	for both linker and assembler.
> 	* configure: Regenerate.
> 	* gcc.cc (LINK_COMPRESS_DEBUG_SPEC): Handle -gz=zstd.
> 	(ASM_COMPRESS_DEBUG_SPEC): Likewise.
> ---
>  gcc/common.opt   |  5 ++++-
>  gcc/configure    | 11 +++++++++--
>  gcc/configure.ac | 11 +++++++++--
>  gcc/gcc.cc       | 15 +++++++++++++++
>  4 files changed, 37 insertions(+), 5 deletions(-)
> 
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 06ef768ab78..68370db816b 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -3419,7 +3419,10 @@ EnumValue
>  Enum(compressed_debug_sections) String(zlib) Value(1)
>  
>  EnumValue
> -Enum(compressed_debug_sections) String(zlib-gnu) Value(2)
> +Enum(compressed_debug_sections) String(zstd) Value(2)
> +
> +EnumValue
> +Enum(compressed_debug_sections) String(zlib-gnu) Value(3)
>  
>  gz
>  Common Driver
> diff --git a/gcc/configure b/gcc/configure
> index 70a013e9a30..ce4e1859e1f 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -29727,13 +29727,16 @@ else
>     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
> -   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
> -   # defaulting to the ELF gABI format.
>     elif $gcc_cv_as --compress-debug-sections=zlib -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"
> +     # Since binutils 2.40, gas supports --compress-debug-sections=zstd.
> +     if $gcc_cv_as --compress-debug-sections=zstd -o conftest.o conftest.s > /dev/null 2>&1
> +     then
> +       gcc_cv_as_compress_debug=2
> +     fi
>     else
>       gcc_cv_as_compress_debug=0
>     fi
> @@ -30251,6 +30254,10 @@ $as_echo_n "checking linker for compressed debug sections... " >&6; }
>  if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zlib-gabi\>' > /dev/null; then
>      gcc_cv_ld_compress_debug=1
>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> +    # Detect zstd debug section compression support
> +    if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zstd\>' > /dev/null; then
> +      gcc_cv_ld_compress_debug=2
> +    fi
>  else
>    case "${target}" in
>      *-*-solaris2*)
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 96e10d7c194..b6bafa8b7d6 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -5732,13 +5732,16 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
>     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
> -   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
> -   # defaulting to the ELF gABI format.
>     elif $gcc_cv_as --compress-debug-sections=zlib -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"
> +     # Since binutils 2.40, gas supports --compress-debug-sections=zstd.
> +     if $gcc_cv_as --compress-debug-sections=zstd -o conftest.o conftest.s > /dev/null 2>&1
> +     then
> +       gcc_cv_as_compress_debug=2
> +     fi
>     else
>       gcc_cv_as_compress_debug=0
>     fi])
> @@ -6127,6 +6130,10 @@ AC_MSG_CHECKING(linker for compressed debug sections)
>  if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zlib-gabi\>' > /dev/null; then
>      gcc_cv_ld_compress_debug=1
>      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> +    # Detect zstd debug section compression support
> +    if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zstd\>' > /dev/null; then
> +      gcc_cv_ld_compress_debug=2
> +    fi
>  else
>  changequote(,)dnl
>    case "${target}" in
> diff --git a/gcc/gcc.cc b/gcc/gcc.cc
> index 7578988efa9..2ffbbc0bf2a 100644
> --- a/gcc/gcc.cc
> +++ b/gcc/gcc.cc
> @@ -835,6 +835,14 @@ proper position among the other output files.  */
>  #define LINK_COMPRESS_DEBUG_SPEC \
>  	" %{gz|gz=zlib:"  LD_COMPRESS_DEBUG_OPTION "=zlib}" \
>  	" %{gz=none:"	  LD_COMPRESS_DEBUG_OPTION "=none}" \
> +	" %{gz*:%e-gz=zstd is not supported in this configuration} " \
> +	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
> +#elif HAVE_LD_COMPRESS_DEBUG == 2
> +/* ELF gABI style and ZSTD.  */
> +#define LINK_COMPRESS_DEBUG_SPEC \
> +	" %{gz|gz=zlib:"  LD_COMPRESS_DEBUG_OPTION "=zlib}" \
> +	" %{gz=none:"	  LD_COMPRESS_DEBUG_OPTION "=none}" \
> +	" %{gz=zstd:"	  LD_COMPRESS_DEBUG_OPTION "=zstd}" \
>  	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
>  #else
>  #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
> @@ -890,6 +898,13 @@ proper position among the other output files.  */
>  	" %{gz|gz=zlib:"  AS_COMPRESS_DEBUG_OPTION "=zlib}" \
>  	" %{gz=none:"	  AS_COMPRESS_DEBUG_OPTION "=none}" \
>  	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
> +#elif HAVE_AS_COMPRESS_DEBUG == 2
> +/* ELF gABI style and ZSTD.  */
> +#define ASM_COMPRESS_DEBUG_SPEC \
> +	" %{gz|gz=zlib:"  AS_COMPRESS_DEBUG_OPTION "=zlib}" \
> +	" %{gz=none:"	  AS_COMPRESS_DEBUG_OPTION "=none}" \
> +	" %{gz=zstd:"	  AS_COMPRESS_DEBUG_OPTION "=zstd}" \
> +	" %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
>  #else
>  #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
>  #endif


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] support -gz=zstd for both linker and assembler
  2022-09-27 13:54                     ` Martin Liška
@ 2022-09-28 19:21                       ` Richard Biener
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Biener @ 2022-09-28 19:21 UTC (permalink / raw)
  To: Martin Liška; +Cc: gcc-patches

On Tue, Sep 27, 2022 at 3:54 PM Martin Liška <mliska@suse.cz> wrote:
>
> PING^1

OK

Thanks,
Richard.

> On 9/22/22 14:51, Martin Liška wrote:
> > Hi.
> >
> > Tested with Fangrui's patch set sent to binutils ML and mold linker.
> >
> > $ gcc -g -gz=zstd a.c --save-temps --verbose 2>&1 | grep debug-sections
> >  /home/marxin/Programming/binutils/objdir/gas/as-new -v --gdwarf-5 --compress-debug-sections=zstd --64 -o a.o a.s
> >  /home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/collect2 -plugin /home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/liblto_plugin.so -plugin-opt=/home/marxin/bin/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper -plugin-opt=-fresolution=a.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 --compress-debug-sections=zstd /lib/../lib64/crt1.o /lib/../lib64/crti.o /home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/crtbegin.o -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0 -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/../../.. a.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/marxin/bin/gcc/lib64/gcc/x86_64-pc-linux-gnu/13.0.0/crtend.o /lib/../lib64/crtn.o
> >
> > $ gdb a.out
> > ...
> > BFD: /home/marxin/Programming/testcases/a.out: unable to initialize decompress status for section .debug_abbrev
> > BFD: /home/marxin/Programming/testcases/a.out: unable to initialize decompress status for section .debug_abbrev
> > "/home/marxin/Programming/testcases/a.out": not in executable format: file format not recognized
> >
> > So it's really compressed with zstd. I'm going to write ChangeLog entry for zlib-gnu once this gets merged as well.
> >
> > Ready to be installed?
> > Thanks,
> > Martin
> >
> >       PR driver/106897
> >
> > gcc/ChangeLog:
> >
> >       * common.opt: Add -gz=zstd value.
> >       * configure.ac: Detect --compress-debug-sections=zstd
> >       for both linker and assembler.
> >       * configure: Regenerate.
> >       * gcc.cc (LINK_COMPRESS_DEBUG_SPEC): Handle -gz=zstd.
> >       (ASM_COMPRESS_DEBUG_SPEC): Likewise.
> > ---
> >  gcc/common.opt   |  5 ++++-
> >  gcc/configure    | 11 +++++++++--
> >  gcc/configure.ac | 11 +++++++++--
> >  gcc/gcc.cc       | 15 +++++++++++++++
> >  4 files changed, 37 insertions(+), 5 deletions(-)
> >
> > diff --git a/gcc/common.opt b/gcc/common.opt
> > index 06ef768ab78..68370db816b 100644
> > --- a/gcc/common.opt
> > +++ b/gcc/common.opt
> > @@ -3419,7 +3419,10 @@ EnumValue
> >  Enum(compressed_debug_sections) String(zlib) Value(1)
> >
> >  EnumValue
> > -Enum(compressed_debug_sections) String(zlib-gnu) Value(2)
> > +Enum(compressed_debug_sections) String(zstd) Value(2)
> > +
> > +EnumValue
> > +Enum(compressed_debug_sections) String(zlib-gnu) Value(3)
> >
> >  gz
> >  Common Driver
> > diff --git a/gcc/configure b/gcc/configure
> > index 70a013e9a30..ce4e1859e1f 100755
> > --- a/gcc/configure
> > +++ b/gcc/configure
> > @@ -29727,13 +29727,16 @@ else
> >     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
> > -   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
> > -   # defaulting to the ELF gABI format.
> >     elif $gcc_cv_as --compress-debug-sections=zlib -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"
> > +     # Since binutils 2.40, gas supports --compress-debug-sections=zstd.
> > +     if $gcc_cv_as --compress-debug-sections=zstd -o conftest.o conftest.s > /dev/null 2>&1
> > +     then
> > +       gcc_cv_as_compress_debug=2
> > +     fi
> >     else
> >       gcc_cv_as_compress_debug=0
> >     fi
> > @@ -30251,6 +30254,10 @@ $as_echo_n "checking linker for compressed debug sections... " >&6; }
> >  if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zlib-gabi\>' > /dev/null; then
> >      gcc_cv_ld_compress_debug=1
> >      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> > +    # Detect zstd debug section compression support
> > +    if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zstd\>' > /dev/null; then
> > +      gcc_cv_ld_compress_debug=2
> > +    fi
> >  else
> >    case "${target}" in
> >      *-*-solaris2*)
> > diff --git a/gcc/configure.ac b/gcc/configure.ac
> > index 96e10d7c194..b6bafa8b7d6 100644
> > --- a/gcc/configure.ac
> > +++ b/gcc/configure.ac
> > @@ -5732,13 +5732,16 @@ gcc_GAS_CHECK_FEATURE([compressed debug sections],
> >     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
> > -   # Since binutils 2.26, gas supports --compress-debug-sections=zlib,
> > -   # defaulting to the ELF gABI format.
> >     elif $gcc_cv_as --compress-debug-sections=zlib -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"
> > +     # Since binutils 2.40, gas supports --compress-debug-sections=zstd.
> > +     if $gcc_cv_as --compress-debug-sections=zstd -o conftest.o conftest.s > /dev/null 2>&1
> > +     then
> > +       gcc_cv_as_compress_debug=2
> > +     fi
> >     else
> >       gcc_cv_as_compress_debug=0
> >     fi])
> > @@ -6127,6 +6130,10 @@ AC_MSG_CHECKING(linker for compressed debug sections)
> >  if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zlib-gabi\>' > /dev/null; then
> >      gcc_cv_ld_compress_debug=1
> >      gcc_cv_ld_compress_debug_option="--compress-debug-sections"
> > +    # Detect zstd debug section compression support
> > +    if $gcc_cv_ld --help 2>&1 | grep -- '--compress-debug-sections.*\<zstd\>' > /dev/null; then
> > +      gcc_cv_ld_compress_debug=2
> > +    fi
> >  else
> >  changequote(,)dnl
> >    case "${target}" in
> > diff --git a/gcc/gcc.cc b/gcc/gcc.cc
> > index 7578988efa9..2ffbbc0bf2a 100644
> > --- a/gcc/gcc.cc
> > +++ b/gcc/gcc.cc
> > @@ -835,6 +835,14 @@ proper position among the other output files.  */
> >  #define LINK_COMPRESS_DEBUG_SPEC \
> >       " %{gz|gz=zlib:"  LD_COMPRESS_DEBUG_OPTION "=zlib}" \
> >       " %{gz=none:"     LD_COMPRESS_DEBUG_OPTION "=none}" \
> > +     " %{gz*:%e-gz=zstd is not supported in this configuration} " \
> > +     " %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
> > +#elif HAVE_LD_COMPRESS_DEBUG == 2
> > +/* ELF gABI style and ZSTD.  */
> > +#define LINK_COMPRESS_DEBUG_SPEC \
> > +     " %{gz|gz=zlib:"  LD_COMPRESS_DEBUG_OPTION "=zlib}" \
> > +     " %{gz=none:"     LD_COMPRESS_DEBUG_OPTION "=none}" \
> > +     " %{gz=zstd:"     LD_COMPRESS_DEBUG_OPTION "=zstd}" \
> >       " %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
> >  #else
> >  #error Unknown value for HAVE_LD_COMPRESS_DEBUG.
> > @@ -890,6 +898,13 @@ proper position among the other output files.  */
> >       " %{gz|gz=zlib:"  AS_COMPRESS_DEBUG_OPTION "=zlib}" \
> >       " %{gz=none:"     AS_COMPRESS_DEBUG_OPTION "=none}" \
> >       " %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
> > +#elif HAVE_AS_COMPRESS_DEBUG == 2
> > +/* ELF gABI style and ZSTD.  */
> > +#define ASM_COMPRESS_DEBUG_SPEC \
> > +     " %{gz|gz=zlib:"  AS_COMPRESS_DEBUG_OPTION "=zlib}" \
> > +     " %{gz=none:"     AS_COMPRESS_DEBUG_OPTION "=none}" \
> > +     " %{gz=zstd:"     AS_COMPRESS_DEBUG_OPTION "=zstd}" \
> > +     " %{gz=zlib-gnu:}" /* Ignore silently zlib-gnu option value.  */
> >  #else
> >  #error Unknown value for HAVE_AS_COMPRESS_DEBUG.
> >  #endif
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-09-28 19:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-01  6:57 [PATCH] Remove legacy -gz=zlib-gnu Fangrui Song
2022-07-01  7:03 ` Andrew Pinski
2022-07-01  7:20   ` Fangrui Song
2022-09-20 12:55     ` Martin Liška
2022-09-21  7:36       ` Richard Biener
2022-09-21  7:45         ` Fangrui Song
2022-09-21  7:49         ` Martin Liška
2022-09-21  9:35           ` Richard Biener
2022-09-22 11:10             ` [PATCH] remove -gz=zlib-gnu option value Martin Liška
2022-09-22 12:26               ` [PATCH v2] " Martin Liška
2022-09-22 12:35                 ` Richard Biener
2022-09-22 12:51                   ` [PATCH] support -gz=zstd for both linker and assembler Martin Liška
2022-09-27 13:54                     ` Martin Liška
2022-09-28 19:21                       ` Richard Biener

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