Repository navigation
Conversation
dundysm
force-pushed
the
fix/1365-all-generic-cuda-module-anchor
branch
from
October 2, 2026 11:36
b7fb326 to
fd345bc
Compare
8 tasks done
… anchor All-generic #[cuda_module] skipped the rlib artifact-anchor keep-alive because the macro assumed "no artifact here". When the library itself monomorphizes, codegen still embeds .oxart with an anchor; nothing referenced it, so the linker dropped the archive member and load_all_ptx_bundles_merged returned NoModules (issue NVIDIA#1365). Emit the same cfg-guarded black_box anchor refs for generic kernels. When owner-selected with PTX-merge markers but kernel_count == 0, emit a strong anchor-only .oxlink stub so the NVIDIA#222 (mono only in the binary) shape still links. Keep merge loading; do not invent empty PTX. The anchor reference tokens are built by a small helper that takes the resolved symbol, so the generic keep-alive is unit tested without cargo's per-crate environment. Adds the generic_mono_in_lib example under cuda-oxide/crates/rustc-codegen-cuda/examples. The stub uses build_host_strong_anchor_object_for_target(_with_legacy_anchor) from oxide-artifacts 0.2.2 (PR 1446), so this builds once that release is published and the requirement is relocked. Signed-off-by: Dundy Pasupuleti <dundysm@gmail.com>
dundysm
force-pushed
the
fix/1365-all-generic-cuda-module-anchor
branch
from
October 8, 2026 03:04
fd345bc to
2da9429
Compare
Author
|
split the oxide-artifacts part out into #1446 (new strong anchor-only writers, bump to 0.2.2). the backend reads oxide-artifacts from crates.io, so this one now builds once 0.2.2 is published and relocked; i'll rebase it on top after that lands. also squashed here: the example moved under cuda-oxide/crates/rustc-codegen-cuda/examples, rustfmt, and the generic anchor tests now go through a small token builder so they pass under plain cargo test. |
This branch has not been deployed
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.
Summary
Fixes #1365.
An all-generic
#[cuda_module]in a library that monomorphizes locally still embeds.oxartwith an artifact anchor, but the macro skipped the #72 rlib keep-alive under the assumption that generics never produce an artifact in the defining crate. Nothing referenced the anchor, so the linker dropped the archive member andload_all_ptx_bundles_mergedreturnedNoModules.Adding one unused concrete kernel "fixed" it only because concrete kernels restored the keep-alive. This PR restores the handshake for generics without reverting #222 merge loading.
Root cause
.oxart?Approach
Preserves the intentional design layers:
load_named.DriverError(500, "named symbol not found")when calling generic kernels from a separate crate #222 merge load: generic modules still callload_all_ptx_bundles_merged(no named-only regression).kernel_count == 0, the backend emits a strong anchor-only.oxlinkstub (no fake empty PTX payload).Macro (
cuda_module_artifact_anchor_references)black_boxanchor refs for generic kernels viaeffective_cfg_attrs.CARGO_PKG_*skips.Backend (
rustc-codegen-cuda)cgus_require_ptx_bundle_mergeso markers are scanned even without device code.kernel_count == 0/ no device fns), emit a strong primary anchor-only object (v2 + weak legacy when owner filter is active), using the 0.2.2 writers from feat(oxide-artifacts): add strong anchor-only host objects, bump to 0.2.2 #1446.Tests / example
artifact_anchor_reference_tokens, split out of the env lookup so it can be tested without cargo's per-crate env) emits the keep-alive for generic kernels; cfg-gated generic gates the ref.oxide-artifactsstrong anchor-only object tests now live in feat(oxide-artifacts): add strong anchor-only host objects, bump to 0.2.2 #1446.generic_mono_in_libtwo-crate example undercuda-oxide/crates/rustc-codegen-cuda/examples/matching the issue (lib mono + thin bin).cuda_module_in_lib/cross_crate_embeddedshapes remain the concrete and PanicDriverError(500, "named symbol not found")when calling generic kernels from a separate crate #222 regressions.Orthogonal to #1367 / #1166 (finalizer expected-kernel inventory).
Test plan
cargo test -p cuda-macros(118 unit tests, including the two generic anchor tests)cargo clippy -p cuda-macros --all-targets -- -D warningscargo fmt --checkfor the SIMT workspace, the backend, and the new examplerustc-codegen-cuda:cargo check,cargo clippy --all-targets -- -D warnings, andcargo testagainst the feat(oxide-artifacts): add strong anchor-only host objects, bump to 0.2.2 #1446 crate via a local[patch.crates-io]scripts/sync-example-locks.sh --checkand everycuda-oxide/scripts/check-*.sh, including the cargo-deny example license policycargo oxide run generic_mono_in_liband--verify-bundlescargo oxide run cuda_module_in_libandcross_crate_embeddedReviewers
cc @nihalpasham @xavierforge (prior #72 / from-anchor / embedding owners; CODEOWNERS currently declares no path owners in-tree)