GNU bug report logs - #42555
[PATCH core-updates] build-system/gnu: strip with --strip-unneeded

Previous Next

Package: guix-patches;

Reported by: Jakub Kądziołka <kuba <at> kadziolka.net>

Date: Sun, 26 Jul 2020 23:40:01 UTC

Severity: normal

Tags: patch

Done: Jakub Kądziołka <kuba <at> kadziolka.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 42555 in the body.
You can then email your comments to 42555 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#42555; Package guix-patches. (Sun, 26 Jul 2020 23:40:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jakub Kądziołka <kuba <at> kadziolka.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 26 Jul 2020 23:40:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jakub Kądziołka <kuba <at> kadziolka.net>
To: guix-patches <at> gnu.org
Subject: [PATCH core-updates] build-system/gnu: strip with --strip-unneeded
Date: Mon, 27 Jul 2020 01:38:50 +0200
Apart from debug information, one can also strip some symbols. This can
be a significant difference, qtbase:out consists of about 5 MB of those
symbols. As per [1], --strip-debug is included in --strip-unneeded, and
the debug files created also contain a copy of the information removed
by --strip-unneeded.

Linux From Scratch suggests that this option shouldn't be used on static
libraries [2], however other sources [3] indicate otherwise. Building a
toolchain with this patch succeeds, and the result works fine for
'gcc -static hello-world.c'.

[1]: https://stackoverflow.com/a/52555093
[2]: http://www.linuxfromscratch.org/lfs/view/9.1/chapter05/stripping.html
[3]: https://www.technovelty.org/linux/stripping-shared-libraries.html

* guix/build/gnu-build-system.scm (strip): Use --strip-unneeded.
---
 guix/build/gnu-build-system.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 2e7dff2034..d3347c9518 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -425,7 +425,7 @@ makefiles."
                 (objcopy-command (if target
                                      (string-append target "-objcopy")
                                      "objcopy"))
-                (strip-flags '("--strip-debug"
+                (strip-flags '("--strip-unneeded"
                                "--enable-deterministic-archives"))
                 (strip-directories '("lib" "lib64" "libexec"
                                      "bin" "sbin"))
-- 
2.27.0





Information forwarded to guix-patches <at> gnu.org:
bug#42555; Package guix-patches. (Thu, 30 Jul 2020 00:23:01 GMT) Full text and rfc822 format available.

Message #8 received at 42555 <at> debbugs.gnu.org (full text, mbox):

From: Jakub Kądziołka <kuba <at> kadziolka.net>
To: 42555 <at> debbugs.gnu.org
Subject: [PATCH v2 core-updates] build-system/gnu: strip with --strip-unneeded
Date: Thu, 30 Jul 2020 02:21:54 +0200
Apart from debug information, one can also strip some symbols. This can
be a significant difference, the closure of gcc-toolchain <at> 7 got reduced
by 15 MB in my tests.

As per [1], --strip-debug is included in --strip-unneeded, and
the debug files created also contain a copy of the information removed
by --strip-unneeded.

Linux From Scratch suggests that this option shouldn't be used on static
libraries [2], however other sources [3] indicate otherwise. Building a
toolchain with this patch succeeds, and the result works fine for
'gcc -static hello-world.c'.

[1]: https://stackoverflow.com/a/52555093
[2]: http://www.linuxfromscratch.org/lfs/view/9.1/chapter05/stripping.html
[3]: https://www.technovelty.org/linux/stripping-shared-libraries.html

* guix/build/gnu-build-system.scm (strip): Use --strip-unneeded.
* guix/build-system/gnu.scm (static-package, gnu-build, gnu-cross-build): Likewise.
---

I have realized that my previous patch was a no-op due to default values
for arguments being scattered across files. I ran my builds again and
now I can observe results in the earlier stages of the toolchain,
accessible to a testing core-updates build.

 guix/build-system/gnu.scm       | 6 +++---
 guix/build/gnu-build-system.scm | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm
