Repository navigation
feat(finalizer): fail a link that drops an expected kernel - #1367
Merged
nihalpasham merged 4 commits intoNov 9, 2026
Merged
Conversation
nvJitLink can report success while dropping a module's kernels: an unresolved device-runtime symbol makes it discard the module, and the link-time optimizer strips a kernel it finds unreachable. The result is a well-formed but empty image, which is_valid_cubin accepts. Every finalizer link now takes the kernels its output must define and checks the output's entry points after the link: cubin entries from the ELF symbol table (FUNC symbols with STO_CUDA_ENTRY), PTX entries from ptx-parse. A missing kernel is FinalizerError::MissingKernels, and an image whose entries cannot be read is UnreadableEntryInventory. Rooting stays with the @llvm.used the exporter already emits; nvJitLink's -kernels-used is not passed, since it also lets the link drop kernels it does not list. The expected kernels reach every finalization route: - build-time materialization: the collector's kernel export names; - embedded bundles finalized at load: the bundle's Kernel entries; - sidecar files (cargo oxide interop, cuda-host's file loader): a new <module>.kernels sidecar the compiler writes next to the .ll, before the completing .target. An artifact the compiler emitted must have it; a manual .ll is checked against one only when present. Cached cubins are checked on a hit too, since a stored image may predate the check. The cuda-host build/link functions and the finalizer entry points take the expected kernels as a new argument. Tests: synthetic empty and partial cubins, PTX with only device functions, unreadable inventories, the sidecar format, and a live link whose unrooted kernel nvJitLink drops (cubin and PTX); the live file-cache test now roots its kernel, which it previously linked away. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Zihua Wu <[email protected]>
lucifer1004
force-pushed
the
feat/final-link-kernel-check
branch
from
September 30, 2026 00:58
66f9ad8 to
770c4e8
Compare
This was referenced Oct 1, 2026
Signed-off-by: nihalpasham <[email protected]>
nihalpasham
previously approved these changes
Nov 3, 2026
Collaborator
|
/ok to test 6bf77be |
Collaborator
|
Thanks, verifying that every expected kernel entry survives At |
Signed-off-by: nihalpasham <[email protected]>
Collaborator
|
/ok to test 6c46708 |
Signed-off-by: nihalpasham <[email protected]>
Collaborator
|
/ok to test 63e6f01 |
nihalpasham
approved these changes
Nov 9, 2026
2 of 3 tasks
nihalpasham
added a commit
that referenced
this pull request
Nov 9, 2026
…oir (#1766) ## What This PR Does Passes the generated `call_<decl>` kernel entry names (`call_relu`, `call_scale_in_place`, `call_warp_sum`) to `LtoLinker::link_ltoir` in `examples/tilelib_relu` and ignores `*.kernels` sidecars in `cuda-oxide/.gitignore`: 1. **Expected Kernel List (`crates/rustc-codegen-cuda/examples/tilelib_relu/src/main.rs`)** 2. **Sidecar Ignore Rule (`cuda-oxide/.gitignore`)** --- ### 1. Matching `caller.cu`'s Generated Entry Names in `tilelib_relu` `caller_source` in `tilelib_relu` generates one `__global__` wrapper kernel per callable `#[tile_export]` named `call_<decl>`. Passing `exports.iter().map(|desc| format!("call_{}", desc.decl))` to `LtoLinker::link_ltoir` matches the actual cubin entry table: ```text BEFORE (#1367): link_ltoir(..., &["caller"]) ──► fails at runtime: `missing expected kernel(s) ["caller"] (3 entry point(s) present)` AFTER: expected_kernels = ["call_relu", "call_scale_in_place", "call_warp_sum"] ──► `link_ltoir` verifies all 3 generated wrapper kernels in the linked cubin ``` --- ## Verification * `cargo oxide run tilelib_relu --emit-nvvm-ir --arch sm_100`: **PASS** (`3/3 tile exports verified through the native ABI`) * `cargo clippy --manifest-path cuda-oxide/crates/rustc-codegen-cuda/examples/tilelib_relu/Cargo.toml --all-targets -- -D warnings`: **PASS** * `rustfmt --check --edition 2024 cuda-oxide/crates/rustc-codegen-cuda/examples/tilelib_relu/src/main.rs`: **PASS** --------- Signed-off-by: nihalpasham <[email protected]>
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 PR Does
Verifies that every expected kernel entry point survives
nvJitLink/ PTX finalization incuda-artifact-finalizer, failing closed withFinalizerError::MissingKernelsifnvJitLinksilently drops a module or strips an expected kernel:cuda-artifact-finalizer): After linking, inspects ELF cubin symbols (FUNCwithSTO_CUDA_ENTRY) or PTX.entrycallables (ptx-parse) and verifies every expected kernel is present.mir-importer,rustc-codegen-cuda,cuda-host,cargo-oxide): Build-time materialization passes the collector's kernel export names, embedded bundles pass theirKernelentries, and sidecar.llbuilds write<module>.kernels(cuda-oxide expected-kernels v1).Verification
cargo test -p cuda-artifact-finalizer -p cuda-host --all-targets: PASSjust fmt-check,cargo clippy,sync-example-locks.sh --check, and repository guards: PASSRefs #1071