rust-lang / rust-lang/rust-clippy

Locating standard libraries outside of sysroot

Open
#7,017 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug E-medium E-needs-mcve
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

I'm currently working on running Clippy to analyze Rust repositories that are being cross compiled.

The location of sysroot is decided based on the platform being compiled, such as /build/amd64-generic, while the sysroot found by running rustc --print sysroot is /usr. Because this sysroot is different from the sysroot used by the compiling platform, it may not actually contain the compiler itself, or the standard library, which seems to break some of the underlying assumptions being made by Clippy.

I get the following error message: error[E0463]: can't find crate for `std`

On the other hand, running the same commands with cargo build successfully builds the repository. It would therefore seem that Clippy expects the standard library and all other dependencies to exist with the compiler in the same tree in SYSROOT, while cargo build does not.

This makes it difficult to properly support linting before cross compilation.

I'm currently quite new to working with Rust, but I'm happy to contribute in any way I can if someone could offer some pointers or insight on what it would take to support this usecase. Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing how Clippy determines SYSROOT with the rustc --print sysroot result for cross-compilation, and contrast that with the successful cargo build behavior. Trace how the standard library is located and define completion as supporting linting before cross compilation without the can't find crate for std error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.