willcrichton / flowistry

Flowistry is an IDE plugin for Rust that helps you focus on relevant code.
https://marketplace.visualstudio.com/items?itemName=wcrichton.flowistry
MIT License
1.88k stars 44 forks source link

sccache causes flowistry-driver to fail #18

Open domenukk opened 3 years ago

domenukk commented 3 years ago

When trying to use flowistry for the first time, I get this error message:

Flowistry could not run because your project failed to build with error:
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `sccache /Users/domenukk/.cargo/bin/flowistry-driver rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit status: 2)
  --- stderr
  sccache: error: failed to execute compile
  sccache: caused by: Compiler not supported: "error: expected one of `!` or `[`, found keyword `if`\n --> /var/folders/9b/2lxhyc8567g980pxjn_t3qy40000gn/T/sccachewzZPue/testfile.c:1:2\n  |\n1 | #if defined(__NVCC__)\n  |  ^^ expected one of `!` or `[`\n\nerror: aborting due to previous error\n\n"

Could this be realted to sccache somehow? I'll try without next, but in any case it would be good to find another solution.

willcrichton commented 3 years ago

Thanks for the bug report @domenukk! It's almost certainly related to sccache. I've never tested with it. I'm not 100% sure if it it's even possible to integrate with sccache, because Flowistry uses a similar mechanism (RUSTC_WORKSPACE_WRAPPER) to integrate with rustc.

I noticed that Clippy also has an open issue on integrating with sccache: https://github.com/rust-lang/rust-clippy/issues/3840

I'll play with this, but I wouldn't expect a fix unless Cargo gets patched to support this. Sorry!

wangyingsm commented 2 years ago

I encountered same problem.

cauebs commented 2 years ago

But isn't there a way to bypass sccache and call rustc directly? I'd like to use Flowistry without having to lose the setting that enables sccache system-wide.

bjorn3 commented 2 years ago

Had the same problem with cg_clif: https://github.com/bjorn3/rustc_codegen_cranelift/issues/1091 The problem is indeed sccache. It detects whether it wraps rustc or a C compiler based on the executable name. This means that only "rustc" will be considered a rust compiler accepting the same arguments as rustc. If the executable is named anything different it will assume that is is gcc or clang and attempt to compile some C code using it to detect which C compiler is is exactly. I opened an issue about this a long time ago: https://github.com/mozilla/sccache/issues/861 On cg_clif's side I worked around it by checking if RUSTC_WRAPPER is set to sccache and unsetting it if this is the case.