-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix LTO with doctests. #8657
Merged
Merged
Fix LTO with doctests. #8657
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(rust_highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Aug 28, 2020
@bors: r+ |
📌 Commit 5bbad10 has been approved by |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Aug 28, 2020
☀️ Test successful - checks-actions |
ehuss
pushed a commit
to ehuss/cargo
that referenced
this pull request
Aug 28, 2020
Fix LTO with doctests. This fixes an issue where `cargo test --release` would fail to run doctests if LTO is set in `profile.release` or `profile.bench`. The issue is that dependencies were built with `-Clinker-plugin-lto`, but the final rustdoc invocation did not issue `-C lto`. This causes a link failure (or crash!) because the necessary object code was missing. This is because rustdoc historically did not support codegen flags, so Cargo has never passed them in. Rustdoc now supports codegen flags (via rust-lang/rust#63827), so it should be safe to start passing them in. For now, I am only adding LTO, but more should be added in the future. There are two bugs here. One is that LTO flags aren't passed to rustdoc. The other is that the "doctest" unit was using the wrong profile (it was using dev/release when it should be using test/bench). There are two distinct scenarios here. One where just `release` has `lto` set. And one where both `release` and `bench` have `lto` set. This is relevant because LTO mostly cares about what the final artifact wants, and in the case where `bench` does not have `lto` set, then LTO will not be used for tests. This will hopefully be a little cleaner in the future when rust-lang#6988 is stabilized, which causes the test/bench profiles to *inherit* from the dev/bench profiles, which means you won't need to manually synchronize the test/bench profiles with dev/release. Fixes rust-lang#8654
This was referenced Aug 28, 2020
bors
added a commit
that referenced
this pull request
Aug 28, 2020
[beta] Fix LTO with doctests. Beta packports: * #8653 Fix cache_messages::rustdoc test broken on beta. — so that CI tests pass * #8648 Add spaces after -C and -Z flags for consistency — so that #8657 can be merged * #8657 Fix LTO with doctests. Although the LTO regression is on 1.46, I probably won't do a stable backport even if there is a point release, as I think it would be good to have sufficient time for testing on nightly, and I don't want to rush it. I'm willing to reconsider that, though.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Aug 31, 2020
Update cargo 8 commits in 51b66125ba97d2906f461b3f4e0408f206299bb6..126907a7cfccbe93778530e6a6bbaa3adb6c515c 2020-08-19 20:22:52 +0000 to 2020-08-31 20:42:11 +0000 - Fix flakiness in close_output test (rust-lang/cargo#8668) - Reload unstable table from config file in `reload_rooted_at` (rust-lang/cargo#8656) - Bump to 0.49.0, update changelog (rust-lang/cargo#8659) - Fix LTO with doctests. (rust-lang/cargo#8657) - Add spaces after -C and -Z flags for consistency (rust-lang/cargo#8648) - Fix cache_messages::rustdoc test broken on beta. (rust-lang/cargo#8653) - fix: remove unnecessary allocations (rust-lang/cargo#8641) - Fixed a spelling and some clippy warnings (rust-lang/cargo#8637)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue where
cargo test --release
would fail to run doctests if LTO is set inprofile.release
orprofile.bench
.The issue is that dependencies were built with
-Clinker-plugin-lto
, but the final rustdoc invocation did not issue-C lto
. This causes a link failure (or crash!) because the necessary object code was missing. This is because rustdoc historically did not support codegen flags, so Cargo has never passed them in. Rustdoc now supports codegen flags (via rust-lang/rust#63827), so it should be safe to start passing them in. For now, I am only adding LTO, but more should be added in the future.There are two bugs here. One is that LTO flags aren't passed to rustdoc. The other is that the "doctest" unit was using the wrong profile (it was using dev/release when it should be using test/bench).
There are two distinct scenarios here. One where just
release
haslto
set. And one where bothrelease
andbench
havelto
set. This is relevant because LTO mostly cares about what the final artifact wants, and in the case wherebench
does not havelto
set, then LTO will not be used for tests. This will hopefully be a little cleaner in the future when #6988 is stabilized, which causes the test/bench profiles to inherit from the dev/bench profiles, which means you won't need to manually synchronize the test/bench profiles with dev/release.Fixes #8654