Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upSymbols blow up binary size to an unreasonable degree on x86_64-unknown-linux-gnu #46034
Comments
kennytm
added
the
C-bug
label
Nov 16, 2017
This comment has been minimized.
This comment has been minimized.
|
On x86_64-apple-darwin:
The size is definitely growing but not something that increases by 10×. On x86_64-pc-windows-msvc:
Probably a Linux-only problem. |
This comment has been minimized.
This comment has been minimized.
|
@kennytm updated OP with |
This comment has been minimized.
This comment has been minimized.
|
Repro'd on Linux with stable. (Not sure about the BSDs)
The initial blow up problem comes from 1.14.0. Comparing the readelf -S -W 1.13.0
readelf -S -W 1.14.0
Detailed breakdown of size delta for each section
|
kennytm
added
the
A-debuginfo
label
Nov 16, 2017
This comment has been minimized.
This comment has been minimized.
|
#43392 seems to be the same problem. Since Windows and macOS places the debug symbols externally (*.pdb and *.dSYM respectively), we don't see the size blow up on those platforms. |
This comment has been minimized.
This comment has been minimized.
|
This seems like a very important thing. Size affects linkage time, affects compilation speed. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Making the assumption that this is caused by |
kennytm
added
A-linkage
O-linux
labels
Nov 16, 2017
This comment has been minimized.
This comment has been minimized.
Michael-F-Bryan
commented
Jan 4, 2018
|
On
So stripping debug info goes from 12M to 6.3M. |
Byron
added a commit
to share-secrets-safely/cli
that referenced
this issue
Jan 7, 2018
This comment has been minimized.
This comment has been minimized.
|
The C/C++ toolchain (whether GCC or Clang) on Linux solves this with -gsplit-dwarf, which results in similar products as the *.pdb or *.dSYM on Windows and macOS; to anyone interested in implementing the support, it would be as simple as setting the appropriate LLVM codegen option (as seen in clang):
|
This comment has been minimized.
This comment has been minimized.
|
Oh interesting. cc @main-- rust-lang/rfcs#2154. |
This comment has been minimized.
This comment has been minimized.
main--
commented
Jan 8, 2018
|
Thanks. I actually knew about this "debug fission" but was not aware that LLVM already supports it. The nice thing about the old How good is toolchain support? Of course gdb reads info from dwo files but GNU addr2line does not. It's either just not implemented yet or not intended to work like that (which would be very disappointing since you need I'm still having a hard time finding pretty much any documentation at all about debug fissure (beyond that one GCC page) but these points lead me to believe that it's not the best approach for what I'm trying to do in rust-lang/rfcs#2154. |
This comment has been minimized.
This comment has been minimized.
But... if |
This comment has been minimized.
This comment has been minimized.
main--
commented
Jan 9, 2018
Yes. |
This comment has been minimized.
This comment has been minimized.
@michaelwoerister this is kind of true, but only kind of... Measurements in https://users.rust-lang.org/t/rust-binary-sizes-once-again/16287/2 for a crate with "with rocket, serde, wiringpi and pam-auth" should reduction 6.5M -> 1.6M. It is not 90%, but, still, is very significant. Note also an interesting observation that LTO does not affect stripped binaries, but, for non-striped, goes from 6.5M -> 4.7M. I wonder if there's any actionable items on this issue? Could there be some linker flag for "please, don't link-in the debuginfo into the final binary"? |
This comment has been minimized.
This comment has been minimized.
|
That's a good idea, @matklad. |
This comment has been minimized.
This comment has been minimized.
|
If anyone wants to give it a try, the relevant spot in the source code is here: rust/src/librustc_trans/back/linker.rs Lines 283 to 285 in 15add36 This method should add any linker flags relevant to debuginfo. |
michaelwoerister
added
E-mentor
E-help-wanted
labels
Mar 19, 2018
This comment has been minimized.
This comment has been minimized.
axos88
commented
Mar 20, 2018
|
I also stumbled upon this cross-compiling from OS X to arm-linux: https://users.rust-lang.org/t/rust-binary-sizes-once-again/16287/2 |
crumblingstatue commentedNov 16, 2017
•
edited
Standard hello world program generated with
cargo new --bin mytestBuilt with
cargo build --release, the resulting binary size is 4270408 bytes.This sounds unreasonably large for a hello world program.
After
strip --strip-all, we get 449224.The non-stripped version is almost 10 times larger than the stripped version. Why?
This is with
rustc 1.23.0-nightly (fa26421f5 2017-11-15), installed through rustup.Here is stable
rustc 1.21.0 (3b72af97e 2017-10-09)for good measure:Normal: 4059968
Stripped: 404096
This time, the initial size is lower, but the stripped size is even smaller, making the non-stripped version slightly more than 10 times larger.
(As a sidenote, I've been noticing that binary sizes for the same program have been steadily increasing with every new rustc, at least on
x86_64-unknown-linux-gnu, but that's a separate issue, I suppose)