-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc: Add -C lto=val
option
#47521
rustc: Add -C lto=val
option
#47521
Conversation
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc/session/config.rs
Outdated
|
||
/// Do a local graph LTO with ThinLTO (only relevant for multiple codegen | ||
/// units). | ||
AutoThin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe LocalThin
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ThinLocal
is what I would do.
|
||
// If there's only one codegen unit and LTO isn't enabled then there's | ||
// no need for ThinLTO so just return false. | ||
if self.codegen_units() == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, so I sort of feel like this logic should be in trans somewhere instead of here. Though it doesn't really matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it would make sense to move that to trans at some point because we only really know after CGU partitioning how many object files there are. At moment it's likely that there's always more than one though.
src/librustc_trans/back/write.rs
Outdated
crate_types[0] == config::CrateTypeRlib; | ||
// let crate_types = sess.crate_types.borrow(); | ||
// let only_rlib = crate_types.len() == 1 && | ||
// crate_types[0] == config::CrateTypeRlib; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgotten comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @alexcrichton! I left some comments about the implementation. We'll need buy-in from the whole @rust-lang/compiler team before merging, I think.
|
||
// If there's only one codegen unit and LTO isn't enabled then there's | ||
// no need for ThinLTO so just return false. | ||
if self.codegen_units() == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it would make sense to move that to trans at some point because we only really know after CGU partitioning how many object files there are. At moment it's likely that there's always more than one though.
src/librustc_trans/back/lto.rs
Outdated
Lto::AutoThin => SymbolExportLevel::Rust, | ||
|
||
// We're doing LTO for the entire crate graph | ||
_ => symbol_export::crates_export_threshold(&cgcx.crate_types), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this match
exhaustive?
41ce39b
to
d45a5b7
Compare
Ok I've updated! This PR also now switches the default (the meaning of |
This commit reverts a small portion of the switch to ThinLTO by default which changed the meaning of `-C lto` from "put the whole crate graph into one codegen unit" to "perform ThinLTO over the whole crate graph". This backport has no corresponding commit on master as rust-lang#47521 is making the same change but in a slightly different manner. This commit is intended to be a surgical change with low impact on beta. Closes rust-lang#47409
src/librustc/session/config.rs
Outdated
No, | ||
|
||
/// Do a full crate graph LTO. The flavor is determined by the compiler | ||
/// (currently the default is "thin"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/thin/fat
Thanks, Alex! r=me with the comment updated. |
d45a5b7
to
43c5f62
Compare
@bors: r=michaelwoerister |
📌 Commit 43c5f62 has been approved by |
@bors r- @alexcrichton https://travis-ci.org/rust-lang/rust/builds/330845572#L1220:
|
34c2fa8
to
7517c66
Compare
@bors: r=michaelwoerister |
📌 Commit 7517c66 has been approved by |
@alexcrichton https://travis-ci.org/rust-lang/rust/builds/330958787#L1202:
|
7517c66
to
ee63bc6
Compare
@bors: r=michaelwoerister wheeeeeee |
📌 Commit ee63bc6 has been approved by |
☔ The latest upstream changes (presumably #45684) made this pull request unmergeable. Please resolve the merge conflicts. |
626921e
to
dc902b1
Compare
@bors: r=michaelwoerister |
📌 Commit dc902b1 has been approved by |
☔ The latest upstream changes (presumably #47678) made this pull request unmergeable. Please resolve the merge conflicts. |
This commit primarily adds the ability to control what kind of LTO happens when rustc performs LTO, namely allowing values to be specified to the `-C lto` option, such as `-C lto=thin` and `-C lto=fat`. (where "fat" is the previous kind of LTO, throw everything in one giant module) Along the way this also refactors a number of fields which store information about whether LTO/ThinLTO are enabled to unify them all into one field through which everything is dispatched, hopefully removing a number of special cases throughout. This is intended to help mitigate rust-lang#47409 but will require a backport as well, and this would unfortunately need to be an otherwise insta-stable option.
dc902b1
to
8bde2ac
Compare
@bors: r=michaelwoerister |
📌 Commit 8bde2ac has been approved by |
☔ The latest upstream changes (presumably #47748) made this pull request unmergeable. Please resolve the merge conflicts. |
This commit primarily adds the ability to control what kind of LTO happens when
rustc performs LTO, namely allowing values to be specified to the
-C lto
option, such as
-C lto=thin
and-C lto=fat
. (where "fat" is the previouskind of LTO, throw everything in one giant module)
Along the way this also refactors a number of fields which store information
about whether LTO/ThinLTO are enabled to unify them all into one field through
which everything is dispatched, hopefully removing a number of special cases
throughout.
This is intended to help mitigate #47409 but will require a backport as well,
and this would unfortunately need to be an otherwise insta-stable option.