Skip to content

fix: exclude host-only MemoryUsage.cpp from CUDA compilation (nvcc 12.8.1 + GCC 13 cudafe++ crash) - #125

Merged
jrood-nrel merged 2 commits into
mainfrom
copilot/fix-cuda-compilation-error
Jul 23, 2026
Merged

fix: exclude host-only MemoryUsage.cpp from CUDA compilation (nvcc 12.8.1 + GCC 13 cudafe++ crash)#125
jrood-nrel merged 2 commits into
mainfrom
copilot/fix-cuda-compilation-error

Conversation

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

set_cuda_build_properties() unconditionally marks every .cpp source as LANGUAGE CUDA, routing pure host-only files like src/MemoryUsage.cpp through nvcc's cudafe++ front-end. On nvcc 12.8.1 with GCC 13 as the host compiler, cudafe++ hits an internal assertion in find_allocated_name_reference while parsing stl_construct.h, aborting the build.

Changes

cmake/kynema-driver-utils.cmake

  • set_cuda_build_properties() now accepts an optional ARGN list of host-only source paths
  • Those paths are removed from the CUDA sources list and explicitly set to LANGUAGE CXX, bypassing nvcc entirely
  • Comment added documenting the nvcc 12.8.1 / GCC 13 cudafe++ crash as the motivation
function(set_cuda_build_properties target)
  # Optional ARGN: host-only source paths kept as LANGUAGE CXX to bypass
  # nvcc/cudafe++, which crashes on GCC 13 headers (nvcc 12.8.1, lexical.c
  # assertion in find_allocated_name_reference).
  set(_host_only_srcs ${ARGN})
  ...
  if(_host_only_srcs)
    list(REMOVE_ITEM _tgt_src ${_host_only_srcs})
    set_source_files_properties(${_host_only_srcs} PROPERTIES LANGUAGE CXX)
  endif()
  set_source_files_properties(${_tgt_src} PROPERTIES LANGUAGE CUDA)
  ...
endfunction()

CMakeLists.txt

  • Defines _kynema_host_only_srcs containing src/MemoryUsage.cpp and passes it to every set_cuda_build_properties() call in the CUDA-enabled block
  • No change to the CUDA=OFF path

…vcc 12.8.1 + GCC 13 cudafe++ crash

src/MemoryUsage.cpp is pure host C++ (calls getrusage) and contains no
device code. When KYNEMA_DRIVER_ENABLE_CUDA=ON, set_cuda_build_properties()
was unconditionally marking every .cpp source as LANGUAGE CUDA, routing
MemoryUsage.cpp through nvcc's cudafe++ front-end, which crashes on the
GCC 13 libstdc++ header stl_construct.h (internal assertion failure at
lexical.c in find_allocated_name_reference).

Fix: extend set_cuda_build_properties() to accept an optional ARGN list
of host-only source file paths. Those files are removed from the CUDA
sources list and explicitly set to LANGUAGE CXX so they compile through
g++ directly. Register src/MemoryUsage.cpp as a host-only source from
CMakeLists.txt. All other .cpp files continue to be compiled as CUDA.
Copilot AI changed the title [WIP] Fix CUDA compilation error with nvcc 12.8.1 fix: exclude host-only MemoryUsage.cpp from CUDA compilation (nvcc 12.8.1 + GCC 13 cudafe++ crash) Jul 23, 2026
Copilot AI requested a review from jrood-nrel July 23, 2026 19:10
@jrood-nrel
jrood-nrel marked this pull request as ready for review July 23, 2026 19:20
@jrood-nrel
jrood-nrel merged commit 179d2bf into main Jul 23, 2026
2 checks passed
@jrood-nrel
jrood-nrel deleted the copilot/fix-cuda-compilation-error branch July 23, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants