bazel-contrib / bazel-contrib/rules_cuda
Invalid relocatable device link action generated on header-only cuda_library targets with LTO arches
- Dominant language
- Starlark
- Stars
- 122
- Forks
- 73
- Avg merge
- 7h 34m
- Merged PRs (30d)
- 7
Description
Trying to build a `cuda_library` target that only has `hdrs` with `--@rules_cuda//cuda:archs="lto_80"` (or any LTO arch target) correctly results in no compilation actions but does generate a device link action with zero inputs, which obviously fails.
From reading the action implementations `compile.bzl` correctly handles the empty `srcs` case since [this loop](https://github.com/bazel-contrib/rules_cuda/blob/1b36a264f61f4fb811d403428cc999f0d2bf3eb1/cuda/private/actions/compile.bzl#L61) never fires on empty inputs, but in `dlink.bzl` a depset of objects & transitive objects [gets passed straight to actions.run](https://github.com/bazel-contrib/rules_cuda/blob/1b36a264f61f4fb811d403428cc999f0d2bf3eb1/cuda/private/actions/dlink.bzl#L90-L98) so there's no check whether the set of direct inputs is empty or not.
Contributor guide
Research direction
Start in cuda/private/actions/dlink.bzl around lines 90-98 and compare its empty-input handling with cuda/private/actions/compile.bzl around line 61. Reproduce a header-only cuda_library build using --@rules_cuda//cuda:archs="lto_80". Done means the build produces no invalid zero-input device link action and completes successfully.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100