New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 592228 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Last visit > 30 days ago
Closed: Mar 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug



Sign in to add a comment

cross-compiled binutils have large dwp & ld.gold binaries

Project Member Reported by vapier@chromium.org, Mar 5 2016

Issue description

i have no idea why this is happening, but these binaries are like 10x the size they should be

$ du -h /build/*/usr/*/binutils-bin/2.25.51/ld.gold.real 
87M     /build/arm64-generic/usr/aarch64-cros-linux-gnu/binutils-bin/2.25.51/ld.gold.real
75M     /build/peach_pit/usr/armv7a-cros-linux-gnueabi/binutils-bin/2.25.51/ld.gold.real
92M     /build/samus/usr/x86_64-cros-linux-gnu/binutils-bin/2.25.51/ld.gold.real
68M     /build/x32-generic/usr/x86_64-cros-linux-gnux32/binutils-bin/2.25.51/ld.gold.real
71M     /build/x86-alex/usr/i686-pc-linux-gnu/binutils-bin/2.25.51/ld.gold.real

$ du -h /build/*/usr/*/binutils-bin/2.25.51/dwp
53M     /build/arm64-generic/usr/aarch64-cros-linux-gnu/binutils-bin/2.25.51/dwp
48M     /build/peach_pit/usr/armv7a-cros-linux-gnueabi/binutils-bin/2.25.51/dwp
58M     /build/samus/usr/x86_64-cros-linux-gnu/binutils-bin/2.25.51/dwp
41M     /build/x32-generic/usr/x86_64-cros-linux-gnux32/binutils-bin/2.25.51/dwp
46M     /build/x86-alex/usr/i686-pc-linux-gnu/binutils-bin/2.25.51/dwp

whereas the native ones look fine:

$ du -h /usr/*/*/binutils-bin/2.25.51/ld.gold.real
6.3M    /usr/x86_64-pc-linux-gnu/aarch64-cros-linux-gnu/binutils-bin/2.25.51/ld.gold.real
6.3M    /usr/x86_64-pc-linux-gnu/arm-none-eabi/binutils-bin/2.25.51/ld.gold.real
6.3M    /usr/x86_64-pc-linux-gnu/armv6j-cros-linux-gnueabi/binutils-bin/2.25.51/ld.gold.real
6.3M    /usr/x86_64-pc-linux-gnu/armv7a-cros-linux-gnueabi/binutils-bin/2.25.51/ld.gold.real
6.3M    /usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/binutils-bin/2.25.51/ld.gold.real
6.3M    /usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/binutils-bin/2.25.51/ld.gold.real
$ du -h /usr/*/*/binutils-bin/2.25.51/dwp
3.5M    /usr/x86_64-pc-linux-gnu/aarch64-cros-linux-gnu/binutils-bin/2.25.51/dwp
3.5M    /usr/x86_64-pc-linux-gnu/arm-none-eabi/binutils-bin/2.25.51/dwp
3.5M    /usr/x86_64-pc-linux-gnu/armv6j-cros-linux-gnueabi/binutils-bin/2.25.51/dwp
3.5M    /usr/x86_64-pc-linux-gnu/armv7a-cros-linux-gnueabi/binutils-bin/2.25.51/dwp
3.5M    /usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/binutils-bin/2.25.51/dwp
3.5M    /usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/binutils-bin/2.25.51/dwp
 
Cc: shenhan@chromium.org
Owner: rahulchaudhry@chromium.org
Status: Assigned (was: Unconfirmed)
These executables contain debug info:

readelf -S /build/x86-alex/usr/i686-pc-linux-gnu/binutils-bin/2.25.51/dwp | grep debug
  [33] .debug_info       PROGBITS        00000000 2efb60 158afb3 00      0   0  1
  [34] .debug_abbrev     PROGBITS        00000000 187ab13 02e5c4 00      0   0  1
  [35] .debug_loc        PROGBITS        00000000 18a90d7 ce80ee 00      0   0  1
  [36] .debug_aranges    PROGBITS        00000000 25911c5 00d610 00      0   0  1
  [37] .debug_ranges     PROGBITS        00000000 259e7d5 127d70 00      0   0  1
  [38] .debug_line       PROGBITS        00000000 26c6545 11e881 00      0   0  1
  [39] .debug_str        PROGBITS        00000000 27e4dc6 4f4c5f 01  MS  0   0  1
  [40] .debug_frame      PROGBITS        00000000 2cd9a28 002538 00      0   0 

not being stripped?

Rahul, can you please take a look at this?


Status: Started (was: Assigned)
Verified that all of the size increase is from debug info. Cross-compiled binutils is being compiled with "-g".

