facebook / facebook/buck2

How do I perform BXL analysis over targets with incompatible configurations?

Open
#757 7 comments 0 reactions 0 assignees View on GitHub
bxl
Dominant language
Rust
Stars
4.4k
Forks
394
PR merge metrics
No merged PRs in 30d

Description

Consider a BXL script that needs to both perform actions via `ctx.bxl_actions().actions` and run analysis via `ctx.analysis()`.
We must enable execution platforms for the actions to work, via `-c build.execution_platforms=//my:platform`. However, this breaks analysis when the target pattern includes transitioned targets (both via rule transitions and `attrs.configured_dep()`) or in general when not all targets are compatible with the same configuration. This will look something like this:

```
0: Error in configured node dependency, dependency chain follows (-> indicates depends on, ^ indicates same configuration as previous):
root//:main_target (root//initial_platform#862bbf0260c42c92)
-> root//:transitioned_target (root//new_platform#3b9c87e21a60f426)
-> toolchains//:cxx (^)

1: Can't find toolchain_dep execution platform using configuration ``
```

I have tried setting the `target_platform` and `skip_incompatible` parameters to `ctx.analysis()`, but this made no difference.

Here are my observations:
- It is possible that specifying all possible platforms as execution platforms would solve this issue, but I see no way to do this, and this would be very inconvenient at best.
- Regular builds do not have this issue, the execution platform is properly determined for any target.
- I could somewhat work around this if I could filter out targets based on configuration, but I see no way to do that cleanly. I can match on target names or rule names, but that's not quite enough. Even then, I would like to be able to handle those targets, skipping them is not always an acceptable option. Being able to dynamically set the execution platform based on the target platform would potentially help?

Note that the analysis runs fine when I don't set an execution platform, but again this is not an option in order to use actions. I'm not sure which side of the problem should be "fixed" in this case.

If anyone has experience dealing with such a situtation (BXL analysis over configuration-incompatible targets _and_ running actions in the same script), I'd be very interested in hearing about how they do that.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.