-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't apply msvc link opts for non-opt build #37994
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
As a comparison, for the build script of libbindgen, with |
If we are going to disable |
I agree that we should do incremental linking as well. But I think that change could be more complicated than simply turning off the link-time optimization for debug build. And this trivial change shows a great win on link time, especially for crates who have lots of generated code. As I've mentioned above, switching from So I think we should take it as soon as possible without letting further potential improvement block it. |
|
@ollie27 Cargo deletes the old binary before invoking rustc, so at the moment there is no chance of the result of previous linking being usable for incremental linking. Making incremental linking actually possible should be as simple as telling cargo to not delete that sort of stuff, although it'll be a while before anyone actually teaches cargo when to do that. |
Well maybe we should explicitly pass |
@Manishearth or @pnkfelix, can you review @upsuper's linker change here? This is a big productivity issue. This PR reduces his link times from three minutes (!!) to one second by disabling MSVC LTO for debug builds. |
Incremental linking may need more investigation to see whether that works well with Rust's binaries. I did see an issue that incremental linked binary (linking a Rust library into Gecko) sometimes has weird runtime error inside Rust code. |
Thanks for the PR! Sorry about taking a bit to get around to this. I'd be curious to play around a bit here with the various options before we just turn this off entirely. We get significant size wins sometimes with IIRC Also, could you take a look at the traditional "hello world" and see what the difference in the size of the executable is? Does it jump by megabytes or does it remain the same? In any case I think we definitely need to change something here because a 100s link time is crazy huge. Just want to explore the possibility space ahead of time! |
I tried building the build script of libbindgen. This is the data:
And for binary of rust-bindgen:
I didn't run them many times, but it seems to me the time consumption is roughly stable, and somehow faster than my measurement before. Probably because that laptop is not doing anything else this time. So it seems the binary size is indeed much larger without the optimizations (~2.3x), but the reduction of time consumption should well justify that difference. |
Oh, |
Updated the data with |
Updated the patch to use |
📌 Commit 3fcbdfe has been approved by |
⌛ Testing commit 3fcbdfe with merge abc1ef6... |
💔 Test failed - auto-win-msvc-64-opt-rustbuild |
@alexcrichton Could you review the test change? |
@bors: r+ |
📌 Commit 257f643 has been approved by |
Don't apply msvc link opts for non-opt build `/OPT:REF,ICF` sometimes takes lots of time. It makes no sense to apply them when doing debug build. MSVC's linker by default disables these optimizations when `/DEBUG` is specified, unless they are explicitly passed.
/OPT:REF,ICF
sometimes takes lots of time. It makes no sense to apply them when doing debug build. MSVC's linker by default disables these optimizations when/DEBUG
is specified, unless they are explicitly passed.