Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-cl.exe incompatible with passing both -E and -showIncludes #246

Open
fxb opened this issue May 2, 2018 · 4 comments
Open

clang-cl.exe incompatible with passing both -E and -showIncludes #246

fxb opened this issue May 2, 2018 · 4 comments

Comments

@fxb
Copy link
Contributor

fxb commented May 2, 2018

Currently sccache is unable to cache compilations that pass -showIncludes when using clang-cl.exe.

Compilations fail with the following error:
clang-cl.exe: error: argument unused during compilation: '--show-includes' [-Werror,-Wunused-command-line-argument]

This is caused by sccache passing both -E and -showIncludes to clang-cl.exe with the expectation that -E output will be on stdout and -showIncludes output will be on stderr (See: msvc.rs#L120). However clang-cl.exe outputs both on stdout, so this combination of flags is currently not supported (See: lib/Driver/ToolChains/Clang.cpp#L5080).

  // Both /showIncludes and /E (and /EP) write to stdout. Allowing both
  // would produce interleaved output, so ignore /showIncludes in such cases.
@luser
Copy link
Contributor

luser commented May 2, 2018

That's a bummer. I guess we should just bail early with a CannotCache response when using clang-cl with -showIncludes? Note that one of my colleagues determined that you can coerce clang-cl to emit dependency files in the gcc style with the right set of options. We could certainly support handling -deps to do that for clang like we do with MSVC.

@fxb
Copy link
Contributor Author

fxb commented May 2, 2018

That would be unfortunate, since CMake / GN + Ninja builds always pass -showIncludes (See #47), so any projects using Ninja would not be cacheable at all when using clang-cl.exe as the compiler.

It seems like the only solution in this case would be to raise this issue on the LLVM bug tracker and contribute a fix to clang-cl.exe

@fxb
Copy link
Contributor Author

fxb commented May 3, 2018

I submitted a patch to clang, which makes clang-cl.exe behave the same as cl.exe in this case: https://reviews.llvm.org/D46394

spurious pushed a commit to spurious/clang-mirror that referenced this issue May 4, 2018
… /E, /EP or /P

This replicates 'cl.exe' behavior and allows for both preprocessor output and
dependency information to be extraced with a single compiler invocation.

This is especially useful for compiler caching with tools like Mozilla's sccache.

See: mozilla/sccache#246

Patch By: fxb

Differential Revision: https://reviews.llvm.org/D46394


git-svn-id: http://llvm.org/svn/llvm-project/cfe/trunk@331533 91177308-0d34-0410-b5e6-96231b3b80d8
@fxb
Copy link
Contributor Author

fxb commented May 4, 2018

My patch has now landed in clang trunk (https://reviews.llvm.org/rC331533).

jyknight pushed a commit to jyknight/llvm-monorepo that referenced this issue May 9, 2018
… /E, /EP or /P

This replicates 'cl.exe' behavior and allows for both preprocessor output and
dependency information to be extraced with a single compiler invocation.

This is especially useful for compiler caching with tools like Mozilla's sccache.

See: mozilla/sccache#246

Patch By: fxb

Differential Revision: https://reviews.llvm.org/D46394

llvm-svn=331533
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants