[CUDA] Temporarily undefine __noinline__ when including bits/shared_ptr_base.h
authorArtem Belevich <tra@google.com>
Thu, 27 Apr 2023 18:10:37 +0000 (11:10 -0700)
committerArtem Belevich <tra@google.com>
Mon, 1 May 2023 23:27:13 +0000 (16:27 -0700)
This avoid CUDA compilation errors caused by CUDA headers defining __noinline__
and conflicting with __noinline__ use in libstdc++.

Differential Revision: https://reviews.llvm.org/D149364

clang/lib/Headers/CMakeLists.txt
clang/lib/Headers/cuda_wrappers/bits/shared_ptr_base.h [new file with mode: 0644]

index 7c2f323..f8d6862 100644 (file)
@@ -262,6 +262,7 @@ set(cuda_wrapper_files
   cuda_wrappers/cmath
   cuda_wrappers/complex
   cuda_wrappers/new
+  cuda_wrappers/bits/shared_ptr_base.h
 )
 
 set(ppc_wrapper_files
diff --git a/clang/lib/Headers/cuda_wrappers/bits/shared_ptr_base.h b/clang/lib/Headers/cuda_wrappers/bits/shared_ptr_base.h
new file mode 100644 (file)
index 0000000..10028dd
--- /dev/null
@@ -0,0 +1,9 @@
+// CUDA headers define __noinline__ which interferes with libstdc++'s use of
+// `__attribute((__noinline__))`. In order to avoid compilation error,
+// temporarily unset __noinline__ when we include affected libstdc++ header.
+
+#pragma push_macro("__noinline__")
+#undef __noinline__
+#include_next "bits/shared_ptr_base.h"
+
+#pragma pop_macro("__noinline__")