diff --git a/docs/Caching.md b/docs/Caching.md index 7dbb6e895..31a0f4c71 100644 --- a/docs/Caching.md +++ b/docs/Caching.md @@ -54,4 +54,4 @@ to the C/C++ compiler one, but with additional elements: * The hash of the input file Note that some compiler options can disable preprocessor cache mode. As of this -writing, only `-Xpreprocessor` does. +writing, only `-Xpreprocessor` and `-Wp,*` do. diff --git a/docs/Local.md b/docs/Local.md index 3f9d02b80..d8fb381a6 100644 --- a/docs/Local.md +++ b/docs/Local.md @@ -20,7 +20,7 @@ Preprocessor cache mode will be disabled if any of the following holds: - the configuration setting `use_preprocessor_cache_mode` is false - a modification time of one of the include files is too new (needed to avoid a race condition) -- a compiler option not supported by the preprocessor cache mode is used. Currently, this is only `-Xpreprocessor`, but if/when sccache grows to handle options like `-Wp,X`, then more could be added to this list. +- a compiler option not supported by the preprocessor cache mode is used. Currently, this is only `-Xpreprocessor` and `-Wp,*`, but if/when sccache grows to handle options then more could be added to this list. - the string `__TIME__` is present in the source code Configuration options and their default values: diff --git a/src/compiler/gcc.rs b/src/compiler/gcc.rs index 1566371d5..e422d8735 100644 --- a/src/compiler/gcc.rs +++ b/src/compiler/gcc.rs @@ -182,6 +182,7 @@ counted_array!(pub static ARGS: [ArgInfo; _] = [ take_arg!("-U", OsString, CanBeSeparated, PassThrough), take_arg!("-V", OsString, Separated, PassThrough), flag!("-Werror=pedantic", PedanticFlag), + take_arg!("-Wp", OsString, Concatenated(','), PreprocessorArgument), flag!("-Wpedantic", PedanticFlag), take_arg!("-Xassembler", OsString, Separated, PassThrough), take_arg!("-Xlinker", OsString, Separated, PassThrough), @@ -422,9 +423,16 @@ where extra_hash_files.push(cwd.join(path)); &mut common_args } - Some(PreprocessorArgumentFlag) - | Some(PreprocessorArgument(_)) - | Some(PreprocessorArgumentPath(_)) => &mut preprocessor_args, + Some(PreprocessorArgument(_)) => { + too_hard_for_preprocessor_cache_mode = match arg.flag_str() { + Some(s) => s == "-Xpreprocessor" || s == "-Wp", + _ => false, + }; + &mut preprocessor_args + } + Some(PreprocessorArgumentFlag) | Some(PreprocessorArgumentPath(_)) => { + &mut preprocessor_args + } Some(DepArgumentPath(_)) | Some(NeedDepTarget) => &mut dependency_args, Some(DoCompilation) | Some(Language(_)) | Some(Output(_)) | Some(XClang(_)) | Some(DepTarget(_)) => continue, @@ -436,11 +444,6 @@ where }, }; - too_hard_for_preprocessor_cache_mode = match arg.flag_str() { - Some(s) => s == "-Xpreprocessor", - _ => false, - }; - // Normalize attributes such as "-I foo", "-D FOO=bar", as // "-Ifoo", "-DFOO=bar", etc. and "-includefoo", "idirafterbar" as // "-include foo", "-idirafter bar", etc. @@ -2054,5 +2057,12 @@ mod test { o => panic!("Got unexpected parse result: {:?}", o), }; assert!(parsed_args.too_hard_for_preprocessor_cache_mode); + + let args = stringvec!["-c", "foo.c", "-o", "foo.o", r#"-Wp,-DFOO="something""#]; + let parsed_args = match parse_arguments_(args, false) { + CompilerArguments::Ok(args) => args, + o => panic!("Got unexpected parse result: {:?}", o), + }; + assert!(parsed_args.too_hard_for_preprocessor_cache_mode); } }