Repository navigation
suggest rm librustc_codegen_cuda.so before cargo install cargo-oxide - #56
Merged
Merged
Conversation
Closes NVIDIA#49. Replaces the doc-side `rm -f` workaround with a real fix. `find_or_build_backend` step 3 used to return the cached `.so` whenever it existed, with no freshness check against `~/.cargo/bin/cargo-oxide`. After `cargo install --git ...` upgraded the binary, the new binary would happily `dlopen` the old `.so` and crash or misbehave. The cache is now compared against the running cargo-oxide binary's mtime: every `cargo install` rewrites the binary (bumping its mtime), so a binary newer than the cached `.so` is the canonical "user just upgraded" signal. On staleness we drop both the cached `.so` and the cached `src/` checkout; the auto-fetch path re-clones fresh, since otherwise step 4 would rebuild from a months-old `git clone --depth 1` and produce yet another stale `.so` (issue NVIDIA#49 raises this case too). Conservative on errors: if `current_exe()` or either `metadata()` call fails, we report "not stale" so a working cache is never invalidated on a failed metadata read. Tests cover the three branches: cache predates binary (stale), cache postdates binary (fresh), cache file missing (not-stale fallback). Reverts the `rm -f $HOME/.cargo/cuda-oxide/librustc_codegen_cuda.so` lines added to five docs in the original PR; with the in-tool fix they become superstition for first-time installers (who have no cache to invalidate) and would outlive the bug they were documenting.
nihalpasham
approved these changes
May 16, 2026
nihalpasham
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the PR
A couple of additions/changes on layered on top:
- Replaced the docs-side
rm -fworkaround with a real fix inbackend.rs. - Step 3 now drops the cached
.soandsrc/when the cargo-oxide binary is newer, so step 4 re-clones fresh on next upgrade. - Three unit tests cover stale, fresh, and missing-cache branches; closes #49.
So here's what a before - after looks like
Before:
user upgrades cargo-oxide → step 3 returns OLD .so → binary dlopens old backend → crash
After:
user upgrades cargo-oxide → step 3 sees binary mtime > .so mtime
→ drops both .so and src/ from cache
→ step 4 re-clones fresh and rebuilds
→ binary dlopens matching backend
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.
This is a placeholder/interim "solution" for part of #49 . By documenting the existence and relevance of
librustc_codegen_cuda.sothe few folks who actually modify or update their cuda-oxide installation will know how to remove a stale artifact.A more long-term solution would be to automate the replacement of
librustc_codegen_cuda.sowhen a new cuda-oxide tool is installed.