[clang] a50e54f - [CUDA] Temporarily undefine __noinline__ when including bits/shared_ptr_base.h

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Mon May 1 16:27:48 PDT 2023


Author: Artem Belevich
Date: 2023-05-01T16:27:13-07:00
New Revision: a50e54fbeb48fb8a218a2914d827e1087bae2f8d

URL: https://github.com/llvm/llvm-project/commit/a50e54fbeb48fb8a218a2914d827e1087bae2f8d
DIFF: https://github.com/llvm/llvm-project/commit/a50e54fbeb48fb8a218a2914d827e1087bae2f8d.diff

LOG: [CUDA] Temporarily undefine __noinline__ when including bits/shared_ptr_base.h

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

Added: 
    clang/lib/Headers/cuda_wrappers/bits/shared_ptr_base.h

Modified: 
    clang/lib/Headers/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index 7c2f323652bb5..f8d6862bb6584 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -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
index 0000000000000..10028dd7bd9a0
--- /dev/null
+++ b/clang/lib/Headers/cuda_wrappers/bits/shared_ptr_base.h
@@ -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__")


        


More information about the cfe-commits mailing list