Skip to content

sys: honor CUDA_TOOLKIT_PATH in runtime discovery - #95

Merged
nihalpasham merged 4 commits into
NVIDIA:mainfrom
yagna-1:fix/sys-crates-cuda-toolkit-path
Jun 12, 2026
Merged

nihalpasham merged 4 commits into
NVIDIA:mainfrom
yagna-1:fix/sys-crates-cuda-toolkit-path

Conversation

@yagna-1

@yagna-1 yagna-1 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Include CUDA_TOOLKIT_PATH in libNVVM and nvJitLink runtime discovery.
  • Keep it ahead of CUDA_HOME and CUDA_PATH so runtime loading matches the build script and CI environment.
  • Add unit tests for the CUDA root search order.

Fixes #93

Test plan

  • cargo fmt --check --all
  • cargo test -p libnvvm-sys -p nvjitlink-sys --lib
  • cargo clippy -p libnvvm-sys -p nvjitlink-sys --lib --tests -- -D warnings

Search CUDA_TOOLKIT_PATH before CUDA_HOME and CUDA_PATH when discovering
libNVVM and nvJitLink so runtime loading matches the project-supported build
environment.

Signed-off-by: yagna-1 <[email protected]>
@nihalpasham nihalpasham added bug Something isn't working build-related Build scripts, toolchain discovery, or compilation setup labels Jun 6, 2026
The ltoir module carries a third copy of cuda_roots() that the sys-crate
fix did not reach, so a toolkit installed only via CUDA_TOOLKIT_PATH
would load libNVVM and nvJitLink but still fail to find libdevice.10.bc.
Port the same precedence (CUDA_TOOLKIT_PATH, CUDA_HOME, CUDA_PATH, then
the /usr/local/cuda and /opt/cuda defaults) and reuse the closure seam
so the search order stays unit-testable without touching process env.
The runtime search now consults CUDA_TOOLKIT_PATH first, but the
module docs, READMEs, and not-found error messages still advertised
only CUDA_HOME and CUDA_PATH, steering users away from the variable
the build environment already standardizes on. Sweep every discovery
list (libnvvm-sys, nvjitlink-sys, the primitive_stress README) and
both LibraryNotFound messages to match the actual probe order.
@nihalpasham

Copy link
Copy Markdown
Collaborator

LGTM 👍🏾, verified the precedence end-to-end (fake roots via env: CUDA_TOOLKIT_PATH wins over CUDA_HOME, fallback order intact).

Layered two commits on top:

  • cuda-host: there is a third duplicated cuda_roots() in cuda-host's ltoir module (libdevice discovery) that still ignored CUDA_TOOLKIT_PATH, so a toolkit installed only via that var would load libNVVM and nvJitLink but fail on libdevice.10.bc. Ported your closure seam + order test there.
  • docs: swept the discovery lists (module docs, both READMEs, one example README) and the LibraryNotFound / LibdeviceNotFound messages to name CUDA_TOOLKIT_PATH.

@nihalpasham
nihalpasham merged commit 2144f38 into NVIDIA:main Jun 12, 2026
24 checks passed
meefs pushed a commit to meefs/cuda-oxide that referenced this pull request Sep 30, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runtime CUDA library discovery ignores CUDA_TOOLKIT_PATH

2 participants