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

Some LTO fixes. #8349

Merged
merged 1 commit into from
Jun 11, 2020
Merged

Some LTO fixes. #8349

merged 1 commit into from
Jun 11, 2020

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Jun 10, 2020

This reworks the LTO computation a little to address a few issues:

  • cargo build in a project with both a lib and bin would not engage the optimization introduced in Don't force rustc to do codegen for LTO builds #8192 where the lib should be compiled with -C linker-plugin-lto (bitcode only). This happened because the old code was starting root units as Lto::None. The solution here is to conditionally choose the starting Lto for roots.
  • A project with a dylib dependency would fail to build. It was building the dylib with -C linker-plugin-lto which is not valid.
  • A project with a bin/lib would build the lib differently based on whether or not it was selected. This changes it so that the lib is built the same. See lto::between_builds, where the second build the lib is now fresh.
  • Tests/benchmarks of a lib target will now support LTO.
  • Treats example libs a little more consistently as regular libs.

I scattered some comments throughout, hopefully it's not too difficult to follow.

Closes #8337

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 10, 2020
.build()
}

fn verify_lto(output: &Output, krate: &str, krate_info: &str, expected_lto: Lto) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is really necessary, it's a lot of code to do very little. The main thing is that I want to detect builds that don't pass any flags (Lto::ObjectAndBitcode), which is difficult to do with the current infrastructure. I could instead use with_stderr_line_without, or just not bother asserting that condition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah I think this is fine, it's just tests anyway so I don't think there's much need to be super strict about style and such.

@alexcrichton
Copy link
Member

@bors: r+

All looks great to me, thanks for all the comments!

@bors
Copy link
Collaborator

bors commented Jun 11, 2020

📌 Commit 62a61dd has been approved by alexcrichton

@bors 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 Jun 11, 2020
@bors
Copy link
Collaborator

bors commented Jun 11, 2020

⌛ Testing commit 62a61dd with merge ee417cb...

@bors
Copy link
Collaborator

bors commented Jun 11, 2020

☀️ Test successful - checks-azure
Approved by: alexcrichton
Pushing ee417cb to master...

@bors bors merged commit ee417cb into rust-lang:master Jun 11, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 12, 2020
Update cargo

2 commits in 1ec223effbbbf9fddd3453cdcae3a96a967608eb..79c769c3d7b4c2cf6a93781575b7f592ef974255
2020-06-09 20:03:14 +0000 to 2020-06-11 22:13:37 +0000
- Fix failure with missing readme. (rust-lang/cargo#8353)
- Some LTO fixes. (rust-lang/cargo#8349)
@ehuss ehuss added this to the 1.46.0 milestone Feb 6, 2022
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LTO behavior depends on root targets
4 participants