The flag is coming from "chromeos/config/make.conf.generic-target" line 72 (https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/master/chromeos/config/make.conf.generic-target#72). This also explains why the host versions are smaller ("make.conf.generic-target" is included only for target packages).

Typically, for other cross-compiled packages, the binaries get stripped before install so we don't see the size increase. This doesn't happen for binutils because the sys-devel/binutils ebuild has RESTRICT="strip". This makes some sense since "strip" itself is part of binutils and may, in some instances, cause circular dependency (you need to strip "strip" before installing it).

There are 3 alternative ways I can think of to fix this:

1) Remove "-g" from "make.conf.generic-target". This is intrusive, in that it will affect all cross-compiled packages. Not sure if anything visible will change, since the binaries are getting stripped anyway.

2) Remove RESTRICT="strip" from sys-devel/binutils. The circularity inherent in the package seems to be getting handled already somehow (you need the linker to link the linker).

3) Filter flag "-g" when configuring sources for binutils. This is the least intrusive, and probably what we want: https://chromium-review.googlesource.com/#/c/331772

looks like we should do (2).  i don't see any reason in the history as to why this was added in the first place, and we don't do it in Gentoo.
We have RESTRICT="strip" in sys-devel/gcc ebuild as well. Something special about sys-devel/ binaries?

I'll prepare another CL to remove RESTRICT="strip" from the binutils ebuild.

gcc is necessary because it mixes $CBUILD binaries (e.g. `gcc`) and $CHOST binaries (e.g. libgcc_s.so).  the gcc ebuild though manually strips things in src_install with the right strip prog.
Comparison of binary sizes:

Before:
Sizes of host and cross-compiled binutils directories:
        13M     /usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/binutils-bin/2.25.51
        163M    /build/panther/usr/x86_64-cros-linux-gnu/binutils-bin/2.25.51

Sizes of ld.gold.real:
        6.3M    /usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/binutils-bin/2.25.51/ld.gold.real
        92M     /build/panther/usr/x86_64-cros-linux-gnu/binutils-bin/2.25.51/ld.gold.real



After "filter-flags -g": https://chromium-review.googlesource.com/#/c/331772
Sizes of host and cross-compiled binutils directories:
        13M     /usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/binutils-bin/2.25.51
        15M     /build/panther/usr/x86_64-cros-linux-gnu/binutils-bin/2.25.51

Sizes of ld.gold.real:
        6.3M    /usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/binutils-bin/2.25.51/ld.gold.real
        6.8M    /build/panther/usr/x86_64-cros-linux-gnu/binutils-bin/2.25.51/ld.gold.real



After removing "RESTRICT=strip": https://chromium-review.googlesource.com/#/c/332020
Sizes of host and cross-compiled binutils directories:
        9.9M    /usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/binutils-bin/2.25.51
        11M     /build/panther/usr/x86_64-cros-linux-gnu/binutils-bin/2.25.51

Sizes of ld.gold.real:
        4.6M    /usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/binutils-bin/2.25.51/ld.gold.real
        5.1M    /build/panther/usr/x86_64-cros-linux-gnu/binutils-bin/2.25.51/ld.gold.real

the advantage of (2) over (1) & (3) is that you still have the debug info split out for when you do want it

Comment 9 by lloz...@google.com, Mar 9 2016

Yunlian, Han and I talked about this. We dont know why RESTRICT="strip" is there. 
I like 2)
Project Member

Comment 10 by bugdroid1@chromium.org, Mar 10 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/d0401f9379bf6d2606bde2ca2adaaebbebfafc2a

commit d0401f9379bf6d2606bde2ca2adaaebbebfafc2a
Author: Rahul Chaudhry <rahulchaudhry@chromium.org>
Date: Wed Mar 09 22:24:22 2016

sys-devel/binutils: strip binutils binaries before install.

BUG= chromium:592228 
TEST='emerge-panther sys-devel/binutils' and 'emerge cross-x86_64-cros-linux-gnu/binutils' produce binaries very similar in size.
TEST='cbuildbot --remote -g 332020 --latest-toolchain chromiumos-sdk' was successful.

Change-Id: Ic142a00119f618f66120b491c04cc7c5c4e42c2c
Reviewed-on: https://chromium-review.googlesource.com/332020
Commit-Ready: Rahul Chaudhry <rahulchaudhry@chromium.org>
Tested-by: Rahul Chaudhry <rahulchaudhry@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[rename] https://crrev.com/d0401f9379bf6d2606bde2ca2adaaebbebfafc2a/sys-devel/binutils/binutils-2.25.51-r56.ebuild
[modify] https://crrev.com/d0401f9379bf6d2606bde2ca2adaaebbebfafc2a/sys-devel/binutils/binutils-9999.ebuild

Status: Fixed (was: Started)
thanks ... this will help a lot with test images which have been getting too full lately
Labels: VerifyIn-51
Status: Verified (was: Fixed)
Bulk verified

Sign in to add a comment