-
Notifications
You must be signed in to change notification settings - Fork 558
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
Changes for sccache+msvc+LLVM #78
Conversation
6bb8785
to
b61570d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked as much as I understood.
src/compiler/clang.rs
Outdated
let ParsedArguments { | ||
input, | ||
extension, | ||
depfile: _depfile, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can write _
instead of _depfile
.
https://is.gd/7nHDiH
src/compiler/clang.rs
Outdated
} | ||
o @ _ => assert!(false, format!("Got unexpected parse result: {:?}", o)), | ||
} | ||
let args = stringvec!["-c", "foo.cxx", "-arch", "xyz", "-fabc","-I", "include", "-o", "foo.o", "-include", "file"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after `"-afbc".
src/compiler/clang.rs
Outdated
let ParsedArguments { | ||
input, | ||
extension, | ||
depfile: _depfile, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as I suggested above.
src/compiler/gcc.rs
Outdated
let ParsedArguments { | ||
input, | ||
extension, | ||
depfile: _depfile, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as I suggested above.
src/compiler/msvc.rs
Outdated
@@ -108,56 +109,58 @@ pub fn parse_arguments(arguments: &[String]) -> CompilerArguments { | |||
let mut debug_info = false; | |||
let mut pdb = None; | |||
let mut depfile = None; | |||
let mut show_includes = false; | |||
|
|||
//TODO: support arguments that start with / as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the comment is no longer needed.
src/compiler/msvc.rs
Outdated
v @ _ if v.starts_with("-deps") => { | ||
depfile = Some(v[5..].to_owned()); | ||
} | ||
// Arguments we can't handle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should be placed below because we will be able to handle "-showIncludes"
.
b61570d
to
17da12f
Compare
I've built a local copy with mozilla/sccache#79 and mozilla/sccache#78. Let's see if that helps rust-lang#40240!
travis: Update sccache binary I've built a local copy with mozilla/sccache#79 and mozilla/sccache#78. Let's see if that helps #40240!
travis: Update sccache binary I've built a local copy with mozilla/sccache#79 and mozilla/sccache#78. Let's see if that helps #40240!
e927bc8
to
4020e89
Compare
src/compiler/msvc.rs
Outdated
let mut it = arguments.iter(); | ||
let mut it = arguments.iter().map(|i| { | ||
if i.starts_with("/") { | ||
format!("-{}", &i[1..]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a clever hack!
debug_info = true; | ||
common_args.push(arg.clone()); | ||
} | ||
v if v.starts_with("-Fd") => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking it might be nice to refactor some of the other compiler argument parsing code to use the ArgsIter
pattern I implemented for Rust:
Line 366 in 7ae4c25
let it = ArgsIter::new(arguments, &args_with_val); |
It's probably not as useful here, but it was nice to be able to write all the match arms as strings instead of having v.starts_with(...)
all over the place.
@@ -77,7 +79,7 @@ struct CCompilation<I: CCompilerImpl> { | |||
parsed_args: ParsedArguments, | |||
executable: String, | |||
/// The output from running the preprocessor. | |||
preprocessor_output: Vec<u8>, | |||
preprocessor_result: process::Output, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change ought to make it easier to fix #72 as well!
src/compiler/clang.rs
Outdated
msvc_show_includes, | ||
common_args, | ||
} = match _parse_arguments(&args) { | ||
CompilerArguments::Ok(args) => args, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a much more sensible way to write this.
src/compiler/msvc.rs
Outdated
} | ||
Box::new(ret.map(|(cacheable, mut output)| { | ||
let prev = mem::replace(&mut output.stderr, extra_stderr); | ||
output.stderr.extend(prev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is actually correct, and this is probably what breaks the configure test in the Firefox build. See my comment in detect_showincludes_prefix
:
Line 104 in 7ae4c25
// The MSDN docs say the -showIncludes output goes to stderr, |
I just did a simple local test with MSVC2015 and the -showIncludes
output goes to stdout when compiling:
ted@DESKTOP-32V9ND8 /c/build
$ cl -Fonul -nologo -showIncludes -c test.c > /tmp/cl.stdout 2>/tmp/cl.stderr
ted@DESKTOP-32V9ND8 /c/build
$ cat /tmp/cl.stdout
test.c
Note: including file: C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt\stdio.h
Note: including file: C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt\corecrt.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vcruntime.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\sal.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\ConcurrencySal.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\vadefs.h
Note: including file: C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt\corecrt_wstdio.h
Note: including file: C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt\corecrt_stdio_config.h
When running the preprocessor it definitely goes to stderr.
Unfortunately I think this means we'll have to do something slightly more complex here, like parse the preprocessor stderr to get just the showIncludes lines, and then put just those in the compiler stdout.
Thanks for the review! It'll take a bit I think to get time to cover the comments, but I'll dig in as soon as I get a chance. |
According to https://msdn.microsoft.com/en-us/library/hdkef6tk.aspx
This seems empirically false... |
Helps avoid some extra indentation
Just do a simple translation from `/foo` to `-foo`
Track the `-showIncludes` flag being passed down to the compilation itself, and then also be sure to thread the entire output of the preprocessor down to compilations instead of just stdout. Once that was done support was implemented by simply prepending the preprocessor stderr to the compiler stderr if the `-showIncludes` flag was passed.
4020e89
to
8660519
Compare
// means that the "show includes" business when to stderr. Normally, though, | ||
// the compiler emits `-showIncludes` output to stdout. To handle that we | ||
// take the stderr of the preprocessor and prepend it to the stdout of the | ||
// compilation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think at some point we'll want to do something like this for all compilers to fix #72, but we'll probably have to put the warnings on stderr for compatibility.
Oh sorry I pushed an update but then confused myself as to how it could work at all! I'm not actually sure how this patch works but maybe I'm missing something? We recreate |
Oh so it turns out my |
Ok, I've sent a PR which I believe fixes the issue: #106 |
Sorry for the runaround! |
CI: publish sccache dist
This few commits were what I found was necessary to get sccache fully working on MSVC when compiling LLVM in rust-lang/rust. It basically boiled down to:
Fixes #61
Fixes #47