[libcxx-commits] [libcxx] 7378fb3 - [libc++] Protect the libc++ implementation from CUDA SDK's __noinline__ macro (#73838)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 22 10:12:09 PST 2024
Author: Dmitri Gribenko
Date: 2024-01-22T13:12:05-05:00
New Revision: 7378fb30645ad5398491acea3960a8115d1b171c
URL: https://github.com/llvm/llvm-project/commit/7378fb30645ad5398491acea3960a8115d1b171c
DIFF: https://github.com/llvm/llvm-project/commit/7378fb30645ad5398491acea3960a8115d1b171c.diff
LOG: [libc++] Protect the libc++ implementation from CUDA SDK's __noinline__ macro (#73838)
The CUDA SDK contains an unfortunate definition for the `__noinline__`
macro. This patch works around it by using `__attribute__((noinline))`
instead of `__attribute__((__noinline__))` on CUDA. We are still waiting
for a long-term resolution to this issue in NVIDIA/cccl#1235.
Added:
Modified:
libcxx/include/__config
Removed:
################################################################################
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 33a79b9a79f62fe..9a64cdb489119d9 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1216,6 +1216,23 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
# define _LIBCPP_NOINLINE
# endif
+# if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
+// The CUDA SDK contains an unfortunate definition for the __noinline__ macro,
+// which breaks the regular __attribute__((__noinline__)) syntax. Therefore,
+// when compiling for CUDA we use the non-underscored version of the noinline
+// attribute.
+//
+// This is a temporary workaround and we still expect the CUDA SDK team to solve
+// this issue properly in the SDK headers.
+//
+// See https://github.com/llvm/llvm-project/pull/73838 for more details.
+# define _LIBCPP_NOINLINE __attribute__((noinline))
+# elif __has_attribute(__noinline__)
+# define _LIBCPP_NOINLINE __attribute__((__noinline__))
+# else
+# define _LIBCPP_NOINLINE
+# endif
+
// We often repeat things just for handling wide characters in the library.
// When wide characters are disabled, it can be useful to have a quick way of
// disabling it without having to resort to #if-#endif, which has a larger
More information about the libcxx-commits
mailing list