Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug build of libLLVM.so is enormous #67109

Closed
Aaron1011 opened this issue Dec 7, 2019 · 4 comments
Closed

Debug build of libLLVM.so is enormous #67109

Aaron1011 opened this issue Dec 7, 2019 · 4 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. I-heavy Issue: Problems and improvements with respect to binary size of generated code. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@Aaron1011
Copy link
Member

This isn't an issue with Rust per se - however, it has implications for people building the compiler.

The libLLVM.so shipped with the Rust compiler (libLLVM-9-rust-1.41.0-nightly.so at the time of writing) is currently 80MB. While this seems incredibly large for a shared library, it's still only slightly larger than librustc_driver (63MB).

This is unfortunate, but things become much worse when llvm.release-debuginfo=true is set in config.toml. This makes libLLVM-9-rust-1.41.0-dev-de1a7dbf6.so take up 2.1 GB of space.

To make matters worse, we currently copy libLLVM.so to a target directory when building the compiler:

builder.install(&llvm_dylib_path, &dst_libdir, 0o644);

With #67077, we may have to copy it into even more places. This represents a non-trivial amount of disk space.

I don't think there's much we can directly do about the size of libLLVM.so, other than making sure upstream is aware of this. However, we might want to consider symlinking libLLVM.so, rather than copying it. I know this works for shared libraries on Linux, but I'm not sure about other platforms.

@tesuji
Copy link
Contributor

tesuji commented Dec 7, 2019

Also in ~/.rustup/toolchains:

> find -name '*libLLVM*' -exec ls -lai {} \+
129111035 -rw-r--r-- 1 lzutao lzutao 81161488 Dec  3 09:33 ./beta-x86_64-unknown-linux-gnu/lib/libLLVM-9-rust-1.40.0-beta.so
129111071 -rw-r--r-- 1 lzutao lzutao 81161488 Dec  3 09:33 ./beta-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-9-rust-1.40.0-beta.so
126485192 -rw-r--r-- 1 lzutao lzutao 83195704 Dec  5 12:54 ./master/lib/libLLVM-9-rust-1.41.0-nightly.so
126485193 -rw-r--r-- 1 lzutao lzutao 83195704 Dec  5 12:54 ./master/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-9-rust-1.41.0-nightly.so
126755208 -rw-r--r-- 1 lzutao lzutao 83195704 Dec  7 04:09 ./nightly-x86_64-unknown-linux-gnu/lib/libLLVM-9-rust-1.41.0-nightly.so
126755209 -rw-r--r-- 1 lzutao lzutao 83195704 Dec  7 04:09 ./nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-9-rust-1.41.0-nightly.so
> find -name '*libLLVM*' -exec sha256sum {} \+
b837248c30682a65177aa00ea138f33d7ad2596fd7cf158d41cb5d858ebe2df7  ./nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-9-rust-1.41.0-nightly.so
b837248c30682a65177aa00ea138f33d7ad2596fd7cf158d41cb5d858ebe2df7  ./nightly-x86_64-unknown-linux-gnu/lib/libLLVM-9-rust-1.41.0-nightly.so
4fdc606fff426a248fc6b814aabd2ff9087f13893b9bfb6ed0724ad89c39995a  ./beta-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-9-rust-1.40.0-beta.so
4fdc606fff426a248fc6b814aabd2ff9087f13893b9bfb6ed0724ad89c39995a  ./beta-x86_64-unknown-linux-gnu/lib/libLLVM-9-rust-1.40.0-beta.so
b837248c30682a65177aa00ea138f33d7ad2596fd7cf158d41cb5d858ebe2df7  ./master/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-9-rust-1.41.0-nightly.so
b837248c30682a65177aa00ea138f33d7ad2596fd7cf158d41cb5d858ebe2df7  ./master/lib/libLLVM-9-rust-1.41.0-nightly.so

I think these libLLVM files in the same toolchain could be symlink too.

@jonas-schievink jonas-schievink added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) I-heavy Issue: Problems and improvements with respect to binary size of generated code. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Dec 7, 2019
@nagisa
Copy link
Member

nagisa commented Dec 8, 2019

I don't think there's much we can directly do about the size of libLLVM.so, other than making sure upstream is aware of this.

It is a well known fact to people working with LLVM that a debug build is both large in its outputs and very stressful on the toolchain. This might improve when we get good support for separated debuginfo files, but the toolchain is not quite there yet.

@nagisa
Copy link
Member

nagisa commented Dec 8, 2019

(This also likely does not affect windows as much as it does affect other platforms)

@jyn514
Copy link
Member

jyn514 commented May 20, 2023

Bootstrap is now using hard links for llvm whenever possible:

rust/src/bootstrap/lib.rs

Lines 1520 to 1524 in 77f4f82

if let Ok(()) = fs::hard_link(&src, dst) {
// Attempt to "easy copy" by creating a hard link
// (symlinks don't work on windows), but if that fails
// just fall back to a slow `copy` operation.
} else {

I'm going to close this since upstream is aware of the issue, I don't see much we can do on our end.

@jyn514 jyn514 closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. I-heavy Issue: Problems and improvements with respect to binary size of generated code. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

5 participants