index 6b481ad45c..2c23197e77 100644
--- a/guix/build-system/gnu.scm
+++ b/guix/build-system/gnu.scm
@@ -215,7 +215,7 @@ use `--strip-all' as the arguments to `strip'."
     (arguments
      (let ((a (default-keyword-arguments (package-arguments p)
                 '(#:configure-flags '()
-                  #:strip-flags '("--strip-debug")))))
+                  #:strip-flags '("--strip-unneeded")))))
        (substitute-keyword-arguments a
          ((#:configure-flags flags)
           `(cons* "--disable-shared" "LDFLAGS=-static" ,flags))
@@ -337,7 +337,7 @@ standard packages used as implicit inputs of the GNU build system."
                     (parallel-tests? #t)
                     (patch-shebangs? #t)
                     (strip-binaries? #t)
-                    (strip-flags ''("--strip-debug"
+                    (strip-flags ''("--strip-unneeded"
                                     "--enable-deterministic-archives"))
                     (strip-directories ''("lib" "lib64" "libexec"
                                           "bin" "sbin"))
@@ -492,7 +492,7 @@ is one of `host' or `target'."
                           (parallel-build? #t) (parallel-tests? #t)
                           (patch-shebangs? #t)
                           (strip-binaries? #t)
-                          (strip-flags ''("--strip-debug"
+                          (strip-flags ''("--strip-unneeded"
                                           "--enable-deterministic-archives"))
                           (strip-directories ''("lib" "lib64" "libexec"
                                                 "bin" "sbin"))
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 2e7dff2034..d3347c9518 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -425,7 +425,7 @@ makefiles."
                 (objcopy-command (if target
                                      (string-append target "-objcopy")
                                      "objcopy"))
-                (strip-flags '("--strip-debug"
+                (strip-flags '("--strip-unneeded"
                                "--enable-deterministic-archives"))
                 (strip-directories '("lib" "lib64" "libexec"
                                      "bin" "sbin"))
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#42555; Package guix-patches. (Sat, 19 Sep 2020 12:50:01 GMT) Full text and rfc822 format available.

Message #11 received at 42555 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Jakub Kądziołka <kuba <at> kadziolka.net>
Cc: 42555 <at> debbugs.gnu.org
Subject: Re: [bug#42555] [PATCH v2 core-updates] build-system/gnu: strip
 with --strip-unneeded
Date: Sat, 19 Sep 2020 14:49:41 +0200
Hi Jakub,

Jakub Kądziołka <kuba <at> kadziolka.net> skribis:

> Apart from debug information, one can also strip some symbols. This can
> be a significant difference, the closure of gcc-toolchain <at> 7 got reduced
> by 15 MB in my tests.

Nice!  Now’s a good time to get that patch in on ‘core-updates’.

> As per [1], --strip-debug is included in --strip-unneeded, and
> the debug files created also contain a copy of the information removed
> by --strip-unneeded.

Hmm the Binutils manual suggests otherwise (info "(binutils) objcopy"):

--8<---------------cut here---------------start------------->8---
'-g'
'--strip-debug'
     Do not copy debugging symbols or sections from the source file.

'--strip-unneeded'
     Strip all symbols that are not needed for relocation processing.
--8<---------------cut here---------------end--------------->8---

… but objcopy.c reads this:

--8<---------------cut here---------------start------------->8---
      else if ((flags & BSF_DEBUGGING) != 0)	/* Debugging symbol.  */
	keep = (strip_symbols != STRIP_DEBUG
		&& strip_symbols != STRIP_UNNEEDED
		&& ! convert_debugging);
--8<---------------cut here---------------end--------------->8---

… confirming that ‘--strip-unneeded’ includes ‘--strip-debug’.

I submitted a patch for the Binutils manual.

> Linux From Scratch suggests that this option shouldn't be used on static
> libraries [2], however other sources [3] indicate otherwise. Building a
> toolchain with this patch succeeds, and the result works fine for
> 'gcc -static hello-world.c'.

OK.

> [1]: https://stackoverflow.com/a/52555093

Perhaps we can omit this one.  In general, I think it’s safer to refer
to “primary sources” as Wikipedians would say.

> [2]: http://www.linuxfromscratch.org/lfs/view/9.1/chapter05/stripping.html
> [3]: https://www.technovelty.org/linux/stripping-shared-libraries.html
>
> * guix/build/gnu-build-system.scm (strip): Use --strip-unneeded.
> * guix/build-system/gnu.scm (static-package, gnu-build, gnu-cross-build): Likewise.

LGTM!

For the record, I tried ‘--strip-all’ before, but that was problematic
for some reason:

  https://lists.gnu.org/archive/html/guix-devel/2018-03/msg00135.html

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#42555; Package guix-patches. (Sat, 19 Sep 2020 13:55:01 GMT) Full text and rfc822 format available.

Message #14 received at 42555 <at> debbugs.gnu.org (full text, mbox):

From: Jakub Kądziołka <kuba <at> kadziolka.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 42555 <at> debbugs.gnu.org, 42555-done <at> debbugs.gnu.org
Subject: Re: [bug#42555] [PATCH v2 core-updates] build-system/gnu: strip
 with --strip-unneeded
Date: Sat, 19 Sep 2020 15:49:31 +0200
On Sat Sep 19, 2020 at 4:49 PM CEST, Ludovic Courtès wrote:
> Hi Jakub,
>
> Jakub Kądziołka <kuba <at> kadziolka.net> skribis:
>
> > Apart from debug information, one can also strip some symbols. This can
> > be a significant difference, the closure of gcc-toolchain <at> 7 got reduced
> > by 15 MB in my tests.
>
> Nice! Now’s a good time to get that patch in on ‘core-updates’.

Thanks. Patch pushed (with a small hiccup...)

> > [1]: https://stackoverflow.com/a/52555093
>
> Perhaps we can omit this one. In general, I think it’s safer to refer
> to “primary sources” as Wikipedians would say.

The problem with "primary sources" is that the docs on this are quite
sparse. I think this link is much more comprehensive.

> > [2]: http://www.linuxfromscratch.org/lfs/view/9.1/chapter05/stripping.html
> > [3]: https://www.technovelty.org/linux/stripping-shared-libraries.html
> >
> > * guix/build/gnu-build-system.scm (strip): Use --strip-unneeded.
> > * guix/build-system/gnu.scm (static-package, gnu-build, gnu-cross-build): Likewise.
>
> LGTM!
>
> For the record, I tried ‘--strip-all’ before, but that was
> problematic
> for some reason:
>
> https://lists.gnu.org/archive/html/guix-devel/2018-03/msg00135.html

The docs for --strip-all say "Do not copy relocation and symbol
information", so I would expect some relocation and/or linking use case
to get broken...

Regards,
Jakub Kądziołka




Reply sent to Jakub Kądziołka <kuba <at> kadziolka.net>:
You have taken responsibility. (Sat, 19 Sep 2020 13:55:02 GMT) Full text and rfc822 format available.

Notification sent to Jakub Kądziołka <kuba <at> kadziolka.net>:
bug acknowledged by developer. (Sat, 19 Sep 2020 13:55:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 18 Oct 2020 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 191 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.