-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Better Toolchain Error and Help Messages #14572
Comments
Note that CC @weihanglo for input in any designs you are working with. |
@epage Thank you for your quick response and offering potential ways forward. Doesn't the toolchain nightly-i686-unknown-linux-gnu on a x86_64 computer always need i686's crti.o, crtn.o, and Scrt1.o? Even if it is based on which linker you have configured, each native-triple + toolchain + linker set should know in advance which .o/.dll are needed (for at least rust-std). Which can be checked for, either before running the linker, or after the linker returns a non-zero status code. It would be a stop-gap with higher maintenance, but doable with a call to arms for people to submit which packages are needed for their OS + toolchain-triple. Improving this would also help rust gain new users, as devs learning rust to try out bevy have gotten stuck on linker errors, unable to even run hello world. |
so if I understand correctly, you are suggesting we pre-emptively check to see if a known set of libraries for a platform-target triple are present before compiling? For myself, I worry about making that list accurate and our ability to look them up considering all of the shenanigans users can do with their builds. |
I understand build times are already a pain point, so the fastest way is to only check after An alternative option would be to preemptively check in the PATH list that |
I think there is a huge benefit to sane error messages for new users not doing any shenanigans (and for existing users where their OS update changed something). The example above is a >750 line confusing error message that can be detected and replaced with a useful 3 line help message covering 2 different solutions (install these dependencies or change to this native toolchain). |
I think it would be beneficial for |
Thanks for the suggestion. It definitely could improve the user experience for newly onboard users, yet I am not sure how feasible at this moment can Cargo provide a better message. Indeed, Cargo capture diagnostics from the compiler and re-render it to the console. However, the linking error was emitted by the compiler from here, which doesn't seem to have an error code to identify. Cargo may need to guess from the error message body for the root cause. Not too ideal and may be false. Cargo may need to re-implement the logic of finding linker/cc/compiler-runtime-lib, which could be intimidating, especially when considering different versions of different C compiler tooclhains like LLVM, GCC (I've bumped into a bug that a version of LLVM doesn't respect Cargo could potentially collapse the 750-line error messages into one concise messsage, and redirect the original message to a file. However, this may have an impact on build logs in CI, as people may not have way to access and read the redirected log. This will be a problem because Cargo's guess might not always be correct. That being said, I am not turning this down. It just has some technical issue needing more design and exploration. |
Problem
Feature to help debug cargo run failing on first-use or changed computer setup (automatic OS update):
New users should not be expected to know rustc, linkers, llvm, cc, nor ld to use
cargo run
.New users should not be expected to know which packages have which .o files for which archs.
Current message
$
cargo run
(
...45 lines of gibberish...
)
...repeated 12 more times.
Proposed Solution
Desired message
$
cargo run
A first pass improvement on this is a low hanging fruit, but a robust solution will take a lot of work and tests per target-triple os pair.
The platform link
https://doc.rust-lang.org/nightly/rustc/platform-support/{platform-with-failed-requirements-page}.html
should display if the toolchain has detected failed requirements or complex undetectable requirements
https://doc.rust-lang.org/nightly/rustc/platform-support/apple-darwin.html
Take into account if current project is stable or unstable, but default to unstable if unknown (for compatibility).
Take into account best/default available package manager with sane prioritizing: nix else rpm-ostree else dnf/apt-get else ...etc.
Detect which packages are needed and what labels to use that aren't fixed to a version. (glibc-devel.i686 instead of glibc-devel-2.39-22.fc40.i686, this allows the package manager to handle version requirements.) Show "help: " message(s) recommending needed package(s).
Do not show
cc
andld
errors if the issue is just a tool-chain dependency isn't installed.I also installed
lld.i686
at some point and I am not sure ifrpm-ostree install glibc-devel.i686 lld.i686
is more accurate.Notes
Versions
$
cargo --version
The text was updated successfully, but these errors were encountered: