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

Fix cache collision with object file and precompiled headers #2268

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
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
36 changes: 36 additions & 0 deletions src/compiler/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,42 @@ mod test {
);
}

#[test]
fn test_header_differs() {
let args = ovec!["a", "b", "c"];
const PREPROCESSED: &[u8] = b"hello world";
assert_neq!(
hash_key("abcd", Language::C, &args, &[], &[], PREPROCESSED, false),
hash_key(
"abcd",
Language::CHeader,
&args,
&[],
&[],
PREPROCESSED,
false
)
);
}

#[test]
fn test_plusplus_header_differs() {
let args = ovec!["a", "b", "c"];
const PREPROCESSED: &[u8] = b"hello world";
assert_neq!(
hash_key("abcd", Language::Cxx, &args, &[], &[], PREPROCESSED, true),
hash_key(
"abcd",
Language::CxxHeader,
&args,
&[],
&[],
PREPROCESSED,
true
)
);
}

#[test]
fn test_hash_key_executable_contents_differs() {
let args = ovec!["a", "b", "c"];
Expand Down
6 changes: 4 additions & 2 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ impl Language {

pub fn as_str(self) -> &'static str {
match self {
Language::C | Language::CHeader => "c",
Language::Cxx | Language::CxxHeader => "c++",
Language::C => "c",
Language::CHeader => "cHeader",
Language::Cxx => "c++",
Language::CxxHeader => "c++Header",
Language::GenericHeader => "c/c++",
Language::ObjectiveC => "objc",
Language::ObjectiveCxx => "objc++",
Expand Down
Loading