Repository navigation
fix(cargo-oxide): take the scaffold's host crates from cuda-host's git source - #1488
Merged
nihalpasham merged 2 commits intoOct 15, 2026
Merged
nihalpasham merged 2 commits into
nihalpasham merged 2 commits into
Conversation
…t source `cargo oxide new` named cuda-core (and, with --async, cuda-async) from crates.io at 0.4.0 next to a git cuda-host. cuda-host depends on those crates by path at tip of tree. The lockfile therefore carried two cuda-core packages and the expansion of #[cuda_module] failed to type-check: 7 errors in the sync template, 13 in the async one, all CudaContext/CudaModule mismatches. The templates now take cuda-core and cuda-async from GIT_REPO, the source cuda-host already comes from, and SHARED_HOST_CRATES_VERSION goes away. check-shared-crate-pin.sh section 3 now requires every host-crate line in the templates to use GIT_REPO and rejects a crates.io requirement there. A new test asserts the same invariant over both templates. Signed-off-by: Alejandro Soto Franco <sotofranco.eng@gmail.com>
The scaffold now names every CUDA crate from the git source cuda-host comes from, and the guard checks for that instead of a crates.io version constant. Rewrite the root manifest comment that still named the removed constant, and the status-guard job comment and step name that still described a crates.io release copied into the templates. Signed-off-by: nihalpasham <nihalp@nvidia.com>
nihalpasham
requested review from
binarybana,
cryos,
elibol,
kkraus14,
roivanov and
rparolin
as code owners
October 15, 2026 08:04
Collaborator
|
/ok to test a536122 |
Collaborator
|
I verified the breakage and the fix at
Merges cleanly with #1489 in either order. Closes #1459: the scaffold no longer needs a version derived from the root manifests. |
nihalpasham
approved these changes
Oct 15, 2026
nihalpasham
added a commit
that referenced
this pull request
Oct 15, 2026
## What this adds
`cargo oxide new` writes the repository address of `cuda-device` and
`cuda-host` into every new project's manifest, and the backend fallback
clone fetches the same address when no cuda-oxide dependency pins a
commit. Both still named the pre-move `NVlabs/cuda-oxide` repository,
which resolves only through GitHub's redirect and leaves every new
lockfile recording the old source. Both now name `NVIDIA/cuda-rust`.
```text
cargo oxide new demo
Before cuda-device = { git = "https://github.com/NVlabs/cuda-oxide.git" }
source = "git+https://github.com/NVlabs/cuda-oxide.git#bc46b1ff..." (via redirect)
checkout ~/.cargo/git/checkouts/cuda-oxide-<hash>/bc46b1f/
After cuda-device = { git = "https://github.com/NVIDIA/cuda-rust.git" }
source = "git+https://github.com/NVIDIA/cuda-rust.git#bc46b1ff..." (direct)
checkout ~/.cargo/git/checkouts/cuda-rust-<hash>/bc46b1f/
```
```bash
cargo oxide new demo && cd demo
cargo oxide build # builds the backend from the checkout Cargo made for cuda-device
```
## What we fixed
- `GIT_REPO` in `scaffold.rs`, interpolated into both scaffold
templates, now reads `https://github.com/NVIDIA/cuda-rust.git`.
- The fallback `git clone --depth 1` in `backend.rs`, used only for
projects with no cuda-oxide dependency, clones the same address.
- The `backend_source.rs` module diagram, its test constant and the
matching README diagram follow: the checkout is `cuda-rust-<hash>`, and
the backend crate and the toolchain pin sit under `cuda-oxide/` in it.
- A scaffold test asserts the emitted `git =
"https://github.com/NVIDIA/cuda-rust.git"` lines in both templates and
rejects the old address.
<details><summary>Implementation</summary>
- Backend discovery never reads the URL:
`dependency_source_from_metadata` keys on the package name and
`manifest_path`, `git_source_rev` keeps only the `#<sha>` fragment, and
`checkout_root` walks up to the first directory holding `Cargo.toml`
plus the codegen crate, bounded by `.git` or `.cargo-ok`.
- `codegen_crate_in_checkout` prefers
`cuda-oxide/crates/rustc-codegen-cuda` and falls back to the historical
flat `crates/rustc-codegen-cuda`; `pinned_channel` walks from the
codegen crate upward, so the component nightly wins over the stable pin
at the git root. The same two functions serve the fallback clone.
- The backend cache is keyed by commit (`source-rev.txt`), not by URL,
so cached backends and existing projects are unaffected.
- The historical issue permalink to `/issues/96` in the
README stays, per the repository guide.
</details>
## Verification
Checked at `746d60eb`:
- ✅ `cargo test -p cargo-oxide --all-targets`: 243 passed; 244 with the
new URL test.
- ✅ `cargo clippy -p cargo-oxide --all-targets -- -D warnings`, `cargo
fmt --check`, rustdoc with `-D warnings`, and all 18
`scripts/check-*.sh` guards pass.
- ✅ `grep -rn NVlabs crates/cargo-oxide/src` returns nothing; the
remaining hits are the README install line (#1491) and the #96
permalink.
- ✅ In an isolated `CARGO_HOME`: `cargo oxide new` writes the new
address in both templates; `cargo generate-lockfile` records
`git+https://github.com/NVIDIA/cuda-rust.git#bc46b1ff` for
`cuda-device`, `cuda-host` and `cuda-macros` in a `cuda-rust-*`
checkout; `cargo oxide build` builds the backend from that checkout's
`cuda-oxide/crates/rustc-codegen-cuda` under nightly-2026-10-11 and
caches it with `source-rev.txt = bc46b1f`.
- ✅ The old-address baseline binary scaffolds `NVlabs/cuda-oxide.git`
and resolves the same commit through the redirect; `git ls-remote` on
both URLs returns the same HEAD.
- ✅ A shallow clone of `NVIDIA/cuda-rust` builds the backend offline
from its nested codegen crate under the component nightly, which is the
fallback route.
- ✅ Auto-merges with #1488, #1490 and #1491 in either order.
## Caveats
- A scaffolded project still fails to compile at this head with two
`cuda-core` crates in its graph; that is #1488's fix and is independent
of the address.
- A graph that mixes the old and new address for the same crate resolves
two checkouts and `cargo oxide` refuses it;
`[patch."https://github.com/NVlabs/cuda-oxide.git"]` pointing the crate
at the new address collapses the graph to one source.
- Machines that already hold the old-address git database fetch the
repository once more under the new name; the backend cache is reused
because it is keyed by commit.
- The remaining old-address mentions are the install lines (#1491) and
the manifest `repository` fields and license CSV (#1490).
---------
Signed-off-by: Alejandro Soto Franco <sotofranco.eng@gmail.com>
Signed-off-by: nihalpasham <nihalp@nvidia.com>
Co-authored-by: nihalpasham <nihalp@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
cargo oxide newwrote a manifest that tookcuda-deviceandcuda-hostfrom the repository's git URL butcuda-core(andcuda-asyncwith--async) from crates.io 0.4.0.cuda-hostdepends oncuda-coreby path inside that checkout, so every scaffolded project resolved twocuda-corepackages and the code#[cuda_module]generates failed to type-check. The templates now name every CUDA crate from the same git source, so cargo resolves one copy of each.What we fixed
cuda-coreandcuda-asyncfromGIT_REPO, the sourcecuda-hostcomes from;SHARED_HOST_CRATES_VERSIONis gone.check-shared-crate-pin.shsection 3 requiresgit = "{GIT_REPO}"on every host-crate line in the templates and rejects a crates.io requirement there.scaffold_takes_every_cuda_crate_from_one_git_sourceasserts everycuda-*line in both templates names the same git source ascuda-device.Scaffold dependency contract
Every CUDA crate in a new project comes from one git source with no version requirement. The first build locks all of them to one commit of that repository, and
cargo updatemoves them together. A crates.iocuda-coreorcuda-asyncbeside a gitcuda-hostis always a second crate and does not compile.Implementation
cuda-oxidefrom crates.iocuda-core0.3.1 onto the git-root path copies while the scaffold kept its crates.io constant; build: depend on the shared host crates by path at tip of tree #1466 only dropped theversion = "=0.4.0"qualifier. Lockfiles resolved at the commit before a kernel which accepts a reference to an application struct seems to cause illegal memory access #29 hold onecuda-core; at a kernel which accepts a reference to an application struct seems to cause illegal memory access #29, before build: depend on the shared host crates by path at tip of tree #1466 and at build: depend on the shared host crates by path at tip of tree #1466 they hold two.cuda-corefrom the sourcecuda-hostuses.cuda-bindings, which no user code names and whichcuda-corepulls by path.CudaContext,CudaModule,DeviceBufferand theDriverErrorclosure: 6 E0308 plus 1 E0277 in the sync template; 9 E0308, 3 E0277 and 1 E0599 in the async one.Verification
Checked at
180770a9:cargo test -p cargo-oxide --all-targets: 244 passed. With the old template lines restored and the new tests kept, 3 scaffold tests fail.cargo clippy -p cargo-oxide --all-targets -- -D warnings,cargo fmt --checkand rustdoc with-D warningsclean.check-*.shguards pass.check-shared-crate-pin.shrejects four reintroduced forms (cuda-core = "0.4.0",{ version = "0.4.0" }, a different git URL,cuda-async = "0.4.0") with exit 1.cargo oxide newfor both templates fails to build, 7 and 13 errors, with twocuda-core,cuda-bindingsandcuda-core-deriveper lockfile (and twocuda-async).cargo oxide newthencargo oxide runfor both templates on an RTX 5090 (sm_120a, CUDA 13.4):PASSED: all 1024 elements correct,compute-sanitizer --tool memcheck0 errors, onecuda-coreper lockfile and zero registrycuda-*packages. Same result on the author's RTX 5060 Laptop (sm_120, CUDA 13.3).https://github.com/NVIDIA/cuda-rust.git.Caveats
rev,branchortagadded to one line still resolves a secondcuda-core, even at the same commit; a follow-up tightens the comparison to the full source.GIT_REPOstill namesNVlabs/cuda-oxide, which GitHub redirects; fix(cargo-oxide): scaffold and clone from NVIDIA/cuda-rust #1489 renames it.Closes #1459.