Skip to content

Use consistent names for internal nvcc files #2383

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
45 changes: 43 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ opendal = { version = "0.52.0", optional = true, default-features = false }
openssl = { version = "0.10.72", optional = true }
rand = "0.8.4"
regex = "1.10.3"
regex_static = "0.1.1"
reqsign = { version = "0.16.0", optional = true }
reqwest = { version = "0.12", features = [
"json",
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ pub trait CCompilerImpl: Clone + fmt::Debug + Send + Sync + 'static {
T: CommandCreatorSync;
/// Generate a command that can be used to invoke the C compiler to perform
/// the compilation.
#[allow(clippy::too_many_arguments)]
fn generate_compile_commands<T>(
&self,
path_transformer: &mut dist::PathTransformer,
Expand All @@ -208,6 +209,7 @@ pub trait CCompilerImpl: Clone + fmt::Debug + Send + Sync + 'static {
cwd: &Path,
env_vars: &[(OsString, OsString)],
rewrite_includes_only: bool,
hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand Down Expand Up @@ -1157,6 +1159,7 @@ impl<T: CommandCreatorSync, I: CCompilerImpl> Compilation<T> for CCompilation<I>
&self,
path_transformer: &mut dist::PathTransformer,
rewrite_includes_only: bool,
hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand All @@ -1178,6 +1181,7 @@ impl<T: CommandCreatorSync, I: CCompilerImpl> Compilation<T> for CCompilation<I>
cwd,
env_vars,
rewrite_includes_only,
hash_key,
)
}

Expand Down
75 changes: 31 additions & 44 deletions src/compiler/cicc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl CCompilerImpl for Cicc {
cwd: &Path,
env_vars: &[(OsString, OsString)],
_rewrite_includes_only: bool,
_hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand Down Expand Up @@ -118,7 +119,6 @@ where
let mut take_next = false;
let mut outputs = HashMap::new();
let mut extra_dist_files = vec![];
let mut gen_module_id_file = false;
let mut module_id_file_name = Option::<PathBuf>::None;

let mut common_args = vec![];
Expand All @@ -128,6 +128,20 @@ where
match arg {
Ok(arg) => {
let args = match arg.get_data() {
Some(ExtraOutput(o)) => {
take_next = false;
let path = cwd.join(o);
if let Some(flag) = arg.flag_str() {
outputs.insert(
flag,
ArtifactDescriptor {
path,
optional: false,
},
);
}
&mut common_args
}
Some(PassThrough(_)) => {
take_next = false;
&mut common_args
Expand All @@ -146,7 +160,6 @@ where
}
Some(GenModuleIdFileFlag) => {
take_next = false;
gen_module_id_file = true;
&mut common_args
}
Some(ModuleIdFileName(o)) => {
Expand All @@ -158,24 +171,6 @@ where
take_next = false;
&mut unhashed_args
}
Some(UnhashedOutput(o)) => {
take_next = false;
let path = cwd.join(o);
if let Some(flag) = arg.flag_str() {
outputs.insert(
flag,
ArtifactDescriptor {
path,
optional: false,
},
);
}
&mut unhashed_args
}
Some(UnhashedFlag) => {
take_next = false;
&mut unhashed_args
}
None => match arg {
Argument::Raw(ref p) => {
if take_next {
Expand All @@ -200,17 +195,16 @@ where
}

if let Some(module_id_path) = module_id_file_name {
if gen_module_id_file {
outputs.insert(
"--module_id_file_name",
ArtifactDescriptor {
path: module_id_path,
optional: true,
},
);
} else {
extra_dist_files.push(module_id_path);
if module_id_path.exists() {
extra_dist_files.push(module_id_path.clone());
}
outputs.insert(
"--module_id_file_name",
ArtifactDescriptor {
path: module_id_path,
optional: false,
},
);
}

CompilerArguments::Ok(ParsedArguments {
Expand All @@ -236,13 +230,7 @@ where
}

pub async fn preprocess(cwd: &Path, parsed_args: &ParsedArguments) -> Result<process::Output> {
// cicc and ptxas expect input to be an absolute path
let input = if parsed_args.input.is_absolute() {
parsed_args.input.clone()
} else {
cwd.join(&parsed_args.input)
};
std::fs::read(input)
std::fs::read(cwd.join(&parsed_args.input))
.map_err(anyhow::Error::new)
.map(|s| process::Output {
status: process::ExitStatus::default(),
Expand Down Expand Up @@ -329,23 +317,22 @@ pub fn generate_compile_commands(
}

ArgData! { pub
Output(PathBuf),
PassThrough(OsString),
UnhashedFlag,
ExtraOutput(PathBuf),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed this from UnhashedOutput -> ExtraOutput to reflect that these argument types are now hashed.

GenModuleIdFileFlag,
ModuleIdFileName(PathBuf),
Output(PathBuf),
PassThrough(OsString),
UnhashedPassThrough(OsString),
UnhashedOutput(PathBuf),
}

use self::ArgData::*;

counted_array!(pub static ARGS: [ArgInfo<ArgData>; _] = [
take_arg!("--gen_c_file_name", PathBuf, Separated, UnhashedOutput),
take_arg!("--gen_device_file_name", PathBuf, Separated, UnhashedOutput),
take_arg!("--gen_c_file_name", PathBuf, Separated, ExtraOutput),
take_arg!("--gen_device_file_name", PathBuf, Separated, ExtraOutput),
flag!("--gen_module_id_file", GenModuleIdFileFlag),
take_arg!("--include_file_name", OsString, Separated, PassThrough),
take_arg!("--module_id_file_name", PathBuf, Separated, ModuleIdFileName),
take_arg!("--stub_file_name", PathBuf, Separated, UnhashedOutput),
take_arg!("--stub_file_name", PathBuf, Separated, ExtraOutput),
take_arg!("-o", PathBuf, Separated, Output),
]);
1 change: 1 addition & 0 deletions src/compiler/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ impl CCompilerImpl for Clang {
cwd: &Path,
env_vars: &[(OsString, OsString)],
rewrite_includes_only: bool,
_hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand Down
10 changes: 8 additions & 2 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ where
compilation,
weak_toolchain_key,
out_pretty.clone(),
&key,
)
.await?;
let duration_compilation = start.elapsed();
Expand Down Expand Up @@ -671,6 +672,7 @@ where
}

#[cfg(not(feature = "dist-client"))]
#[allow(clippy::too_many_arguments)]
async fn dist_or_local_compile<T>(
service: &server::SccacheService<T>,
_dist_client: Option<Arc<dyn dist::Client>>,
Expand All @@ -679,13 +681,14 @@ async fn dist_or_local_compile<T>(
compilation: Box<dyn Compilation<T>>,
_weak_toolchain_key: String,
out_pretty: String,
hash_key: &str,
) -> Result<(Cacheable, DistType, process::Output)>
where
T: CommandCreatorSync,
{
let mut path_transformer = dist::PathTransformer::new();
let (compile_cmd, _dist_compile_cmd, cacheable) = compilation
.generate_compile_commands(&mut path_transformer, true)
.generate_compile_commands(&mut path_transformer, true, hash_key)
.context("Failed to generate compile commands")?;

debug!("[{}]: Compiling locally", out_pretty);
Expand All @@ -696,6 +699,7 @@ where
}

#[cfg(feature = "dist-client")]
#[allow(clippy::too_many_arguments)]
async fn dist_or_local_compile<T>(
service: &server::SccacheService<T>,
dist_client: Option<Arc<dyn dist::Client>>,
Expand All @@ -704,6 +708,7 @@ async fn dist_or_local_compile<T>(
compilation: Box<dyn Compilation<T>>,
weak_toolchain_key: String,
out_pretty: String,
hash_key: &str,
) -> Result<(Cacheable, DistType, process::Output)>
where
T: CommandCreatorSync,
Expand All @@ -716,7 +721,7 @@ where
};
let mut path_transformer = dist::PathTransformer::new();
let (compile_cmd, dist_compile_cmd, cacheable) = compilation
.generate_compile_commands(&mut path_transformer, rewrite_includes_only)
.generate_compile_commands(&mut path_transformer, rewrite_includes_only, hash_key)
.context("Failed to generate compile commands")?;

let dist_client = match dist_compile_cmd.clone().and(dist_client) {
Expand Down Expand Up @@ -921,6 +926,7 @@ where
&self,
path_transformer: &mut dist::PathTransformer,
rewrite_includes_only: bool,
hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/cudafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl CCompilerImpl for CudaFE {
cwd: &Path,
env_vars: &[(OsString, OsString)],
_rewrite_includes_only: bool,
_hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand Down Expand Up @@ -182,7 +183,7 @@ pub fn generate_compile_commands(
use cicc::ArgData::*;

counted_array!(pub static ARGS: [ArgInfo<cicc::ArgData>; _] = [
take_arg!("--gen_c_file_name", PathBuf, Separated, UnhashedOutput),
take_arg!("--gen_c_file_name", PathBuf, Separated, ExtraOutput),
flag!("--gen_module_id_file", GenModuleIdFileFlag),
take_arg!("--module_id_file_name", PathBuf, Separated, Output),
take_arg!("--stub_file_name", OsString, Separated, UnhashedPassThrough),
Expand Down
1 change: 1 addition & 0 deletions src/compiler/diab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl CCompilerImpl for Diab {
cwd: &Path,
env_vars: &[(OsString, OsString)],
_rewrite_includes_only: bool,
_hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand Down
1 change: 1 addition & 0 deletions src/compiler/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl CCompilerImpl for Gcc {
cwd: &Path,
env_vars: &[(OsString, OsString)],
rewrite_includes_only: bool,
_hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand Down
1 change: 1 addition & 0 deletions src/compiler/msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl CCompilerImpl for Msvc {
cwd: &Path,
env_vars: &[(OsString, OsString)],
_rewrite_includes_only: bool,
_hash_key: &str,
) -> Result<(
Box<dyn CompileCommand<T>>,
Option<dist::CompileCommand>,
Expand Down
Loading
Loading