From 3a388b7b01512d48474b98389a3e776c8d8f817a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 20:53:56 +0000 Subject: [PATCH] Fix issues with nvrtc compilation (#3666) (#3674) * Disable use of builtin `__remove_reference_t` for nvrtc below 12.4 NVRTC does not support it properly, so remove it to unblock cuPy * Use correct warning pragma for nvrtc * Also suppress `__remove_cvref` (cherry picked from commit 7229e0bb8aeb1e49a16bad87405a655c73384361) Co-authored-by: Michael Schellenberger Costa --- cub/cub/util_cpp_dialect.cuh | 2 +- libcudacxx/include/cuda/std/__cccl/builtin.h | 8 ++++++++ libcudacxx/include/cuda/std/__internal/cpp_dialect.h | 2 +- thrust/thrust/detail/config/cpp_dialect.h | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cub/cub/util_cpp_dialect.cuh b/cub/cub/util_cpp_dialect.cuh index 6a85b971884..4a115c3f477 100644 --- a/cub/cub/util_cpp_dialect.cuh +++ b/cub/cub/util_cpp_dialect.cuh @@ -61,7 +61,7 @@ # define CUB_CPP_DIALECT _CCCL_STD_VER // Define CUB_COMPILER_DEPRECATION macro: -# if _CCCL_COMPILER(MSVC) +# if _CCCL_COMPILER(MSVC) || _CCCL_COMPILER(NVRTC) # define CUB_COMP_DEPR_IMPL(msg) _CCCL_PRAGMA(message(__FILE__ ":" _CCCL_TO_STRING(__LINE__) ": warning: " #msg)) # else // clang / gcc: # define CUB_COMP_DEPR_IMPL(msg) _CCCL_PRAGMA(GCC warning #msg) diff --git a/libcudacxx/include/cuda/std/__cccl/builtin.h b/libcudacxx/include/cuda/std/__cccl/builtin.h index 9eefb346eb0..c2ac73bf186 100644 --- a/libcudacxx/include/cuda/std/__cccl/builtin.h +++ b/libcudacxx/include/cuda/std/__cccl/builtin.h @@ -722,6 +722,10 @@ # define _CCCL_BUILTIN_REMOVE_CVREF(...) __remove_cvref(__VA_ARGS__) #endif // _CCCL_HAS_BUILTIN(__remove_cvref) +#if _CCCL_COMPILER(NVRTC, <, 12, 4) // NVRTC below 12.4 fails to properly compile that builtin +# undef _CCCL_BUILTIN_REMOVE_CVREF +#endif // _CCCL_COMPILER(NVRTC, <, 12, 4) + #if _CCCL_HAS_BUILTIN(__remove_extent) && _CCCL_CUDA_COMPILER(CLANG) # define _CCCL_BUILTIN_REMOVE_EXTENT(...) __remove_extent(__VA_ARGS__) #endif // _CCCL_HAS_BUILTIN(__remove_extent) @@ -736,6 +740,10 @@ # define _CCCL_BUILTIN_REMOVE_REFERENCE_T(...) __remove_reference_t(__VA_ARGS__) #endif // _CCCL_HAS_BUILTIN(__remove_reference_t) +#if _CCCL_COMPILER(NVRTC, <, 12, 4) // NVRTC below 12.4 fails to properly compile cuda::std::move with that +# undef _CCCL_BUILTIN_REMOVE_REFERENCE_T +#endif // _CCCL_COMPILER(NVRTC, <, 12, 4) + #if _CCCL_HAS_BUILTIN(__remove_volatile) && _CCCL_CUDA_COMPILER(CLANG) # define _CCCL_BUILTIN_REMOVE_VOLATILE(...) __remove_volatile(__VA_ARGS__) #endif // _CCCL_HAS_BUILTIN(__remove_volatile) diff --git a/libcudacxx/include/cuda/std/__internal/cpp_dialect.h b/libcudacxx/include/cuda/std/__internal/cpp_dialect.h index a4ea71d7ef5..e91a5c4ac6a 100644 --- a/libcudacxx/include/cuda/std/__internal/cpp_dialect.h +++ b/libcudacxx/include/cuda/std/__internal/cpp_dialect.h @@ -21,7 +21,7 @@ #endif // no system header // Define LIBCUDACXX_COMPILER_DEPRECATION macro: -#if _CCCL_COMPILER(MSVC) +#if _CCCL_COMPILER(MSVC) || _CCCL_COMPILER(NVRTC) # define LIBCUDACXX_COMP_DEPR_IMPL(msg) \ _CCCL_PRAGMA(message(__FILE__ ":" _CCCL_TO_STRING(__LINE__) ": warning: " #msg)) #else // ^^^ _CCCL_COMPILER(MSVC) ^^^ / vvv !_CCCL_COMPILER(MSVC) vvv diff --git a/thrust/thrust/detail/config/cpp_dialect.h b/thrust/thrust/detail/config/cpp_dialect.h index 0d93e1ae37a..44607d97983 100644 --- a/thrust/thrust/detail/config/cpp_dialect.h +++ b/thrust/thrust/detail/config/cpp_dialect.h @@ -49,7 +49,7 @@ #define THRUST_CPP_DIALECT _CCCL_STD_VER // Define THRUST_COMPILER_DEPRECATION macro: -#if _CCCL_COMPILER(MSVC) +#if _CCCL_COMPILER(MSVC) || _CCCL_COMPILER(NVRTC) # define THRUST_COMP_DEPR_IMPL(msg) _CCCL_PRAGMA(message(__FILE__ ":" _CCCL_TO_STRING(__LINE__) ": warning: " #msg)) #else // clang / gcc: # define THRUST_COMP_DEPR_IMPL(msg) _CCCL_PRAGMA(GCC warning #msg)