-
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
Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto #118378
Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto #118378
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
LinkerPluginLto::Disabled => { | ||
// Nothing to do | ||
} | ||
LinkerPluginLto::LinkerPluginAuto => { |
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.
LinkerPluginLto::LinkerPluginAuto => { | |
LinkerPluginLto::LinkerPluginAuto | LinkerPluginLto::LinkerPlugin(_) => { |
push_linker_plugin_lto_args
could then be inlined and removed.
Upd: the match on self.sess.opts.optimize
could be kept separate function, though, it is shared between fn optimize
and fn linker_plugin_lto
.
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.
I intentionally left them separate.
- That the match turns out the same is more of a coincidence than anything else. I anticipate the
--lto-O*
args may change to support Os and Oz in future. (Especially with those being the most popular opt levels for webassembly.) If that happens, adding Os/Oz to a shared match statement would break the normalfn optimize
that controls merging sections only, unrelated to LLVM. push_linker_plugin_lto_args
could be inlined, but I was going to do another PR that puts warnings in one of the match arms but not the other.
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.
Ok.
@bors r+ rollup |
config::OptLevel::Less => "O1", | ||
config::OptLevel::Default => "O2", | ||
config::OptLevel::Aggressive => "O3", | ||
// wasm-ld only handles integer LTO opt levels. Use O2 |
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.
// wasm-ld only handles integer LTO opt levels. Use O2 | |
// `wasm-ld` only handles integer LTO opt levels. Use O2. |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#118193 (Add missing period in `std::process::Command` docs) - rust-lang#118222 (unify read_to_end and io::copy impls for reading into a Vec) - rust-lang#118323 (give dev-friendly error message for incorrect config profiles) - rust-lang#118378 (Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto) - rust-lang#118399 (Clean dead codes in miri) - rust-lang#118410 (update test for new LLVM 18 codegen) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#118193 (Add missing period in `std::process::Command` docs) - rust-lang#118222 (unify read_to_end and io::copy impls for reading into a Vec) - rust-lang#118323 (give dev-friendly error message for incorrect config profiles) - rust-lang#118378 (Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto) - rust-lang#118399 (Clean dead codes in miri) - rust-lang#118410 (update test for new LLVM 18 codegen) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#118378 - cormacrelf:bugfix/linker-plugin-lto-wasm, r=petrochenkov Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto Fixes (partially) rust-lang#60059. Technically, `--target wasm32-unknown-unknown -Clinker-plugin-lto` would complete without errors before, but it was not producing optimized code. At least, it may have been but it was probably not the opt-level people intended. Similarly to rust-lang#118377, this could benefit from a warning about using an explicit libLTO path with LLD, which will ignore it and use its internal LLVM. Especially given we always use lld on wasm targets. I left the code open to that possibility rather than making it perfectly neat.
Fixes (partially) #60059. Technically,
--target wasm32-unknown-unknown -Clinker-plugin-lto
would complete without errors before, but it was not producing optimized code. At least, it may have been but it was probably not the opt-level people intended.Similarly to #118377, this could benefit from a warning about using an explicit libLTO path with LLD, which will ignore it and use its internal LLVM. Especially given we always use lld on wasm targets. I left the code open to that possibility rather than making it perfectly neat.