Skip to content

Commit 3c29aab

Browse files
authored
Allow opt-out the -ccbin flag (#1085)
1 parent 3ba2356 commit 3c29aab

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/lib.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ pub struct Build {
277277
cpp_set_stdlib: Option<Arc<str>>,
278278
cuda: bool,
279279
cudart: Option<Arc<str>>,
280+
ccbin: bool,
280281
std: Option<Arc<str>>,
281282
target: Option<Arc<str>>,
282283
host: Option<Arc<str>>,
@@ -402,6 +403,7 @@ impl Build {
402403
cpp_set_stdlib: None,
403404
cuda: false,
404405
cudart: None,
406+
ccbin: true,
405407
std: None,
406408
target: None,
407409
host: None,
@@ -850,6 +852,18 @@ impl Build {
850852
self
851853
}
852854

855+
/// Set CUDA host compiler.
856+
///
857+
/// By default, a `-ccbin` flag will be passed to NVCC to specify the
858+
/// underlying host compiler. The value of `-ccbin` is the same as the
859+
/// chosen C++ compiler. This is not always desired, because NVCC might
860+
/// not support that compiler. In this case, you can remove the `-ccbin`
861+
/// flag so that NVCC will choose the host compiler by itself.
862+
pub fn ccbin(&mut self, ccbin: bool) -> &mut Build {
863+
self.ccbin = ccbin;
864+
self
865+
}
866+
853867
/// Specify the C or C++ language standard version.
854868
///
855869
/// These values are common to modern versions of GCC, Clang and MSVC:
@@ -2915,9 +2929,11 @@ impl Build {
29152929
&self.cargo_output,
29162930
out_dir,
29172931
);
2918-
nvcc_tool
2919-
.args
2920-
.push(format!("-ccbin={}", tool.path.display()).into());
2932+
if self.ccbin {
2933+
nvcc_tool
2934+
.args
2935+
.push(format!("-ccbin={}", tool.path.display()).into());
2936+
}
29212937
nvcc_tool.family = tool.family;
29222938
nvcc_tool
29232939
} else {

0 commit comments

Comments
 (0)