Skip to content

Commit 14b9135

Browse files
gribozavrcopybara-github
authored andcommitted
[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. NOKEYCHECK=True GitOrigin-RevId: 7378fb30645ad5398491acea3960a8115d1b171c
1 parent 36856a8 commit 14b9135

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

include/__config

+17
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,23 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
12161216
# define _LIBCPP_NOINLINE
12171217
# endif
12181218

1219+
# if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
1220+
// The CUDA SDK contains an unfortunate definition for the __noinline__ macro,
1221+
// which breaks the regular __attribute__((__noinline__)) syntax. Therefore,
1222+
// when compiling for CUDA we use the non-underscored version of the noinline
1223+
// attribute.
1224+
//
1225+
// This is a temporary workaround and we still expect the CUDA SDK team to solve
1226+
// this issue properly in the SDK headers.
1227+
//
1228+
// See https://github.com/llvm/llvm-project/pull/73838 for more details.
1229+
# define _LIBCPP_NOINLINE __attribute__((noinline))
1230+
# elif __has_attribute(__noinline__)
1231+
# define _LIBCPP_NOINLINE __attribute__((__noinline__))
1232+
# else
1233+
# define _LIBCPP_NOINLINE
1234+
# endif
1235+
12191236
// We often repeat things just for handling wide characters in the library.
12201237
// When wide characters are disabled, it can be useful to have a quick way of
12211238
// disabling it without having to resort to #if-#endif, which has a larger

0 commit comments

Comments
 (0)