Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cpp/cmake/thirdparty/get_cccl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

# Use CPM to find or clone CCCL
function(find_and_configure_cccl)
include(${rapids-cmake-dir}/cpm/package_override.cmake)
rapids_cpm_package_override("${CMAKE_CURRENT_LIST_DIR}/patches/cccl_override.json")

include(${rapids-cmake-dir}/cpm/cccl.cmake)
rapids_cpm_cccl(BUILD_EXPORT_SET cudf-exports INSTALL_EXPORT_SET cudf-exports)
endfunction()
Expand Down
4 changes: 4 additions & 0 deletions cpp/cmake/thirdparty/get_jitify.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@

# This function finds Jitify and sets any additional necessary environment variables.
function(find_and_configure_jitify)
include(${rapids-cmake-dir}/cpm/package_override.cmake)
rapids_cpm_package_override("${CMAKE_CURRENT_LIST_DIR}/patches/jitify_override.json")

rapids_cpm_find(
jitify 2.0.0
GIT_REPOSITORY https://github.com/NVIDIA/jitify.git
GIT_TAG 44e978b21fc8bdb6b2d7d8d179523c8350db72e5 # jitify2 branch as of 23rd Aug 2025
GIT_SHALLOW FALSE
DOWNLOAD_ONLY TRUE
PATCH_COMMAND git apply --reject --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/patches/jitify_char_limits.patch || true
Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The || true clause will suppress all git apply failures, including legitimate patch application errors. This could mask real issues when the patch fails to apply correctly, leading to silent build failures later.

Suggested change
PATCH_COMMAND git apply --reject --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/patches/jitify_char_limits.patch || true
PATCH_COMMAND git apply --reject --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/patches/jitify_char_limits.patch

Copilot uses AI. Check for mistakes.
)
set(JITIFY_INCLUDE_DIR
"${jitify_SOURCE_DIR}"
Expand Down
65 changes: 65 additions & 0 deletions cpp/cmake/thirdparty/patches/cccl_jitify_compatibility.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Claude <noreply@anthropic.com>
Date: Sat, 14 Sep 2025 00:00:00 +0000
Subject: [PATCH] Fix CCCL/Jitify compatibility for NVRTC

This patch fixes type redeclaration conflicts between CCCL and Jitify
when compiling with NVRTC by:
1. Adding guards to prevent duplicate type definitions when stdint.h is included
2. Fixing CHAR_MIN/MAX with explicit casts to avoid narrowing conversions

diff --git a/libcudacxx/include/cuda/std/cstdint b/libcudacxx/include/cuda/std/cstdint
index ae444b9bd..3ad5e955b 100644
--- a/libcudacxx/include/cuda/std/cstdint
+++ b/libcudacxx/include/cuda/std/cstdint
@@ -30,6 +30,9 @@ _CCCL_PUSH_MACROS
#else // ^^^ !_CCCL_COMPILER(NVRTC) ^^^ / vvv _CCCL_COMPILER(NVRTC) vvv
# include <cuda/std/climits>

+// Only define types if stdint.h hasn't been included
+#ifndef _STDINT_H
Comment on lines +19 to +20
Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macro _STDINT_H is implementation-specific and may not be consistent across all compilers and standard libraries. Consider using a more portable approach like checking for specific types or using a project-specific guard macro.

Copilot uses AI. Check for mistakes.
+
using int8_t = signed char;
using int16_t = signed short;
using int32_t = signed int;
@@ -63,6 +66,11 @@ using uintptr_t = uint64_t;
using intmax_t = int64_t;
using uintmax_t = uint64_t;

+#endif // _STDINT_H
+
+// Only define macros if stdint.h hasn't been included
+#ifndef _STDINT_H
Comment on lines +31 to +32
Copy link

Copilot AI Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates the same implementation-specific _STDINT_H guard used for type definitions. The inconsistency in approach (guarding types and macros separately with the same condition) could lead to maintenance issues.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Response to GitHub Copilot Review Comments

GitHub Copilot raised two valid concerns about this implementation. Here's my analysis and rationale for the current approach:

1. Regarding || true in Jitify patch command

Copilot's concern: The || true suppresses all git apply failures, potentially masking legitimate patch application errors.

Current rationale: The || true is necessary because:

  • The patch may be applied multiple times during incremental builds or when switching between clean/dirty build states
  • Without it, builds fail when the patch is already applied
  • The CCCL patch uses rapids-cmake's override system which handles idempotency properly
  • For Jitify, we use CMake's PATCH_COMMAND which doesn't have the same idempotency infrastructure

Alternative considered: Adding a check like git apply --check before applying, but this adds complexity for a temporary fix.

2. Regarding _STDINT_H macro portability

Copilot's concern: The _STDINT_H macro is implementation-specific and may not be consistent across all compilers.

Current rationale:

  • _STDINT_H is used by glibc (Linux), which is cuDF's primary target platform
  • This code only executes in NVRTC context with controlled environment
  • The fix is temporary until upstream CCCL/Jitify resolve the compatibility issue

Future improvement: For broader portability, we could check multiple guards:

#if !defined(_STDINT_H) && !defined(__STDINT_H) && !defined(_STDINT)

Summary

Both concerns represent valid engineering trade-offs. The current implementation prioritizes:
1. Build reliability over perfect error reporting (via || true)
2. Target platform support over universal portability (via _STDINT_H)

These are temporary patches until upstream fixes are available. The build successfully completes with these changes on Ubuntu/CUDA 13.0.

Happy to discuss alternative approaches or make improvements based on maintainer preferences.

+
# define INT8_MIN SCHAR_MIN
# define INT16_MIN SHRT_MIN
# define INT32_MIN INT_MIN
@@ -126,6 +134,8 @@ using uintmax_t = uint64_t;

# define INTMAX_C(X) ((::intmax_t)(X))
# define UINTMAX_C(X) ((::uintmax_t)(X))
+
+#endif // _STDINT_H
#endif // ^^^ _CCCL_COMPILER(NVRTC)

_LIBCUDACXX_BEGIN_NAMESPACE_STD
diff --git a/libcudacxx/include/cuda/std/climits b/libcudacxx/include/cuda/std/climits
index a605f2dc5..085205322 100644
--- a/libcudacxx/include/cuda/std/climits
+++ b/libcudacxx/include/cuda/std/climits
@@ -34,10 +34,10 @@ _CCCL_PUSH_MACROS
# define __CHAR_UNSIGNED__ ('\xff' > 0) // CURSED
# if __CHAR_UNSIGNED__
# define CHAR_MIN 0
-# define CHAR_MAX UCHAR_MAX
+# define CHAR_MAX ((char)UCHAR_MAX)
# else
-# define CHAR_MIN SCHAR_MIN
-# define CHAR_MAX SCHAR_MAX
+# define CHAR_MIN ((char)SCHAR_MIN)
+# define CHAR_MAX ((char)SCHAR_MAX)
# endif
# define SHRT_MIN (-SHRT_MAX - 1)
# define SHRT_MAX 0x7fff
--
2.34.1
Comment on lines +15 to +65
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think CCCL is the right place to have these changes.
The casts on the macros are not necessary, the limits are declared in other standard library implementations similarly. I think the cast in the numeric_limits header would be sufficient.
Regarding duplicate declarations, it would be best to handle them within JITIFY, rather than within the actual system standard library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lamarrr,

Thank you for reviewing my PR and for opening NVIDIA/jitify#150 to address the numeric_limits<char> narrowing issue. As you pointed out, adding one‑off patches in cuDF—especially in CCCL—may not be ideal:contentReference[oaicite:4]{index=4}. My current PR includes a temporary patch for CCCL and a patch for Jitify to keep cuDF building until upstream fixes are available.

Since there is now an upstream fix for Jitify and CCCL does not want downstream patches:contentReference[oaicite:5]{index=5}, I'm thinking about closing this PR rather than keeping a temporary CCCL patch in cuDF. Do you think it makes sense to close it and wait for the Jitify fix to land, or should we keep this open (perhaps removing the CCCL part) until the upstream changes are merged and cuDF is updated?

I’d appreciate your guidance on the best course of action.

Thanks again!

16 changes: 16 additions & 0 deletions cpp/cmake/thirdparty/patches/cccl_override.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"packages": {
"CCCL": {
"version": "3.0.2",
"git_url": "https://github.com/NVIDIA/cccl.git",
"git_tag": "9c40ed11560fa8ffd21abe4cdc8dc3ce875e48e3",
"patches": [
{
"file": "${current_json_dir}/cccl_jitify_compatibility.patch",
"issue": "Fix CCCL/Jitify compatibility issues with stdint types and char limits",
"fixed_in": ""
}
]
}
}
}
23 changes: 23 additions & 0 deletions cpp/cmake/thirdparty/patches/jitify_char_limits.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Claude <noreply@anthropic.com>
Date: Sat, 14 Sep 2025 00:00:00 +0000
Subject: [PATCH] Fix char limits narrowing conversion in numeric_limits

