[llvm-bugs] [Bug 43706] New: Compiling CUDA does not predefine macros according to doc
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Oct 17 13:04:58 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43706
Bug ID: 43706
Summary: Compiling CUDA does not predefine macros according to
doc
Product: clang
Version: 9.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: eldlistmailingz at tropicsoft.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
According to the documentation regarding clang and CUDA at
https://llvm.org/docs/CompileCudaWithLLVM.html#detecting-clang-vs-nvcc-from-code,
when compiling a CUDA file with clang, the macros __clang__, __CUDA__, and
__CUDACC__ are predefined. Yet given this source as 'clang_cuda_example.cu':
#if !defined(__clang__)
#if !defined(__CUDACC__)
#if !defined(__CUDA__)
#error The predefined macros __clang__ and __CUDACC__ and __CUDA__ are not
defined
#else
#error The predefined macros __clang__ and __CUDACC__ are not defined
#endif
#elif !defined(__CUDA__)
#error The predefined macros __clang__ and __CUDA__ are not defined
#else
#error The predefined macro __clang__ is not defined
#endif
#elif !defined(__CUDACC__)
#if !defined(__CUDA__)
#error The predefined macros __CUDACC__ and __CUDA__ are not defined
#else
#error The predefined macro __CUDACC__ is not defined
#endif
#elif !defined(__CUDA__)
#error The predefined macro __CUDA__ is not defined
#endif
int main(void) { return 0; }
If I compile this with:
clang++ -c -m64 -nocudainc -nocudalib -x cuda clang_cuda_example.cu
the output is:
"clang_cuda_example.cu:17:2: error: The predefined macro __CUDACC__ is not
defined
#error The predefined macro __CUDACC__ is not defined
^
1 error generated when compiling for sm_20."
So either the documentation regarding clang and CUDA is incorrect or there is a
bug in clang when compiling CUDA files. If something else must be present when
compiling a CUDA file so that the __CUDAACC__ macro is predefined the
documentation should specify what that is.
I realize that my test does not actually compile any CUDA code despite the
source file ending with .cu and also telling the clang compiler, through the
'-x cuda' compiler option, that I am compiling a CUDA file. I am trying to test
clang compilation of CUDA code for a change I made in the Boost preprocessor
library, of which I am the maintainer, and I need a minimum test which shows
that clang compiling a CUDA file does indeed define the predefined macros which
the documentation says it does.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191017/5ca2b4d2/attachment.html>
More information about the llvm-bugs
mailing list