bazel-contrib / bazel-contrib/rules_cuda
Critical failure for projects that build on non-Linux and non-Windows platforms in `redist_json_helper.bzl`
- Dominant language
- Starlark
- Stars
- 122
- Forks
- 73
- Avg merge
- 7h 34m
- Merged PRs (30d)
- 7
Description
If a project builds on multiple platforms and registers a toolchain, for example, for Linux, it will fail here when building on machines that do not necessarily build targets which depend on these returned repositories but are on platforms that don't match the below `if` statement:
```
os = None
if _is_linux(ctx):
os = "linux"
elif _is_windows(ctx):
os = "windows"
arch = "x86_64" # TODO: support cross compiling
platform = "{os}-{arch}".format(os = os, arch = arch)
components = attr.components if attr.components else [k for k, v in FULL_COMPONENT_NAME.items() if v in redist]
for c in components:
c_full = FULL_COMPONENT_NAME[c]
payload = redist[c_full][platform]
```
https://github.com/bazel-contrib/rules_cuda/blob/a862f9b1cb7b6cf15c775fd31e4a1cf56f148a82/cuda/private/redist_json_helper.bzl#L74
To reproduce, simply set the `os = None` as it would be for anything that isn't linux or windows. It'll fail when defining the `payload` as the `platform` will be `None-{arch}`
A simple fix could be setting a default value for `os` or returning dummy repositories for alternative platforms.
Contributor guide
Research direction
Start in cuda/private/redist_json_helper.bzl around the platform selection and payload lookup shown in the issue. Reproduce the failure on a non-Linux, non-Windows host or by setting os to None, then determine the intended handling for unsupported platforms; done means multi-platform projects no longer fail while resolving these repositories.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100