-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
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
(
error: linking with `cc` failed: exit status: 1
|
...45 lines of gibberish...
= note: ld: error: cannot open Scrt1.o: No such file or directory
ld: error: cannot open crti.o: No such file or directory
ld: error: unable to find library -lutil
ld: error: unable to find library -lrt
ld: error: unable to find library -lpthread
ld: error: unable to find library -lm
ld: error: unable to find library -ldl
ld: error: unable to find library -lc
ld: error: cannot open crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
)
...repeated 12 more times.
Proposed Solution
Desired message
$ cargo run
error[E99999]: toolchain `nightly-i686-unknown-linux-gnu` failed linking using `cc`: exit status: 1
|
= note: unable to find glibc-devel (crti.o, crtn.o, and Scrt1.o)
= help: to install glibc-devel for i686, try `rpm-ostree install glibc-devel.i686`
= help: for native toolchain, try `rustup default nightly`
= note: visit <https://doc.rust-lang.org/nightly/rustc/platform-support/{platform-page-with-failed-requirements}.html> for more details
For more information about this error, try `rustc --explain E99999`.
error: could not compile `name` (build script) due to 1 previous error
-
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 requirementshttps://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
ccandlderrors if the issue is just a tool-chain dependency isn't installed. -
I also installed
lld.i686at some point and I am not sure ifrpm-ostree install glibc-devel.i686 lld.i686is more accurate.
Notes
Versions
$ cargo --version
cargo 1.83.0-nightly (a9a418d1a 2024-09-15)