[clang] 8e20516 - [CUDA] Define __CUDACC__ before standard library headers
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 17 12:56:39 PDT 2020
Author: Raul Tambre
Date: 2020-04-17T12:56:13-07:00
New Revision: 8e20516540444618ad32dd11e835c05804053697
URL: https://github.com/llvm/llvm-project/commit/8e20516540444618ad32dd11e835c05804053697
DIFF: https://github.com/llvm/llvm-project/commit/8e20516540444618ad32dd11e835c05804053697.diff
LOG: [CUDA] Define __CUDACC__ before standard library headers
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.
Differential Revision: https://reviews.llvm.org/D78392
Added:
Modified:
clang/lib/Headers/__clang_cuda_runtime_wrapper.h
Removed:
################################################################################
diff --git a/clang/lib/Headers/__clang_cuda_runtime_wrapper.h b/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
index 63404c9bdeb5..f43ed55de489 100644
--- a/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ b/clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -31,11 +31,17 @@
// 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>
#include <cstdlib>
#include <stdlib.h>
+#undef __CUDACC__
// Preserve common macros that will be changed below by us or by CUDA
// headers.
More information about the cfe-commits
mailing list