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

Consider building libstd with codegen-units=1 for release artifacts #54872

Closed
michaelwoerister opened this issue Oct 6, 2018 · 6 comments
Closed
Labels
T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-release Relevant to the release subteam, which will review and decide on the PR/issue. WG-llvm Working group: LLVM backend code generation

Comments

@michaelwoerister
Copy link
Member

The main reason I'd like to have this is because it would allow fat-LTO'ed staticlibs to be used as input for LLD-based ThinLTO (which is something that Firefox might want to do, if it brings performance wins). It might also improve runtime performance of all Rust programs without incurring as much of a CI cycle time penalty as building everything with -Ccodegen-units=1 would.

cc @rust-lang/release

@michaelwoerister michaelwoerister added A-build T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-release Relevant to the release subteam, which will review and decide on the PR/issue. WG-llvm Working group: LLVM backend code generation labels Oct 6, 2018
@Mark-Simulacrum
Copy link
Member

To clarify, this is just std? Or would we want std and its dependencies? It does seem plausible that std being built in this fashion would fit into the window of time we have, cc @alexcrichton @rust-lang/infra

@Mark-Simulacrum Mark-Simulacrum added the T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. label Oct 6, 2018
@michaelwoerister
Copy link
Member Author

To clarify, this is just std?

Everything from libcore to libstd.

@alexcrichton
Copy link
Member

I agree that this has a possibility of making some release-mode Rust programs faster by default as well (as std itself will get more inlining opportunities), although I suspect the number of programs there that get faster is quite small in that almost all perf-sensitive funcitons in libstd are already monomorphized/inlined. I agree though that the amount of time it takes on CI to build libstd/libcore with one CGU should be pretty minimal.

@michaelwoerister I don't understand though what you mention is the original motivation for this issue? If you fat-LTO all Rust code together into a staticlib that doesn't matter how many CGUs each of the input crates has, right? It should be compatible with libstd having any number of CGUs, and we'd just need to make sure that the staticlib output is compatible with LLD-based ThinLTO

@michaelwoerister
Copy link
Member Author

@alexcrichton The problem is just that we run into a form of #53912 with a ThinLTO'd libstd because some symbols in there have gone through the ThinLTO mangling before LLD does it a second time. The problem could also be solved by doing some kind of fix-up pass on the IR before emitting it into the staticlib.

@alexcrichton
Copy link
Member

Ah ok, makes sense!

We've already got a smattering of weird patches of "randomly patching LLVM IR" to avoid bugs in LLVM so shouldn't be too hard to add another!

@michaelwoerister
Copy link
Member Author

Yes, such a pass will probably be the more stable option in the long run.

bors added a commit that referenced this issue Oct 23, 2018
Compile the libstd we distribute with -Ccodegen-unit=1

This PR
 - adds the `single-codegen-unit-std` option to `config.toml` which allows for setting the CGU count for `libstd` and `libtest` independently of the one for the rest of the compiler, and
 - sets the new option to `true` for all dist jobs in CI.

Fixes #54872.

r? @Mark-Simulacrum
cc @rust-lang/release
bors added a commit that referenced this issue Oct 23, 2018
Compile the libstd we distribute with -Ccodegen-unit=1

This PR
 - adds the `single-codegen-unit-std` option to `config.toml` which allows for setting the CGU count for `libstd` and `libtest` independently of the one for the rest of the compiler, and
 - sets the new option to `true` for all dist jobs in CI.

Fixes #54872.

r? @Mark-Simulacrum
cc @rust-lang/release
kennytm added a commit to kennytm/rust that referenced this issue Oct 26, 2018
…simulacrum

Compile the libstd we distribute with -Ccodegen-unit=1

This PR
 - adds the `single-codegen-unit-std` option to `config.toml` which allows for setting the CGU count for `libstd` and `libtest` independently of the one for the rest of the compiler, and
 - sets the new option to `true` for all dist jobs in CI.

Fixes rust-lang#54872.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-release Relevant to the release subteam, which will review and decide on the PR/issue. WG-llvm Working group: LLVM backend code generation
Projects
None yet
Development

No branches or pull requests

3 participants