Skip to content

Commit

Permalink
Use a full path relative to cwd for extra hash files
Browse files Browse the repository at this point in the history
When the current directory of the sccache process is not the same as
the current directory for the compiler process, extra hash files are
currently not found, leading to errors.

Fixes #843
  • Loading branch information
glandium committed Dec 16, 2020
1 parent 200c0c7 commit a458fa7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
17 changes: 13 additions & 4 deletions src/compiler/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ mod test {
Clang {
clangplusplus: false,
}
.parse_arguments(&arguments, ".".as_ref())
.parse_arguments(&arguments, &std::env::current_dir().unwrap())
}

macro_rules! parses {
Expand Down Expand Up @@ -246,7 +246,10 @@ mod test {
ovec!["-Xclang", "-load", "-Xclang", "plugin.so"],
a.common_args
);
assert_eq!(ovec!["plugin.so"], a.extra_hash_files);
assert_eq!(
ovec![std::env::current_dir().unwrap().join("plugin.so")],
a.extra_hash_files
);
}

#[test]
Expand Down Expand Up @@ -367,7 +370,10 @@ mod test {
let a = parses!("-c", "foo.c", "-o", "foo.o", "-fplugin", "plugin.so");
println!("A {:#?}", a);
assert_eq!(ovec!["-fplugin", "plugin.so"], a.common_args);
assert_eq!(ovec!["plugin.so"], a.extra_hash_files);
assert_eq!(
ovec![std::env::current_dir().unwrap().join("plugin.so")],
a.extra_hash_files
);
}

#[test]
Expand All @@ -380,7 +386,10 @@ mod test {
"-fsanitize-blacklist=list.txt"
);
assert_eq!(ovec!["-fsanitize-blacklist=list.txt"], a.common_args);
assert_eq!(ovec!["list.txt"], a.extra_hash_files);
assert_eq!(
ovec![std::env::current_dir().unwrap().join("list.txt")],
a.extra_hash_files
);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ where
| Some(PassThrough(_))
| Some(PassThroughPath(_)) => &mut common_args,
Some(ExtraHashFile(path)) => {
extra_hash_files.push(path.clone());
extra_hash_files.push(cwd.join(path));
&mut common_args
}
Some(PreprocessorArgumentFlag)
Expand Down Expand Up @@ -401,7 +401,7 @@ where
| Some(PassThrough(_))
| Some(PassThroughPath(_)) => &mut common_args,
Some(ExtraHashFile(path)) => {
extra_hash_files.push(path.clone());
extra_hash_files.push(cwd.join(path));
&mut common_args
}
Some(PreprocessorArgumentFlag)
Expand Down
12 changes: 7 additions & 5 deletions src/compiler/msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ pub fn parse_arguments(
.iter_os_strings(),
),
Some(ExtraHashFile(path)) => {
extra_hash_files.push(path.clone());
extra_hash_files.push(cwd.join(path));
common_args.extend(
arg.normalize(NormalizedDisposition::Concatenated)
.iter_os_strings(),
Expand Down Expand Up @@ -584,7 +584,7 @@ pub fn parse_arguments(
&mut common_args
}
Some(ExtraHashFile(path)) => {
extra_hash_files.push(path.clone());
extra_hash_files.push(cwd.join(path));
&mut common_args
}
Some(PreprocessorArgumentFlag)
Expand Down Expand Up @@ -895,14 +895,13 @@ fn generate_compile_commands(
mod test {
use super::*;
use crate::compiler::*;
use crate::env;
use crate::mock_command::*;
use crate::test::utils::*;
use futures::Future;
use futures_03::executor::ThreadPool;

fn parse_arguments(arguments: Vec<OsString>) -> CompilerArguments<ParsedArguments> {
super::parse_arguments(&arguments, &env::current_dir().unwrap(), false)
super::parse_arguments(&arguments, &std::env::current_dir().unwrap(), false)
}

#[test]
Expand Down Expand Up @@ -1386,6 +1385,9 @@ mod test {
o => panic!("Got unexpected parse result: {:?}", o),
};
assert_eq!(ovec!["-fsanitize-blacklist=list.txt"], common_args);
assert_eq!(ovec!["list.txt"], extra_hash_files);
assert_eq!(
ovec![std::env::current_dir().unwrap().join("list.txt")],
extra_hash_files
);
}
}

0 comments on commit a458fa7

Please sign in to comment.