Skip to content

suggest rm librustc_codegen_cuda.so before cargo install cargo-oxide - #56

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
mutantbob:doc-artifact-workaround
May 16, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
mutantbob:doc-artifact-workaround

Conversation

@mutantbob

Copy link
Copy Markdown

This is a placeholder/interim "solution" for part of #49 . By documenting the existence and relevance of librustc_codegen_cuda.so the 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.so when a new cuda-oxide tool is installed.

@nihalpasham nihalpasham added the build-related Build scripts, toolchain discovery, or compilation setup label May 16, 2026
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 nihalpasham left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR

A couple of additions/changes on layered on top:

  • Replaced the docs-side rm -f workaround with a real fix in backend.rs.
  • Step 3 now drops the cached .so and src/ 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

@nihalpasham
nihalpasham merged commit d0844eb into NVIDIA:main May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-related Build scripts, toolchain discovery, or compilation setup

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants