Skip to content

RUSTC_WORKSPACE_WRAPPER tracking issue #8143

Closed

Description

@ehuss

RUSTC_WORKSPACE_WRAPPER was added in #7533, primarily for clippy support, but could be useful for others.

Differences from RUSTC_WRAPPER:

  • Only runs for workspace members.
  • Path is included in the filename hash (which ensures these artifacts are cached separately from usage without the wrapper).

You can test drive this with cargo clippy -Zunstable-options on the latest nightly.

One of the primary benefits is that now cargo clippy can share the same cache with cargo check for non-workspace members.

Before stabilizing, some things to consider:

  • Is this the right design?
  • This doesn't help with wrapping only specific crates (like just the "primary" ones). Sometimes people want to only have clippy lints for the "root" crate, or for specific crates specified on the command-line (Limit to specific package in workspace, also excluding its dependencies rust-clippy#3025). With this change for clippy, cargo clippy -p NAME only works for workspace members.
    • Cargo previously had an undocumented CARGO_PRIMARY_PACKAGE environment variable, perhaps something like that could be used?
    • How should tools like clippy handle -p non-member?
  • RUSTC_WORKSPACE_WRAPPER doesn't currently work with sccache. How difficult would this be to fix?
  • Some tools may want to use arguments with the wrapper. For example, my-tool wrapper would pass the "wrapper" argument to my-tool to tell it is in wrapper mode. Currently the env vars do not allow passing in arguments. Alternatively, Cargo could set some special env var to inform the executable that it is being used as a wrapper.

cc @yaahc

Activity

  1. ehuss commented on Apr 25, 2020

    @ehuss
    ContributorAuthor

    One problem that I ran into is when running cargo clippy --fix for a specific package in a workspace, clippy still runs for all other workspace members. This means that any workspace dependency that has a deny-level clippy lint will cause the build to fail. This is essentially rust-lang/rust-clippy#3025.

    I'm not sure how important that is, but it seems like it would make adopting clippy in a larger workspace to be difficult (and make the --fix flag especially difficult to start using). I don't really have any ideas for the UI to switch that behavior (other than some command-line flag or env-var?).

  2. added a commit that references this issue on Sep 12, 2020
  3. added a commit that references this issue on Oct 22, 2020
  4. added a commit that references this issue on Dec 9, 2020
  5. ehuss commented on Dec 13, 2020

    @ehuss
    ContributorAuthor

    @ebroto I've noticed you've gotten some fixes landed in clippy recently 🎉 (sorry, I haven't been able to help review or push those through). Do you think it is time to go ahead and stabilize this? I don't think I have any specific objections (or at least can't think of a better design for this use case). If so, are you interested in working on a PR?

  6. ebroto commented on Dec 13, 2020

    @ebroto
    Contributor

    (sorry, I haven't been able to help review or push those through)

    No problem! Your guidance here has been really helpful :)

    Do you think it is time to go ahead and stabilize this?

    I think so. We could improve the process of passing arguments to the wrapper (the current solution in Clippy is hacky), but I think that could be addressed separately, as landing this would really improve Clippy's usability in stable.

    If so, are you interested in working on a PR?

    Yes! I'm not sure what's involved here but I can take a look at other tracking issues.

  7. ehuss commented on Dec 13, 2020

    @ehuss
    ContributorAuthor

    I think it should be pretty easy:

  8. added a commit that references this issue on Dec 21, 2020
    e10b791
  9. luser commented on Feb 11, 2021

    @luser
    Contributor
    * RUSTC_WORKSPACE_WRAPPER doesn't currently work with sccache. How difficult would this be to fix?
    

    Coming into this extremely late, but this doesn't seem terribly important. For CI usage I would expect projects to simply use RUSTC_WRAPPER. For local builds, workspace crates have incremental compilation enabled by default and sccache declines to cache incremental compiles (because it would just do a worse job than rustc anyway), so there's no real motivation to want this to work.

  10. moved this to Done in Cargo Roadmapon Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions