Skip to content

cuda-bindings: clean error for missing cuda.h, target-aware toolkit layout - #172

Merged
nihalpasham merged 1 commit into
mainfrom
reland/cuda-bindings-header-errors
Jun 12, 2026
Merged

nihalpasham merged 1 commit into
mainfrom
reland/cuda-bindings-header-errors

Conversation

@nihalpasham

Copy link
Copy Markdown
Collaborator

NVIDIA-authored re-land of the build-script hardening @yagna-1 diagnosed in #88. cuda-bindings cannot accept external contributions, so the fix lands here; #88 will be closed with already-fixed. This addresses the panic half of #87.

  • Missing cuda.h is now one clean build-script error through the existing run()/main() exit-1 path: it lists the probed paths (<root>/include/cuda.h and <root>/targets/<dir>/include/cuda.h), names CUDA_TOOLKIT_PATH / CUDA_HOME, and states the /usr/local/cuda default. No more bindgen panic with raw clang diagnostics.
  • Redistributable layouts select the single targets/ directory matching cargo's TARGET (x86_64 -> x86_64-linux, aarch64 -> sbsa-linux), never a sorted glob over targets/*. On multi-target installs sbsa-linux sorts before x86_64-linux, so a glob hands x86_64 builds the wrong arch's headers and stubs. The same selection feeds bindgen's -I and the lib + lib/stubs link-search dirs.
  • Policy: present-but-unreadable cuda.h keeps main's warn-and-continue probe (bindgen reports the authoritative failure right after, now routed through the clean error path instead of an expect); only a missing header is a hard discovery-time error.
  • Verified: normal build; CUDA_TOOLKIT_PATH=/nonexistent fails with the new message; a fake targets/{x86_64-linux,sbsa-linux} layout with a poisoned sbsa stub builds via x86_64-linux only.

The doctor half of #87 (cargo oxide doctor should be reachable without cuda-bindings building first) stays open.

A missing cuda.h previously fell through to bindgen, which panicked
with raw clang diagnostics before cargo oxide doctor could diagnose
the host (issue #87). Discovery now happens up front: probe
{toolkit}/include/cuda.h and the build target's
{toolkit}/targets/<dir>/include/cuda.h, and exit through the existing
run()/main() error path with one message listing the probed paths,
CUDA_TOOLKIT_PATH/CUDA_HOME, and the /usr/local/cuda default.

The targets/ directory is chosen from cargo's TARGET env (x86_64 ->
x86_64-linux, aarch64 -> sbsa-linux) rather than globbing targets/*:
on multi-target installs a sorted glob puts sbsa-linux stubs ahead of
x86_64-linux. The same single-target selection feeds the bindgen -I
flag and the lib + lib/stubs link-search dirs.

A present but unreadable cuda.h keeps the warn-and-continue probe
behavior (bindgen reports the authoritative failure right after, now
mapped through the clean error path instead of an expect panic);
only a missing header is a hard discovery-time error.

Idea credited to @yagna-1's diagnosis in #88; re-landed
NVIDIA-authored because cuda-bindings cannot accept external
contributions.
@nihalpasham nihalpasham added bug Something isn't working cuda-bindings Raw FFI bindings to the CUDA driver/runtime build-related Build scripts, toolchain discovery, or compilation setup labels Jun 12, 2026
@nihalpasham
nihalpasham merged commit 835803b into main Jun 12, 2026
24 checks passed
@nihalpasham
nihalpasham deleted the reland/cuda-bindings-header-errors branch June 12, 2026 10:19
meefs pushed a commit to meefs/cuda-oxide that referenced this pull request Sep 30, 2026
…t arch (NVIDIA#185)

Follow-ups to NVIDIA#183 (issue NVIDIA#172):

- Extract redist archives with --skip-old-files --warning=existing-file:
  cross-archive path collisions become first-wins and visible in the
  build log instead of silently taking whichever archive extracted last.
  Reorder libnvvm ahead of cuda_nvcc so canonical nvvm/ files win under
  first-wins, and document that the list order now matters.
- Assert bin/tileiras and nvvm/lib64/libnvvm.so exist after assembly so
  the exe-relative-lookup failure mode from NVIDIA#172 cannot silently regress
  on a future version bump.
- Derive the Debian multiarch driver directory from uname -m instead of
  enumerating per-arch triplets: shorter, searches the host arch first,
  and covers future architectures without edits.
- Point the hash bookkeeping at NVIDIA's redistrib_13.3.0.json manifest
  for future version bumps.

Signed-off-by: Melih Elibol <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working build-related Build scripts, toolchain discovery, or compilation setup cuda-bindings Raw FFI bindings to the CUDA driver/runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant