Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto#118378
Merged
bors merged 1 commit intorust-lang:masterfrom Nov 29, 2023
Merged
Perform LTO optimisations with wasm-ld + -Clinker-plugin-lto#118378bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
Collaborator
|
(rustbot has picked a reviewer for you, use r? to override) |
| LinkerPluginLto::Disabled => { | ||
| // Nothing to do | ||
| } | ||
| LinkerPluginLto::LinkerPluginAuto => { |
Contributor
There was a problem hiding this comment.
Suggested change
| 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.
Contributor
Author
There was a problem hiding this comment.
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 optimizethat controls merging sections only, unrelated to LLVM. push_linker_plugin_lto_argscould be inlined, but I was going to do another PR that puts warnings in one of the match arms but not the other.
Contributor
|
@bors r+ rollup |
Collaborator
ghost
reviewed
Nov 28, 2023
| 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.
Suggested change
| // wasm-ld only handles integer LTO opt levels. Use O2 | |
| // `wasm-ld` only handles integer LTO opt levels. Use O2. |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 28, 2023
…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
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 28, 2023
…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
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 29, 2023
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.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes (partially) #60059. Technically,
--target wasm32-unknown-unknown -Clinker-plugin-ltowould 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.