[PATCH] D78392: [CUDA] Define __CUDACC__ before standard library headers

Raul Tambre via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 12:26:10 PDT 2020


tambre created this revision.
tambre added a reviewer: tra.
Herald added subscribers: cfe-commits, yaxunl.
Herald added a project: clang.
tambre edited the summary of this revision.
tambre edited the summary of this revision.
tra added inline comments.


================
Comment at: clang/lib/Headers/__clang_cuda_runtime_wrapper.h:44
 #include <stdlib.h>
 
 // Preserve common macros that will be changed below by us or by CUDA
----------------
We should undef __CUDACC__ here to make sure it does not affect anything else in the headers we include further down.


libstdc++ since version 7 when GNU extensions are enabled (e.g. -std=gnu++11) use it to avoid defining overloads using `__float128`.
This fixes compiling with GNU extensions failing due to `__float128` being used.

Discovered at https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4442#note_737136.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78392

Files:
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h


Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===================================================================
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -31,6 +31,11 @@
 // Include some forward declares that must come before cmath.
 #include <__clang_cuda_math_forward_declares.h>
 
+// Define __CUDACC__ early as libstdc++ standard headers with GNU extensions
+// enabled depend on it to avoid using __float128, which is unsupported in
+// CUDA.
+#define __CUDACC__
+
 // Include some standard headers to avoid CUDA headers including them
 // while some required macros (like __THROW) are in a weird state.
 #include <cmath>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78392.258391.patch
Type: text/x-patch
Size: 706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200417/6cb12d1a/attachment.bin>


More information about the cfe-commits mailing list