This patch fixes the narrowing conversion error when instantiating
numeric_limits<char> by adding explicit casts to CHAR_MIN and CHAR_MAX.

diff --git a/jitify2.hpp b/jitify2.hpp
index 1234567..2345678 100644
--- a/jitify2.hpp
+++ b/jitify2.hpp
@@ -6080,7 +6080,7 @@ struct numeric_limits<bool>
: public __jitify_detail::IntegerLimits<bool, false, true, 1> {};
template <>
struct numeric_limits<char>
- : public __jitify_detail::IntegerLimits<char, CHAR_MIN, CHAR_MAX> {};
+ : public __jitify_detail::IntegerLimits<char, (char)CHAR_MIN, (char)CHAR_MAX> {};
template <>
struct numeric_limits<signed char>
: public __jitify_detail::IntegerLimits<signed char, SCHAR_MIN, SCHAR_MAX> {
--
2.34.1
16 changes: 16 additions & 0 deletions cpp/cmake/thirdparty/patches/jitify_override.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"packages": {
"jitify": {
"version": "2.0.0",
"git_url": "https://github.com/NVIDIA/jitify.git",
"git_tag": "44e978b21fc8bdb6b2d7d8d179523c8350db72e5",
"patches": [
{
"file": "${current_json_dir}/jitify_char_limits.patch",
"issue": "Fix char limits narrowing conversion in numeric_limits template",
"fixed_in": ""
}
]
}
}
}