Skip to content

File fallback for an argument too long #2815

Open

Description

@user2589

TLDR: in a very particular set of circumstances, sccache might get an argument so long it can't be passed over the command line.

I've ran into a weird issue. There's an external dependency with 3K+ features, which cargo passes as a single --check-cfg argument to rustc. Linux per-argument limit is 32x PAGE_SIZE, 128kb on my machine. Well, that long argument happened to cross that line.

cargo has a retry_with_argfile fallback for that, writing a tempfile and passing it as rustc @tempfile when it faces E2BIG, but sccache doesn't. It would be really nice if it did.

The ask is for sccache to implement cargo's E2BIG -> @tmpfile retry when spawning rustc

Activity

  1. Kobzol commented on Aug 19, 2026

    @Kobzol

    If this error happens, shouldn't sccache just propagate the error in the same way rustc normally would, and then Cargo would retry it with an argfile? Sccache gained support for reading argfiles recently.

  2. user2589 commented on Aug 19, 2026

    @user2589
    Author

    @Kobzol sccache expands argfiles and passes that down as a list of arguments. Would it be enough to use expanded args for cache key but pass down the original argfile?

  3. Kobzol commented on Aug 20, 2026

    @Kobzol

    I think so, #2789 implements that.

  4. user2589 commented on Aug 20, 2026

    @user2589
    Author

    That's a move in the right direction, but that PR sets the threshold on Linux to 1MB. Which makes sense for all args combined, but the issue in question is just one arg - and a single arg limit on Linux is 32 page sizes, ~128kb on most systems. Is it possible to lower the threshold to 128K (or even a little less)?

    // I'll test this tomorrow morning and submit a PR if it works

  5. user2589 commented on Aug 20, 2026

    @user2589
    Author

    @Kobzol I tested that PR with a lower threshold and it fixes this issue. Left a comment there, looking forward for it to be merged and released

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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions