Inheritance of Target Incompatibility #19200
Replies: 6 comments 22 replies
-
Review request acknowledged... |
Beta Was this translation helpful? Give feedback.
-
Thanks for taking this on @fmeum (and @philsc for ongoing attention & support). I read through carefully and added lots of pedantic comments. Thoughts:
So I suggest we get consensus on these core themes as abstract principles, then consensus on how the implementation fulfills them. I imagine the latter will be easier. I hope this doesn't come across as obstructionist. I'm thinking this way because I worry about the increasing number of toggles coming into the model: multiple flags, repo membership, propagation semantics, direct vs. indirect, etc. The more we have the more complicated the intersection between them and the harder it is to support a clear story. I'm hoping further first principle contemplation could uncover more opportunity to minimize these toggles. https://github.com/pcjanzen @trybka as other notable participants. |
Beta Was this translation helpful? Give feedback.
-
Separate thread:
I'd also love to hear more clarification of how these types of projects work: what kinds of binaries / tests, mixed together how, what real-life changes alter their compatibility properties? How do they integrate the current query-and-tag approach? |
Beta Was this translation helpful? Give feedback.
-
Since the original approach just isn't flexible enough as it doesn't allow direct and incompatibility to be mixed and also permanently relies on a flag, I'm now favoring a different approach based on what @pcjanzen brought up in #18707 (comment). The new idea is very simple: If a target has I prototyped the approach in https://github.com/bazelbuild/bazel/pull/22651/files#diff-a982fd7588855b07d791b1b297ffc662b316c80313943ec6998af93edb331c5e (I recommend taking a look at the integration tests). @gregestren @pcjanzen Please let me know what you think about this alternative. |
Beta Was this translation helpful? Give feedback.
-
Another workaround I'm experimenting with is to define my own # Usage: $0 <cquery-options> <pattern>
incompatible_expr='target.label if "IncompatiblePlatformProvider" in providers(target) else ""'
# List all targets that should be marked with either `self_incompatible` or `deps_incompatible`.
self_and_automatic_incompatible_targets=$(bazel cquery --output=starlark --starlark:expr="$incompatible_expr" --@my_platforms//:deps_incompatible=@my_platforms//:compatible "$@" | sort -u)
# List all incompatible targets.
all_incompatible_targets=$(bazel cquery --output=starlark --starlark:expr="$incompatible_expr" "$@" | sort -u)
# List targets that are incompatible but are missing the declaration.
to_add_deps_incompatible_targets=$(echo "${self_and_automatic_incompatible_targets}" | xargs -n1 bazel cquery --output=jsonproto "${@:1:$#-1}" | jq --raw-output '
.results[] | select(
.target.rule.attribute[] |
select(.name == "target_compatible_with") |
(.stringListValue // []) |
[
.[] |
select(. == "@my_platform//:self_incompatible" or . == "@my_platform//:deps_incompatible")
] == []
) |
.target.rule.name'
)
to_remove_deps_incompatible=$(comm -13 <(echo "${self_and_automatic_incompatible_targets}") <(echo "${all_incompatible_targets}"))
if [ ! -z "${to_remove_deps_incompatible}" ]; then
echo
echo "--- The following targets should have :deps_incompatible removed"
echo "${to_remove_deps_incompatible}"
echo "--- End of :deps_incompatible removal list"
fi
if [ ! -z "${to_add_deps_incompatible_targets}" ]; then
echo
echo "--- The following targets should have :deps_incompatible added"
echo "${to_add_deps_incompatible_targets}"
echo "--- End of :deps_incompatible add list"
fi Edit 2024-11-14: Fixed the |
Beta Was this translation helpful? Give feedback.
-
I would like to run Does anyone have any ideas how to automatically skip targets when toolchains are not registered? |
Beta Was this translation helpful? Give feedback.
-
This is the discussion thread for the Inheritance of Target Incompatibility proposal, which aims to make it both more obvious and more configurable how target incompatibility caused by
target_compatible_with
propagates up the dependency graph.Feedback is very welcome, here or on the doc.
Beta Was this translation helpful? Give feedback.
All reactions