diff --git a/src/compiler/gcc.rs b/src/compiler/gcc.rs index bb8ce3a3f..b366eff6c 100644 --- a/src/compiler/gcc.rs +++ b/src/compiler/gcc.rs @@ -290,7 +290,6 @@ where let mut language_extensions = true; // by default, GCC allows extensions let mut split_dwarf = false; let mut need_explicit_dep_target = false; - let mut dep_path = None; enum DepArgumentRequirePath { NotNeeded, Missing, @@ -382,9 +381,8 @@ where dep_flag = OsString::from(arg.flag_str().expect("Dep target flag expected")); dep_target = Some(s.clone()); } - Some(DepArgumentPath(path)) => { + Some(DepArgumentPath(_)) => { need_explicit_dep_argument_path = DepArgumentRequirePath::Provided; - dep_path = Some(path.clone()); } Some(SerializeDiagnostics(path)) => { serialize_diagnostics = Some(path.clone()); @@ -644,16 +642,6 @@ where dependency_args.push(Path::new(&output).with_extension("d").into_os_string()); } - if let Some(path) = dep_path { - outputs.insert( - "d", - ArtifactDescriptor { - path: path.clone(), - optional: false, - }, - ); - } - if let Some(path) = serialize_diagnostics { outputs.insert( "dia", @@ -1464,13 +1452,6 @@ mod test { path: "foo.o".into(), optional: false } - ), - ( - "d", - ArtifactDescriptor { - path: "foo.o.d".into(), - optional: false - } ) ); assert_eq!(ovec!["-MF", "foo.o.d"], dependency_args); @@ -1564,13 +1545,6 @@ mod test { path: "foo.o".into(), optional: false } - ), - ( - "d", - ArtifactDescriptor { - path: "foo.o.d".into(), - optional: false - } ) ); assert_eq!(ovec!["-MF", "foo.o.d"], dependency_args); @@ -1606,13 +1580,6 @@ mod test { path: "foo.o".into(), optional: false } - ), - ( - "d", - ArtifactDescriptor { - path: "foo.o.d".into(), - optional: false - } ) ); assert_eq!( @@ -1652,13 +1619,6 @@ mod test { path: "foo.o".into(), optional: false } - ), - ( - "d", - ArtifactDescriptor { - path: "foo.o.d".into(), - optional: false - } ) ); assert_eq!( @@ -1899,13 +1859,6 @@ mod test { path: "foo.o".into(), optional: false } - ), - ( - "d", - ArtifactDescriptor { - path: "foo.o.d".into(), - optional: false - } ) ); assert_eq!( diff --git a/src/compiler/nvcc.rs b/src/compiler/nvcc.rs index bc24d0e59..a409b2135 100644 --- a/src/compiler/nvcc.rs +++ b/src/compiler/nvcc.rs @@ -1783,13 +1783,6 @@ mod test { path: "foo.o".into(), optional: false } - ), - ( - "d", - ArtifactDescriptor { - path: "foo.o.d".into(), - optional: false - } ) ); assert_eq!( diff --git a/src/compiler/nvhpc.rs b/src/compiler/nvhpc.rs index 507e5d1a3..0eb2c924a 100644 --- a/src/compiler/nvhpc.rs +++ b/src/compiler/nvhpc.rs @@ -352,13 +352,6 @@ mod test { path: "foo.o".into(), optional: false } - ), - ( - "d", - ArtifactDescriptor { - path: "foo.o.d".into(), - optional: false - } ) ); assert_eq!( diff --git a/tests/system.rs b/tests/system.rs index 78baf8a4a..f94273922 100644 --- a/tests/system.rs +++ b/tests/system.rs @@ -573,6 +573,56 @@ fn test_compile_with_define(compiler: Compiler, tempdir: &Path) { .stderr(predicates::str::contains("warning:").from_utf8().not()); } +fn test_gcc_clang_depfile(compiler: Compiler, tempdir: &Path) { + let Compiler { + name, + exe, + env_vars, + } = compiler; + println!("test_gcc_clang_depfile: {}", name); + copy_to_tempdir(&[INPUT], tempdir); + fs::copy(tempdir.join(INPUT), tempdir.join("same-content.c")).unwrap(); + + trace!("compile"); + sccache_command() + .args(compile_cmdline( + name, + exe.clone(), + INPUT, + OUTPUT, + Vec::new(), + )) + .args(vec_from!(OsString, "-MD", "-MF", "first.d")) + .current_dir(tempdir) + .envs(env_vars.clone()) + .assert() + .success(); + sccache_command() + .args(compile_cmdline( + name, + exe, + "same-content.c", + "same-content.o", + Vec::new(), + )) + .args(vec_from!(OsString, "-MD", "-MF", "second.d")) + .current_dir(tempdir) + .envs(env_vars) + .assert() + .success(); + let mut first = String::new(); + let mut second = String::new(); + File::open(tempdir.join("first.d")) + .unwrap() + .read_to_string(&mut first) + .unwrap(); + File::open(tempdir.join("second.d")) + .unwrap() + .read_to_string(&mut second) + .unwrap(); + assert_ne!(first, second); +} + fn run_sccache_command_tests(compiler: Compiler, tempdir: &Path, preprocessor_cache_mode: bool) { if compiler.name != "clang++" { test_basic_compile(compiler.clone(), tempdir); @@ -589,6 +639,7 @@ fn run_sccache_command_tests(compiler: Compiler, tempdir: &Path, preprocessor_ca if compiler.name == "clang" || compiler.name == "gcc" { test_gcc_clang_no_warnings_from_macro_expansion(compiler.clone(), tempdir); test_split_dwarf_object_generate_output_dir_changes(compiler.clone(), tempdir); + test_gcc_clang_depfile(compiler.clone(), tempdir); } if compiler.name == "clang++" { test_clang_multicall(compiler.clone(), tempdir);