--fission fails with confusing error when dwp not in toolchain tool_paths
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the bug:
For some reason when we created our toolchain we didn't include `"dwp"` in our toolchain's `"tool_paths"` map. When I tried to use `--fission=yes`, I got this unhelpful error:
```
ERROR: /home/ubuntu/mongo/src/mongo/db/BUILD.bazel:3369:16: in cc_binary rule //src/mongo/db:mongod_with_debug:
Traceback (most recent call last):
File "/virtual_builtins_bzl/common/cc/cc_binary.bzl", line 905, column 44, in _impl
File "/virtual_builtins_bzl/common/cc/cc_binary.bzl", line 782, column 35, in cc_binary_impl
File "/virtual_builtins_bzl/common/cc/cc_binary.bzl", line 144, column 20, in _create_debug_packager_actions
Error in run: in call to run(), parameter 'executable' got value of type 'NoneType', want 'File, string, or FilesToRunProvider'
ERROR: /home/ubuntu/mongo/src/mongo/db/BUILD.bazel:3369:16: Analysis of target '//src/mongo/db:mongod_with_debug' failed
```
I eventually traced it town to the following code assuming that there would be a "dwp" tool available and not handling the case where it isn't and the lookup returns `None`: https://github.com/bazelbuild/bazel/blob/c71f0b6ded1de926bd1081fd4327142777711b03/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl#L47-L50 https://github.com/bazelbuild/bazel/blob/c71f0b6ded1de926bd1081fd4327142777711b03/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl#L99-L102 https://github.com/bazelbuild/bazel/blob/c71f0b6ded1de926bd1081fd4327142777711b03/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl#L144-L147
In an ideal world, if `dwp` isn't available, that should just disable the creation of the optional `binary.dwp` targets but still allow the normal local-dev use case of just having a bunch of `blah.dwo` files that don't get rolled up. If that is too complicated, or not worth supporting, at the very least it would be nice to print a nicer failure message pointing to what the problem is and how to fix it, eg: `Using --fission requires that a binary be provided for "dwp" in your cc_toolchain's "tool_paths"`. That will save the next person who runs into this from needing to spend so long figuring out what the problem is.
### Which category does this issue belong to?
C++ Rules
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Unfortunately our bazel setup, including the toolchain building is heavily abstracted at the moment because we are in the middle of porting from another build system, and we support a weird hybrid build mode. This includes our toolchain setup. So I cannot easily make a minimal repro. That said, based on the code I see, I suspect that if you just comment out the `"dwp"` entry in your toolchain's `"tool_paths"` map, and then try to build with `--fission=yes` you will hit this.
That said, if you want a repro, check out https://github.com/mongodb/mongo at commit a921de973f898c01ec1d64476bbdd6e5c8449993 and run `bazelisk build --fission=yes --config=local //src/mongo/db:mongod`. I will soon be adding "dwp" to our "tool_paths" settings [here](https://github.com/mongodb/mongo/blob/a921de973f898c01ec1d64476bbdd6e5c8449993/bazel/toolchains/mongo_toolchain.BUILD#L43-L58) and [here](https://github.com/mongodb/mongo/blob/a921de973f898c01ec1d64476bbdd6e5c8449993/bazel/toolchains/mongo_toolchain.BUILD#L72-L91), so if you get a later commit, this probably won't repro.
### Which operating system are you running Bazel on?
linux
### What is the output of `bazel info release`?
release 7.2.1
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse HEAD` ?
```text
A private mirror which won't help you. See repo steps for a public copy.
```
### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
_No response_
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start in src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl at the dwp lookup and debug packager actions referenced in the report. Reproduce with --fission=yes using a cc_toolchain whose tool_paths omits dwp, or use the MongoDB commit and commands provided. Determine the intended missing-dwp behavior, then verify that the build either handles it or reports the required toolchain configuration clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100