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

Support caching MSVC compiles with -showIncludes #47

Closed
luser opened this issue Dec 13, 2016 · 4 comments
Closed

Support caching MSVC compiles with -showIncludes #47

luser opened this issue Dec 13, 2016 · 4 comments

Comments

@luser
Copy link
Contributor

luser commented Dec 13, 2016

We currently treat -showIncludes as a non-cacheable MSVC option. I ported this directly from the Python implementation. Unfortunately a lot of build tools use this to produce dependency info, and it may not be possible to work around that. @alexcrichton ran into this trying to get sccache working for the LLVM build in Rust.

I suspect the issue here is that the output from -showIncludes is generated when we run the preprocessor, but we cache the output of running the compiler on the already-preprocessed output. It might be a little weird, but I think we could save all the extra output lines and just prepend them to the compiler output if the original command included -showIncludes.

@glandium, is there anything I'm missing there?

@fxb
Copy link
Contributor

fxb commented Jan 16, 2017

Using CMake with the Ninja generator will add /showIncludes to all compiler invocations it seems, making it impossible to use with sccache at the moment.

@luser
Copy link
Contributor Author

luser commented Jan 17, 2017

Right, that was the original motivation for this bug. Rust builds LLVM using CMake, so their compilations include /showIncludes.

@fxb
Copy link
Contributor

fxb commented Jan 20, 2017

It seems like a common way other compiler caches work, is to always add /showIncludes to the compiler command line, effectively including it in the cache key (instead of preprocessing). Obviously this will likely break shared caching, unless paths are the same on all machines.

I guess a straight forward fix, as you said, would just be to strip printed includes from the preprocessor output for caching purposes, and then prepend them to the output again. Just to clarify we are on the same page. I'd be happy to help working on a fix for this issue.

@luser
Copy link
Contributor Author

luser commented Jan 20, 2017

Obviously this will likely break shared caching, unless paths are the same on all machines.

This is already an issue with sccache, #35 covers fixing it.

I guess a straight forward fix, as you said, would just be to strip printed includes from the preprocessor output for caching purposes, and then prepend them to the output again. Just to clarify we are on the same page. I'd be happy to help working on a fix for this issue.

Yeah, that should work fine. sccache caches the compiler output, and -showIncludes is part of the preprocessor output. We always invoke the preprocessor, so we can always get the proper local -showIncludes output. If you'd like to work on this feel free! Most of the work should be contained to msvc.rs, but we'd have to create some way to save the bits from the preprocessor output to return with the compiler output.

We could implement this one of two ways--either always save the -showIncludes lines from running the preprocessor, and then include them along with the locally-produced or cached compiler output, or cache them as if they were part of the compiler output. The former sounds slightly simpler, since we'd have to handle both the locally-compiled and cached cases separately for the latter.

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