Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion src/compiler/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,11 +713,20 @@ where
};
if outputs_gcno {
let gcno = output.with_extension("gcno");
// Assembly inputs accept the coverage flags but never emit a .gcno note
// file, so it must not be a required output -- otherwise caching the
// compile aborts with "failed to zip up compiler outputs". Assembly
// became cacheable in the "Assembly language support" change, which is
// what first exposed this (see issue #2275).
let optional = matches!(
language,
Language::Assembler | Language::AssemblerToPreprocess
);
outputs.insert(
"gcno",
ArtifactDescriptor {
path: gcno,
optional: false,
optional,
},
);
profile_generate = true;
Expand Down Expand Up @@ -1513,6 +1522,44 @@ mod test {
assert!(profile_generate);
}

#[test]
fn test_parse_arguments_coverage_assembly_gcno_optional() {
// Assembly compiled with the coverage flags does not emit a .gcno note
// file, so the .gcno output must be optional for the compile to remain
// cacheable rather than aborting (see issue #2275).
let args = stringvec!["--coverage", "-c", "foo.S", "-o", "foo.o"];
let ParsedArguments {
input,
language,
outputs,
profile_generate,
..
} = match parse_arguments_(args, false) {
CompilerArguments::Ok(args) => args,
o => panic!("Got unexpected parse result: {:?}", o),
};
assert_eq!(Some("foo.S"), input.to_str());
assert_eq!(Language::AssemblerToPreprocess, language);
assert_map_contains!(
outputs,
(
"obj",
ArtifactDescriptor {
path: "foo.o".into(),
optional: false
}
),
(
"gcno",
ArtifactDescriptor {
path: PathBuf::from("foo.gcno"),
optional: true
}
)
);
assert!(profile_generate);
}

#[test]
fn test_parse_arguments_depfile_for_raw_assembly_gcc() {
let args = stringvec!["-c", "foo.s", "-o", "foo.o", "-MD", "-MF", "foo.d"];
Expand Down
Loading