Skip to content

Which version of librustc_driver clippy uses? #14764

Open
@manswami23

Description

@manswami23

Description

Hello,

I'm a beginner trying to poke around in clippy. I've asked a couple silly questions so far, so I hope nobody minds a couple more :). I'm specifically poking around with how clippy determines which rustc_driver to link against.

On my machine, I've got two toolchains installed through rustup. nightly-2025-02-06 and stable 1.86.0.

bash-5.2# rustup show
Default host: aarch64-unknown-linux-gnu
rustup home:  /root/.rustup

installed toolchains
--------------------
nightly-2025-02-06-aarch64-unknown-linux-gnu (active)
1.86.0-aarch64-unknown-linux-gnu (default)

I've noticed that when I run clippy with the nightly toolchain, it links against a specific version of rustc_driver: librustc_driver-3e6e9637b7731f3f.so.

When I run clippy with the 1.86.0 toolchain, it looks for librustc_driver-d10e1ea80d090031.so.

Originally, I assumed that the difference is because both clippy versions are being packaged with different rust toolchains. And that there's probably something happening as part of this packaging that dictates to the final clippy executable which driver to link against.

However, I started to stumble when I noticed that for the version of clippy that's been copied/synced into the rust repo for rust 1.86.0, it's toolchain declares that it must be built with nightly-2025-02-06: https://github.com/rust-lang/rust/blob/1.86.0/src/tools/clippy/rust-toolchain.

And I confirmed on my local that when I manually build clippy at commit 3e3715c (ie the commit which I believe corresponds to the aforementioned copied/synced clippy code), the resulting cargo-clippy executable looks for librustc_driver-3e6e9637b7731f3f.so, not librustc_driver-d10e1ea80d090031.so. That is to say, it links against the driver from the nightly toolchain rather than the stable 1.86 toolchain.

(If it helps, this is how I build clippy: cargo build --release --bin cargo-clippy --bin clippy-driver -Zunstable-options --out-dir "$(rustc --print=sysroot)/bin")

So I guess my questions are

  1. How come when I built clippy independently using the nightly toolchain, the resulting executable loads the nightly toolchain's rustc_driver. Whereas the clippy embedded inside the rust repo is linking against the stable tool chain rustc_driver even though the clippy toolchain.toml file specifies it builds against the nightly.
  2. Is there some logic that specifies for the clippy code embedded inside the rust repo, that it should specifically link against the toolchain for that version of rust rather than the nightly toolchain with which clippy was built? If so, could someone point me to that logic?
  3. When I built clippy locally, how can I dictate the final program to link against the stable rustc_driver?

Thanks!

Version

Stable Toolchain

rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: aarch64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7


Nightly Toolchain that I'm using to build clippy locally
rustc 1.86.0-nightly (a9730c3b5 2025-02-05)
binary: rustc
commit-hash: a9730c3b5f84a001c052c60c97ed0765e9ceac04
commit-date: 2025-02-05
host: aarch64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Additional Labels

@rustbot label + C-question

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions