Skip to content

Commit

Permalink
Allow opt-out the -ccbin flag (#1085)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuarticCat authored Jun 7, 2024
1 parent 3ba2356 commit 3c29aab
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ pub struct Build {
cpp_set_stdlib: Option<Arc<str>>,
cuda: bool,
cudart: Option<Arc<str>>,
ccbin: bool,
std: Option<Arc<str>>,
target: Option<Arc<str>>,
host: Option<Arc<str>>,
Expand Down Expand Up @@ -402,6 +403,7 @@ impl Build {
cpp_set_stdlib: None,
cuda: false,
cudart: None,
ccbin: true,
std: None,
target: None,
host: None,
Expand Down Expand Up @@ -850,6 +852,18 @@ impl Build {
self
}

/// Set CUDA host compiler.
///
/// By default, a `-ccbin` flag will be passed to NVCC to specify the
/// underlying host compiler. The value of `-ccbin` is the same as the
/// chosen C++ compiler. This is not always desired, because NVCC might
/// not support that compiler. In this case, you can remove the `-ccbin`
/// flag so that NVCC will choose the host compiler by itself.
pub fn ccbin(&mut self, ccbin: bool) -> &mut Build {
self.ccbin = ccbin;
self
}

/// Specify the C or C++ language standard version.
///
/// These values are common to modern versions of GCC, Clang and MSVC:
Expand Down Expand Up @@ -2915,9 +2929,11 @@ impl Build {
&self.cargo_output,
out_dir,
);
nvcc_tool
.args
.push(format!("-ccbin={}", tool.path.display()).into());
if self.ccbin {
nvcc_tool
.args
.push(format!("-ccbin={}", tool.path.display()).into());
}
nvcc_tool.family = tool.family;
nvcc_tool
} else {
Expand Down

0 comments on commit 3c29aab

Please sign in to comment.