Skip to content

Rust: Add nvtx-sys tools feature exposing the tools/injection ABI#170

Open
mbrobbel wants to merge 1 commit into
NVIDIA:devfrom
mbrobbel:rust-tools
Open

Rust: Add nvtx-sys tools feature exposing the tools/injection ABI#170
mbrobbel wants to merge 1 commit into
NVIDIA:devfrom
mbrobbel:rust-tools

Conversation

@mbrobbel

@mbrobbel mbrobbel commented Jul 16, 2026

Copy link
Copy Markdown
Member

What

Adds a default-off tools feature to nvtx-sys that extends the existing bindgen allowlist with the NVTX tools/injection ABI from nvtxDetail/nvtxTypes.h:

  • The callback-subscription types: NvtxExportTableCallbacks, NvtxExportTableVersionInfo, NvtxExportTableID, NvtxCallbackModule, all six NvtxCallbackId* enums, NvtxGetExportTableFunc_t, NvtxInitializeInjectionNvtxFunc_t, NvtxFunctionPointer, and NvtxFunctionTable.
  • The function-table slot signatures (*_impl_fntype / *_fakeimpl_fntype) and the dependency-free fake types they reference (nvtx_CUdevice, nvtx_cl_*, ...), so tools cast slots to header-defined signatures instead of hand-maintained ones.
  • The injection result codes (NVTX_SUCCESS, NVTX_FAIL, NVTX_ERR_*).

Why

Rust tools (injection libraries) currently have to run their own bindgen pipeline against the NVTX headers to get these types. Since nvtx-sys already generates bindings from the in-repo headers, exposing the tools ABI behind an opt-in feature lets tools depend on nvtx-sys directly.

This is the first of a series: follow-ups add subscriber support to the nvtx crate on top of this feature.

Notes

  • With tools disabled, the generated bindings are byte-identical to before (verified by diffing generated bindings.rs); with it enabled they are a strict superset.
  • The wrapper already parses nvtxTypes.h (it is included even under NVTX_NO_IMPL), so this only changes the allowlist/blocklist: the .*fntype.* blocklist now applies only when tools is off.

Verification

  • check.sh profiles pass: fmt, check/clippy -Dwarnings and tests for --all-features, --no-default-featuresalloc), MSRV 1.77, and the thumbv7em-none-eabi no-default check; plus --features tools alone and tools,cuda,cuda_runtime.

🤖 Generated with Claude Code

@mbrobbel mbrobbel changed the title Rust: Add nvtx-sys tools feature exposing the tools/injection ABI Rust: Add nvtx-sys tools feature exposing the tools/injection ABI Jul 16, 2026

@evanramos-nvidia evanramos-nvidia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We will need to see a concrete use case for this before we consider merging it.

Also, please see CONTRIBUTING.md.

Allowlist the callback-subscription types, function-table slot
signatures, and injection result codes from nvtxDetail/nvtxTypes.h
behind a new (default-off) tools feature. Default bindings are
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Matthijs Brobbel <m1brobbel@gmail.com>
@mbrobbel

Copy link
Copy Markdown
Member Author

We will need to see a concrete use case for this before we consider merging it.

@willkill07 willkill07 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems sensible to me. Exposition within the nvtx-sys crate should be viewed as safe in the general case.

We can be more critical of the end-user interface which builds upon it.

@9prady9

9prady9 commented Jul 22, 2026

Copy link
Copy Markdown

merge ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants