Conversation
… 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. Signed-off-by: Dundy Pasupuleti <dundysm@gmail.com>
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).Tests / example
oxide-artifacts: strong anchor-only object tests.generic_mono_in_libtwo-crate example 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 oxide-artifacts --features object --lib(24 passed, including new strong-anchor tests)scripts/sync-example-locks.sh --checkscripts/check-example-smoketest-contract.shcargo test -p cuda-macros --lib(blocked on this box: no CUDA 13 toolkit forcuda-bindings)cargo oxide run generic_mono_in_liband--verify-bundles(no GPU / no toolkit here)cargo oxide run cuda_module_in_libandcross_crate_embedded(same)CI on this PR should cover the CUDA-backed lanes.
Reviewers
cc @nihalpasham @xavierforge (prior #72 / from-anchor / embedding owners; CODEOWNERS currently declares no path owners in-tree)