-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Deprecate no-op codegen option -Cinline-threshold=...
#124712
Conversation
r? @JohnTitor rustbot has assigned @JohnTitor. Use |
@@ -1502,7 +1502,8 @@ options! { | |||
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED], | |||
"enable incremental compilation"), | |||
inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED], | |||
"set the threshold for inlining a function"), | |||
"this option is deprecated and does nothing \ | |||
(consider using `-Cllvm-args=--inline-threshold=...`)"), |
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.
Will this have any effect if they do?
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.
Yes that makes a difference. Building e.g. libstd with -Cllvm-args=--inline-threshold=100000
vs -Cllvm-args=--inline-threshold=2
reliably makes a big difference in the size of .text
, namely 1594 kB vs 367 kB:
$ RUSTFLAGS="-Ccodegen-units=1 -Cllvm-args=--inline-threshold=100000" ./x build --stage 0 library/std
$ size ./build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/libstd.rlib
text ...
0 ...
1594437 ...
$ RUSTFLAGS="-Ccodegen-units=1 -Cllvm-args=--inline-threshold=2" ./x build --stage 0 library/std
$ size ./build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/libstd.rlib
text ...
0 ...
367682 ...
Another example is bat with 33 MB vs 5.4 MB:
$ RUSTFLAGS="-Cllvm-args=--inline-threshold=2" cargo build --release
$ ls -hl target/release/bat
-rwxr-xr-x 2 martin martin 5.4M May 5 10:58 target/release/bat
$ RUSTFLAGS="-Cllvm-args=--inline-threshold=100000" cargo build --release
$ ls -hl target/release/bat
-rwxr-xr-x 2 martin martin 33M May 5 11:13 target/release/bat
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.
Oh neat, I'm surprised it does anything!
r? compiler |
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.
The GH issue had a fair bit of discussion and ppl seemed to have mostly settled on deprecation + warning. While you've obviously taken the NOP (+ doc) approach, emitting a warning or remapping it to -C llvm-args=-inline-threshold=
are still valid options.
Emitting a warning would've likely prevented the odyssey as reported in #89742 (comment). Not a fan of non-lint warnings (i.e., ones that cannot be suppressed) but I think it would make perfect sense here. -Cno-stack-check
emits a warning for example (-Car=...
doesn't OTOH).
Regarding remapping to LLVM's "new"(?) inline-threshold
I'm not well-versed enough in the matter to be able to give any input on that. Apart from semantic differences compared to the OldPM days (which seems to be the case having read the discussion), I guess another factor are the guarantees we (want to) provide for -C*
flags esp. wrt. alternative codegen backends (codegen_{cranelift,gcc}
are still unstable ofc). I don't know anything about that, so I'll let sb. else take a look at this PR.
I'm pretty sure this needs a compiler FCP, therefore: |
@@ -1502,7 +1502,8 @@ options! { | |||
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED], | |||
"enable incremental compilation"), | |||
inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED], |
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.
TL;DR: If the deprecation ends up getting accepted (rather than the remapping), please emit a warning like -Cno-stack-check
does (and unlike -Car=...
which we might want to change in a separate PR).
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.
Done, including regression test.
Note that I also added this commit to this PR:
commit 651ff643ae68438213bded335ef47cc9c50d3039
Author: Martin Nordholts <martin.nordholts@codetale.se>
Date: Fri Jun 14 19:48:40 2024 +0200
Fix typo in `-Cno-stack-check` deprecation warning
The flag `--no-stack-check` does not exist:
$ rustc --no-stack-check
error: Unrecognized option: 'no-stack-check'. Did you mean `-C no-stack-check`?
Remapping would probably have been good in late 2021 instead of making Also, maintaining the mapping will be quite much work. There are several knobs in LLVM to tweak, and people will have opinions on how to do it. I foresee endless discussions on how we should do it exactly. And this problem is multiplied for each codegen backend. So given where we are today, I think it is best to not try to remap. But emitting a warning like |
be39c26
to
97c67ee
Compare
inline-threshold
-Cinline-threshold=...
The flag `--no-stack-check` does not exist: $ rustc --no-stack-check error: Unrecognized option: 'no-stack-check'. Did you mean `-C no-stack-check`?
This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago.
97c67ee
to
f5f067b
Compare
i think our official process when it comes to changing the stable command line interface of rustc is the Major Change Proposal (MCP) process. But this specific change strikes me largely as a bug fix where the PR author is trying to make the whole thing more coherent (while also making the actual change quite minimal), and I don't think it warrants an MCP. So, I'm going to r+ (because I don't think we need to further delay landing this change), but I also am going to nominate this PR so that the T-compiler team can double-check whether I am right that there exists some CLI changes that do not warrant an MCP. @bors r+ |
(as an example of why I nominated this, the T-compiler team might want to discuss the valid feedback left by @fmease , in order to determine whether an MCP was in fact warranted here.) |
…mpiler-errors Rollup of 11 pull requests Successful merges: - rust-lang#124460 (Show notice about "never used" of Debug for enum) - rust-lang#124712 (Deprecate no-op codegen option `-Cinline-threshold=...`) - rust-lang#125082 (Remove `MaybeUninit::uninit_array()` and replace it with inline const blocks.) - rust-lang#125575 (SmartPointer derive-macro) - rust-lang#126413 (compiletest: make the crash test error message abit more informative) - rust-lang#126673 (Ensure we don't accidentally succeed when we want to report an error) - rust-lang#126682 (coverage: Overhaul validation of the `#[coverage(..)]` attribute) - rust-lang#126899 (Suggest inline const blocks for array initialization) - rust-lang#126904 (Small fixme in core now that NonZero is generic) - rust-lang#126909 (add `@kobzol` to bootstrap team for triagebot) - rust-lang#126911 (Split the lifetimes of `MirBorrowckCtxt`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#124712 - Enselic:deprecate-inline-threshold, r=pnkfelix Deprecate no-op codegen option `-Cinline-threshold=...` This deprecates `-Cinline-threshold` since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago. Recommend using `-Cllvm-args=--inline-threshold=...` instead. Closes rust-lang#89742 which is E-help-wanted.
This deprecates
-Cinline-threshold
since using it has no effect. This has been the case since the new LLVM pass manager started being used, more than 2 years ago.Recommend using
-Cllvm-args=--inline-threshold=...
instead.Closes #89742 which is E-help-wanted.