Repository navigation
Conversation
cfa4b39 to
eb140b1
Compare
|
I think this is not enough: in sbsa environment this wouldn’t work, even if cuda is installed. |
|
Updated to scan CUDA target-layout directories via |
Report missing or unreadable CUDA headers directly from the build script and discover CUDA headers and libraries in both the standard toolkit layout and target-specific layouts such as targets/x86_64-linux and targets/sbsa-linux. Signed-off-by: yagna-1 <[email protected]>
eb140b1 to
fbf7a7a
Compare
Discover CUDA headers and libraries across target-specific toolkit layouts such as targets/x86_64-linux and targets/sbsa-linux instead of hardcoding a single target directory. Signed-off-by: yagna-1 <[email protected]>
|
I think this introduces another problem: if multiple CUDA targets are installed, we may end up mixing dependencies and likely cause build/link errors. We should probably first discover the CUDA host target, and only then look for cuda.h under that target. |
|
Thanks for the PR, the diagnosis is right and the error-message UX is a nice improvement. We can't accept external contributions to Two changes from your version:
The doctor half of #87 stays open. Closing as already-fixed. (Your #95 merged today, thanks for both.) |
A missing cuda.h previously fell through to bindgen, which panicked with raw clang diagnostics before cargo oxide doctor could diagnose the host (issue NVIDIA#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 NVIDIA#88; re-landed NVIDIA-authored because cuda-bindings cannot accept external contributions.
…egra (#700) * fix(cuda-bindings): select targets/ by full build target, and reach Tegra `toolkit_target_dir` matched only the first segment of the `TARGET` triple, so the architecture alone decided the CUDA `targets/<dir>` layout and the OS was never consulted. Every non-Linux target therefore claimed a Linux directory: `aarch64-apple-darwin` resolved to `sbsa-linux` and `x86_64-pc-windows-msvc` to `x86_64-linux`, both of which then fed `find_cuda_include_dir` and `collect_lib_paths` a path that cannot exist on those platforms. The arch-only match also left CUDA for Tegra unreachable. Tegra installs (Jetson, Drive) put their headers under `targets/aarch64-linux/`, while `sbsa-linux` is the ARM *server* tree -- and both build natively as `aarch64-unknown-linux-gnu`, so the triple cannot tell them apart. aarch64 Linux now yields both names as ordered candidates and the existing `cuda.h` existence probe picks the one actually installed. `sbsa-linux` stays first, so an install carrying both trees resolves exactly as it does today. Selection keys off `CARGO_CFG_TARGET_ARCH`/`CARGO_CFG_TARGET_OS` rather than splitting the triple: the triple's field count varies (`arch-vendor-os-env` vs `arch-os-env`), and `aarch64-linux-android` would otherwise read as a Linux target. This is not the `targets/*` glob proposed in #88 and rejected. Every candidate returned is for the requested architecture only, so a multi-target install can never hand an x86_64 build the `sbsa-linux` headers that sort ahead of it; `multi_target_install_never_hands_x86_64_ the_sbsa_headers` pins that. The table and the candidate-path construction live in `toolkit_target.rs` and are pulled into both `build.rs` and `tests/toolkit_target.rs` with `include!`, because cargo never builds a build script as a test target. Eight tests cover the selection table, the Tegra and sbsa layouts, a multi-target install, the standard top-level `include/`, and non-Linux targets. They fail against the previous arch-only behavior. Signed-off-by: Nils Homer <[email protected]> * fix(cuda-bindings): add CUDA_TOOLKIT_TARGET_DIR override and mirror the targets/ selection Two completions on top of the targets/ selection rework: - CUDA_TOOLKIT_TARGET_DIR names one targets/ tree by hand, like nvcc's -target-dir flag and CMake's CUDAToolkit_TARGET_DIR. When set (and not blank) it is the single targets/ candidate; the directory is still probed for cuda.h, so a wrong value fails with the clear discovery error instead of silently falling back to the table. build.rs emits rerun-if-env-changed for it, and the synthetic-tree tests cover both the resolving and the deliberately-failing override. - The two hand-kept mirrors catch up with the shared table in crates/cuda-bindings/toolkit_target.rs: doctor's cuda_header_candidates in cargo-oxide and the multicast probe in cuda-core/build.rs now key on arch+OS instead of the first triple segment, probe both aarch64 Linux trees (sbsa-linux, then aarch64-linux), and honor the same override. Their lockstep comments now name toolkit_target.rs. --------- Signed-off-by: Nils Homer <[email protected]> Co-authored-by: nihalpasham <[email protected]>
Summary
cuda-bindingsbuild script report missing or unreadable CUDA headers directly instead of falling through to a bindgen panic.include/layout and target-specific redistributable layouts such astargets/x86_64-linux/include/andtargets/sbsa-linux/include/.Fixes #87.
Test plan
cargo fmt --check --allcargo test -p cuda-device -p oxide-artifacts -p reserved-oxide-symbols --lib --testscargo test -p cargo-oxide --all-targetson a host without CUDA headers now fails with the directcuda-bindings: could not find cuda.h...build-script error instead of a bindgen panic.