Skip to content

Commit ecc60ba

Browse files
committed
Refine CUDA documentation.
Original wording gives an impression that user-provided flags are prefixed with -Xcompiler, which is not the case. -Xcompiler is added only to internally generated flags.
1 parent 52a7cb7 commit ecc60ba

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/lib.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,12 @@ impl Build {
640640

641641
/// Set CUDA C++ support.
642642
///
643-
/// Enabling CUDA will pass the detected C/C++ toolchain as an argument to
644-
/// the CUDA compiler, NVCC. NVCC itself accepts some limited GNU-like args;
645-
/// any other arguments for the C/C++ toolchain will be redirected using
646-
/// "-Xcompiler" flags.
643+
/// Enabling CUDA will invoke the CUDA compiler, NVCC. While NVCC accepts
644+
/// the most common compiler flags, e.g. `-std=c++17`, some project-specific
645+
/// flags might have to be prefixed with "-Xcompiler" flag, for example as
646+
/// `.flag("-Xcompiler").flag("-fpermissive")`. See the documentation for
647+
/// `nvcc`, the CUDA compiler driver, at https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/
648+
/// for more information.
647649
///
648650
/// If enabled, this also implicitly enables C++ support.
649651
pub fn cuda(&mut self, cuda: bool) -> &mut Build {
@@ -3297,12 +3299,14 @@ impl Tool {
32973299
self.removed_args.push(flag);
32983300
}
32993301

3300-
/// Push a flag to the end of the compiler's arguments list.
3302+
/// Push an "exotic" flag to the end of the compiler's arguments list.
33013303
///
3302-
/// Currently `-Xcompiler` is inserted before the passed flag when compiling
3303-
/// CUDA sources since NVCC only accepts a limited set of GNU-like flags,
3304-
/// while the rest must be prefixed with the `-Xcompiler` flag to get passed
3305-
/// to the underlying C++ compiler.
3304+
/// Nvidia compiler accepts only the most common compiler flags like `-D`,
3305+
/// `-I`, `-c`, etc. Options meant specifically for the underlying
3306+
/// host C++ compiler have to be prefixed with '-Xcompiler`.
3307+
/// [Another possible future application for this function is passing
3308+
/// clang-specific flags to clang-cl, which otherwise accepts only
3309+
/// MSVC-specific options.]
33063310
fn push_cc_arg(&mut self, flag: OsString) {
33073311
if self.cuda {
33083312
self.args.push("-Xcompiler".into());

0 commit comments

Comments
 (0)