lowRISC / lowRISC/opentitan

[bazel,dvsim] Inconsistent label names in cquery can cause dvsim failures

Open
#19,553 1 comment 0 reactions 0 assignees View on GitHub
Earlgrey-PROD Triaged
Dominant language
SystemVerilog
Stars
3.6k
Forks
1.1k
Avg merge
2d 22h
Merged PRs (30d)
141

Description

### Description

It appears that bazel `cquery` output when using the starlark output format [has changed in bazel 6](https://github.com/bazelbuild/bazel/issues/17864). The difference is that it now adds a '@' by default in front of targets.
I have run into this issues when working on #19510 because [dvsim/sim.mk](https://github.com/lowRISC/opentitan/blob/master/hw/dv/tools/dvsim/sim.mk) filters target as follows:
```bash
if [[ $$dep == //hw/ip/otp_ctrl/data* ]] || \
([[ $$dep != //hw* ]] && [[ $$dep != //util* ]] && [[ $$dep != //sw/host* ]]); then \
```
Unfortunately, if bazel adds a '@' in front, this makes the filter useless and it tries to copy some files it should not.

The bazel bug reports says that they are working on (yet another) flag to make the output more consistent.

In the mean time, possible options are:
- fix the filter to use '@', but I don't know how stable this will be if the cquery output changes again,
- use a custom starlark function instead of the default one to output targets. Something like
```
--starlark:expr='str(target.label)[1:] if str(target.label).startswith("@//") else target.label'
```
- combination of both: fix filter and make sure that the output always starts with @
```
--starlark:expr='target.label if str(target.label).startswith("@") else "@{}".format(target.label)'
```

@timothytrippel @cfrantz

Contributor guide

Open the contributing guide

Research direction

Read hw/dv/tools/dvsim/sim.mk and inspect the cquery target filtering described in the issue. Reproduce the Bazel 6 label output and compare it with the filter's assumptions. Done means the filter handles the label format consistently and dvsim no longer attempts to copy unintended files.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.