-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Powershell-aware panic environment variable suggestions in backtraces… #99902
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
Conversation
… and grammatical consistency.
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
library/std/src/panicking.rs
Outdated
writeln!( | ||
err, | ||
"note: run with `$env:RUST_BACKTRACE=1` environment variable to display a backtrace." | ||
) | ||
} else { | ||
writeln!( | ||
err, | ||
"note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace." | ||
) | ||
}; |
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.
Because .NET Core has made itself sufficiently cross-platform, my understanding is that for macOS, Linux, or Windows, we may be in PowerShell (and for all I know, PS runs on the BSDs too, with sufficient hackery). So we should not simply cfg this out if we accept this PR. And we can only know the value of this env var at runtime, which means we have to include these two strings both in the binary, and we have to make the branch.
While LLVM may successfully merge these strings into the same one, I think that if we accept this, we are probably better off splitting this write up (write!
, then writeln!
) and only writing "$env:"
conditionally, with a fairly similar logic for the hint for using RUST_BACKTRACE="full"
. Which is valid syntax in a POSIX shell, by the way, so we can again reuse the same string.
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 feel like the strings are too tiny to have an actual real world effect on performance/binary size? Like, yes, you are correct and I agree that simply inserting "$env:" would be smaller. But it's barely anything in the first place 🤷🏻
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.
Well... I agree it's very little, but a very little is a lot if we're running on a machine with only MB, not GB, of RAM, one that nonetheless fits the Linux kernel and... probably someone's copy of the Almquist shell, they're usually lighter than bash. A lot of people in such cases complain about the weight of panic code, especially for uses where they're not interactively running the device and it's just a tiny server for some things.
On the other hand, maybe seeing too many requests on the Rust issue tracker to optimize out Literally Two Bytes from a binary has taken a toll on my sanity and I have finally Lost It. You decide.
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.
oof, sounds rough. Fair enough, tbh.
Will commit later 👍🏻
So, this might be a bit more complicated. The tests system for Rust will now need to support having a Powershell attribute, as if the developer hacking on Rust is using Powershell, the tests would fail. cc @jyn514 |
@rustbot author |
The job Click to see the possible cause of the failure (guessed by this bot)
|
… and grammatical consistency.
This is forwarded from #98815 as I was having git problems. Sorry.