bazel-diff icon indicating copy to clipboard operation
bazel-diff copied to clipboard

--useCquery probably incorrectly handles SOURCE_FILE's

Open Asdprom opened this issue 8 months ago • 0 comments

Hi!

I noticed a difference in behavior between the cquery and query implementations - on the same repository (bazel-diff-sample.zip), we get different results.

The example is quite simple: target B depends on the source file A.cc through the sample_repo local repository and target A.

//:B -> @sample_repo//:A -> @sample_repo//:A.cc

Query returns significantly more targets than cquery (with the --fineGrainedHashExternalRepos=sample_repo flag specified in both cases), when A.cc is modified.

cquery:

//sample_repo:A

query:

//sample_repo:A
@sample_repo//:A.cc
@sample_repo//:A
//sample_repo:A.cc
//:B

It is possible that the tool with the --useCquery flag is not working correctly. My suspicion falls on these two (1, 2) code fragments, where almost all sources are implicitly filtered out from the target list because SOURCE_FILE has empty rule.name. Which leads to warnings like:

[Warning] Unable to calculate digest for input @sample_repo//:A.cc for rule @sample_repo//:A

And there is no similar filtration performed when the tool is run in query mode. Sorry in advance if I somehow misunderstood this code or idea behind it, but results seem a little bit strange.

Asdprom avatar Jun 07 '24 14:06 Asdprom