sccache: Compiler not supported: "error: Unrecognized option: \'E\'\n\n"

Just upgraded to Rust 1.52.0 and get this:

sccache: error: failed to execute compile
sccache: caused by: Compiler not supported: "error: Unrecognized option: \'E\'\n\n"
error: could not compile `xxx`

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 12
  • Comments: 20 (7 by maintainers)

Most upvoted comments

I ran into this issue, and in my case the problem was that I had installed sccache with cargo binstall which by default creates a symlink to the actual sccache binary.

I reinstalled without the symlink with cargo binstall --no-symlinks -y sccache and everything worked fine. It’s a bit weird, sccache probably shouldn’t fail if its symlinked, so that’s another problem.

PS: I’m using this as part of some GitHub actions I recently created because I didn’t like the existing ones:

https://github.com/brndnmtthws/rust-action https://github.com/brndnmtthws/rust-action-rustup https://github.com/brndnmtthws/rust-action-cargo-binstall

Perhaps other people will get some value out of these.

@drahnr I don’t seem to be able to actually trigger this with a simple use-case. I’ve encountered this issue on some internal codebase that uses the latest Rust via rustup.

When I’ll get the chance I’ll try to trigger it once more and see if I can reduce it to a simpler scenario.

After a little investigation, this is because Rust is trying to call sccache cc main.c, and since the symlink was setup, when the command gets to sccache it has become sccache sccache main.c, something that sccache doesn’t seem to accept.

I’ve also stumbled upon this issue. (In my case I only had RUSTC_WRAPPER=sccache exported, and no other hardlinks to sccache.)

However, I’ve managed to implement a small proof-of-concept sccache wrapper (yes, a wrapper to the wrapper) that is able to correctly handle all these situations:

  • works if RUSTC_WRAPPER=sccache and rustc calls cc or another compiler; (basically it ignores the double sccache sccache cc invocation;)
  • works if this wrapper is symlinked to cc, gcc, rustc, etc. somewhere in the path; (i.e. it switches to sccache cc😉 (this perhaps covers #993)
  • the above two combined;

sccache.txt

One can just download it, change the extension, chmod +x and then start symlink-ing it to sccache, cc, c++, gcc, g++, clang, clang++ and rustc somewhere in a folder that is at the front of the $PATH.

Then one can just use it transparently. (If one doesn’t use rustup, but instead uses the rustc and cargo that comes with the distribution, it can even work without exporting RUSTC_WRAPPER.)

After a little investigation, this is because Rust is trying to call sccache cc main.c, and since the symlink was setup, when the command gets to sccache it has become sccache sccache main.c, something that sccache doesn’t seem to accept.