[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.
This commit is contained in:
Dmitri Gribenko 2024-01-22 19:12:05 +01:00 committed by GitHub
parent e390bda978
commit 7378fb3064
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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