[PATCH] objcopy: Don't add zstd to the debug compression options if not available

Alan Modra amodra@gmail.com
Wed Oct 22 03:40:38 GMT 2025
On Mon, Oct 20, 2025 at 01:28:41PM -0400, Pietro Monteiro wrote:
> On Mon, Oct 20, 2025, at 3:41 AM, Jan Beulich wrote:
> > On 20.10.2025 02:14, Pietro Monteiro wrote:
> >> If zstd is not available or was intentionally disabled by the user
> >> don't add it to the list of the available options to compress debug
> >> sections when showing usage.
> >> 
> >> binutils/ChangeLog:
> >> 
> >> 	* objcopy.c (copy_usage): Output
> >> 	--compress-debug-sections=zstd if HAVE_ZSTD.
> >> 	* po/binutils.pot: Regenerate.
> >
> > I'm not sure this file wants updating by isolated changes. Nick, Alan -
> > can you provide any guidance here?
> 
> Yeah, it looks like this file is updated when a new release is created.

Yes, updating .pot files is something that tends to happen a little
while before a release.  I'll push the following variant of your patch
if you're happy for me to leave your name as the author.

>From 4cfcc5412cc2dd1ebe31ca467f2afe4752d45952 Mon Sep 17 00:00:00 2001
From: Pietro Monteiro <pietro@sociotechnical.xyz>
Date: Sun, 19 Oct 2025 20:14:51 -0400
Subject: objcopy: Don't add zstd to the debug compression options if not
 available

If zstd is not available or was intentionally disabled by the user
don't add it to the list of the available options to compress debug
sections when showing usage.

binutils/
	* objcopy.c (copy_usage): Only output
	--compress-debug-sections=zstd if HAVE_ZSTD.

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 3c1bcf622ff..9373b75d6ed 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -570,6 +570,12 @@ static bool write_debugging_info (bfd *, void *, long *, asymbol ***);
 static const char *lookup_sym_redefinition (const char *);
 static const char *find_section_rename (const char *, flagword *);
 
+#ifdef HAVE_ZSTD
+#define ZSTD_OPT "|zstd"
+#else
+#define ZSTD_OPT ""
+#endif
+
 ATTRIBUTE_NORETURN static void
 copy_usage (FILE *stream, int exit_status)
 {
@@ -692,8 +698,8 @@ copy_usage (FILE *stream, int exit_status)
                                    <commit>\n\
      --subsystem <name>[:<version>]\n\
                                    Set PE subsystem to <name> [& <version>]\n\
-     --compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi|zstd}]\n\
-				   Compress DWARF debug sections\n\
+     --compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi" ZSTD_OPT "}]\n\
+                                   Compress DWARF debug sections\n\
      --decompress-debug-sections   Decompress DWARF debug sections using zlib\n\
      --elf-stt-common=[yes|no]     Generate ELF common symbols with STT_COMMON\n\
                                      type\n\


-- 
Alan Modra


More information about the Binutils mailing list