Skip to content

Csaint/cuda runtime rdc static deps - #488

Open
charleysaintNV wants to merge 7 commits into
bazel-contrib:mainfrom
charleysaintNV:csaint/cuda-runtime-rdc-static-deps
Open

Csaint/cuda runtime rdc static deps#488
charleysaintNV wants to merge 7 commits into
bazel-contrib:mainfrom
charleysaintNV:csaint/cuda-runtime-rdc-static-deps

Conversation

@charleysaintNV

Copy link
Copy Markdown
Contributor

Move CUDA RDC device runtime libs into the toolchain

Summary

This change removes unconditional propagation of CUDA device runtime static archives from the normal CUDA runtime dependency and moves them into the CUDA toolchain.

The goal is to let non-RDC consumers of @rules_cuda//cuda:runtime keep linking against shared libcudart without also pulling libcudadevrt.a / libculibos.a into downstream shared libraries. RDC builds still get those static archives from the toolchain for device-link and final host-link correctness.

Changes

  • Adds device_runtime_static_libs to CudaToolkitInfo.
  • Discovers local toolkit libcudadevrt.a / libculibos.a and generated redist aliases as toolchain inputs.
  • Adds the device runtime static archives to CUDA device-link actions.
  • Propagates device runtime static archives into final C++ linking only for cuda_library(rdc = True).
  • Removes cudadevrt_a / culibos_a from the normal dynamic cuda_runtime dependency path.
  • Exposes cudadevrt_a / cudadevrt_lib aliases from the cudart component registry so generated toolchains can reference them.

Validation

Rules CUDA:

bazel test //tests/flag:cuda_library_dlink_copts_and_host_copts_flag_test
bazel build @rules_cuda_examples//rdc:main_from_library
bazel build @rules_cuda_examples//basic:main

Link-shape checks:

bazel aquery --noshow_progress 'mnemonic("CppLink", @rules_cuda_examples//basic:main)' --output=text
bazel aquery --noshow_progress 'mnemonic("CppLink", @rules_cuda_examples//rdc:main_from_library)' --output=text
  • Non-RDC basic:main final link uses shared libcudart and does not include libcudadevrt.a, libculibos.a, or libcudart_static.a.
  • RDC rdc:main_from_library final link includes libcudadevrt.a and libculibos.a from the CUDA toolchain.

Downstream smoke validation:

bazel build --override_module=rules_cuda=/home/csaint/nv/csaint/rules_cuda \
  :visual_global_localization_node_so

The representative shared library libvisual_global_localization_node.so dropped to about 20 MB, and the package SO link params used shared libcudart.so.13 without cudadevrt, culibos, or cudart_static entries.

@cloudhan

cloudhan commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Generally looks good. But where is my CI?🤔

@charleysaintNV
charleysaintNV force-pushed the csaint/cuda-runtime-rdc-static-deps branch from d018775 to 83f58e2 Compare August 7, 2026 03:19
@charleysaintNV

Copy link
Copy Markdown
Contributor Author

Not sure why that happened but a rebase seems to have corrected it...

@charleysaintNV

Copy link
Copy Markdown
Contributor Author

@cloudhan not sure if I need to fix CI or if it's expected to fail in some cases

@cloudhan

cloudhan commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

The two window tests can be ignored for now.

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.

2 participants