Skip to content

Resolve cuda_toolkit in exec config#482

Merged
cloudhan merged 1 commit into
bazel-contrib:mainfrom
AustinSchuh:exec_config
Jun 8, 2026
Merged

Resolve cuda_toolkit in exec config#482
cloudhan merged 1 commit into
bazel-contrib:mainfrom
AustinSchuh:exec_config

Conversation

@AustinSchuh

Copy link
Copy Markdown
Contributor

cuda_toolchain.compiler_files is gathered with cfg = "exec", so the files materialized as inputs to CudaCompile actions live under bazel-out/<exec>/bin/. The clang toolchain config, however, derives --cuda-path= from ctx.attr.cuda_toolkit[CudaToolkitInfo].libdevice without specifying a config, so it picks up the target-config File object whose dirname points at bazel-out/<target>/bin/. When the CTK files are generated (e.g. a synthetic CUDA root that drops in wrappers next to real headers), the flag and the materialized inputs land at different paths and clang fails with "cannot find CUDA installation".

Match the toolchain's exec-config view of the CTK in the toolchain config rule so the rendered --cuda-path lines up with the inputs in the sandbox. Source-file CTKs are unaffected because source files are config-independent.

`cuda_toolchain.compiler_files` is gathered with `cfg = "exec"`, so the
files materialized as inputs to CudaCompile actions live under
`bazel-out/<exec>/bin/`. The clang toolchain config, however, derives
`--cuda-path=` from `ctx.attr.cuda_toolkit[CudaToolkitInfo].libdevice`
without specifying a config, so it picks up the target-config File
object whose `dirname` points at `bazel-out/<target>/bin/`. When the
CTK files are generated (e.g. a synthetic CUDA root that drops in
wrappers next to real headers), the flag and the materialized inputs
land at different paths and clang fails with "cannot find CUDA
installation".

Match the toolchain's exec-config view of the CTK in the toolchain
config rule so the rendered `--cuda-path` lines up with the inputs in
the sandbox. Source-file CTKs are unaffected because source files are
config-independent.

Signed-off-by: Austin Schuh <austin.linux@gmail.com>
@cloudhan cloudhan merged commit 087c098 into bazel-contrib:main Jun 8, 2026
23 checks passed
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