[clang] [CUDA] work around more __noinline__ conflicts with libc++ (PR #74123)

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 1 10:41:48 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Artem Belevich (Artem-B)

<details>
<summary>Changes</summary>

https://github.com/llvm/llvm-project/pull/73838

---
Full diff: https://github.com/llvm/llvm-project/pull/74123.diff


3 Files Affected:

- (modified) clang/lib/Headers/CMakeLists.txt (+2) 
- (added) clang/lib/Headers/cuda_wrappers/__config (+10) 
- (added) clang/lib/Headers/cuda_wrappers/string (+10) 


``````````diff
diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index fdd54c05eedf825..f562c354327f2fb 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -283,10 +283,12 @@ set(files
   )
 
 set(cuda_wrapper_files
+  cuda_wrappers/__config
   cuda_wrappers/algorithm
   cuda_wrappers/cmath
   cuda_wrappers/complex
   cuda_wrappers/new
+  cuda_wrappers/string
 )
 
 set(cuda_wrapper_bits_files
diff --git a/clang/lib/Headers/cuda_wrappers/__config b/clang/lib/Headers/cuda_wrappers/__config
new file mode 100644
index 000000000000000..04038b0fa3437ee
--- /dev/null
+++ b/clang/lib/Headers/cuda_wrappers/__config
@@ -0,0 +1,10 @@
+// CUDA headers define __noinline__ which interferes with libc++'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__
+#define __noinline__ __noinline__
+#include_next "__config"
+
+#pragma pop_macro("__noinline__")
diff --git a/clang/lib/Headers/cuda_wrappers/string b/clang/lib/Headers/cuda_wrappers/string
new file mode 100644
index 000000000000000..d612710393623b5
--- /dev/null
+++ b/clang/lib/Headers/cuda_wrappers/string
@@ -0,0 +1,10 @@
+// CUDA headers define __noinline__ which interferes with libc++'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__
+#define __noinline__ __noinline__
+#include_next "string"
+
+#pragma pop_macro("__noinline__")

``````````

</details>


https://github.com/llvm/llvm-project/pull/74123


More information about the cfe-commits mailing list