Skip to content

Commit

Permalink
[libc++] Protect the libc++ implementation from CUDA SDK's __noinline…
Browse files Browse the repository at this point in the history
…__ 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.
  • Loading branch information
gribozavr authored Jan 22, 2024
1 parent e390bda commit 7378fb3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7378fb3

Please sign in to comment.