bazel: Indirect incompatible target skipping can have highly non-local silent effects

Description of the bug:

During a bazel test //..., Bazel skips all targets that transitively depend on a target that is incompatible, as determined by target_compatible_with.

This can have far reaching implications: If any target in the transitive dependencies of a test has target_compatible_with added to it, this causes the test to be skipped on that platform. Even if a Bazel project doesn’t use target_compatible_with itself, it may be affected by this without even being aware of the concept if an external dependency adds this specification.

Over at Jazzer, we recently accidentally and silently disabled our entire test suite on Windows by merging a change that added target_compatible_with somewhere far down in the dependency tree.

I could see guarding indirect incompatible target skipping behind a flag as a potential solution to this. Direct incompatible target skipping works very well and without surprises in all contexts I have used it so far.

What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which operating system are you running Bazel on?

Any

What is the output of bazel info release?

0573eee38d7d3b695267dfd125ab8e08d83a2640

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 master; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

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

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 1
  • Comments: 23 (9 by maintainers)

Most upvoted comments

That’s essentially what I was getting at here: https://docs.google.com/document/d/127pgkR610qaz1k3-OVgt3tbEeMKAm_jFNeRQcUc99d0/edit?disco=AAAA2Q-lZF8

although I stopped short of proposing an implementation.

One way could be

    tags = ["no-transitive-incompatible"],

which would cause analysis to fail if this target’s target_compatible_with matches the current configuration, but one or more of its deps did not. This tag could be set on “top-level” targets.

Or you could consider two tags: "allow-transitive-incompatible" and "disallow-transitive-incompatible", and then introduce some command line switch to set the default for targets which have neither tag.

(I don’t especially love magical tags, but I can’t think of another way to accomplish this in a backwards-compatible way.)

One more idea I had: Make it so that a target with target_compatible_with set explicitly fails analysis if it is compatible according to this attribute but transitively depends on a target that is incompatible. This makes it possible to mark arbitrary, especially top-level targets with what their compatibility should be.