Skip to content

Commit

Permalink
[CUDA] Relax restrictions on GPU-side variadic functions
Browse files Browse the repository at this point in the history
Allow parsing GPU-side variadic functions when we're compiling with CUDA-9 or
newer. We still do not allow accessing variadic arguments.

CUDA-9 was the version which introduced PTX-6.0 which allows implementing
variadic functions, so older versions can't have variadics in principle.

This is required for dealing with headers in recent CUDA versions that rely on
variadic function declarations in some of the templated code in libcu++.
E.g. #58410

Differential Revision: https://reviews.llvm.org/D150718
  • Loading branch information
Artem-B committed May 17, 2023
1 parent a07b135 commit a825f37
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clang/lib/Driver/ToolChains/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,13 @@ void CudaToolChain::addClangTargetOptions(
if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, false))
CC1Args.push_back("-fcuda-approx-transcendentals");

// Unsized function arguments used for variadics were introduced in CUDA-9.0
// We still do not support generating code that actually uses variadic
// arguments yet, but we do need to allow parsing them as recent CUDA
// headers rely on that. https://github.com/llvm/llvm-project/issues/58410
if (CudaInstallation.version() >= CudaVersion::CUDA_90)
CC1Args.push_back("-fcuda-allow-variadic-functions");
}

if (DriverArgs.hasArg(options::OPT_nogpulib))
Expand Down

0 comments on commit a825f37

Please sign in to comment.