Skip to content
Merged
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
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