Open gferon opened 2 years ago
Up to this point the apple rules don't support platforms in general, which is why this case isn't covered. it likely works with swift_library directly because there are no custom transitions inherently with that rule, so bazel handles it.
I'm not sure what other implications adding this to the transition would have, part of the issue today is we have to satisfy bazel internals with some of the apple specific attributes you see in this transition, so I'm not sure what adding platforms to this would break.
Would you still accept such contribution on the bazel/5.x branch
yep sure, we just need to land in master first
Do you know if it is expected behaviour that Bazel completely ignores any invalid values of --platforms= if a target doesn't make use of them/apply transitions based on this flag. This sounds like a bug to me.
I'm not sure, does sound surprising
Thanks for the quick and detailed answer! The only problem I have right now is that master
already has something that could work for us, but won't work with Bazel v5.3 because it transitions on --incompatible_enable_apple_toolchain_resolution
.
You can submit directly to the 5.x branch if absolutely necessary but the problem is if you don't submit to master first we might miss your fix once you do want to upgrade
We have a mixed language build and spent a bit of time trying to understand why platforms aren't propagated (well, ignored) when building a
ios_application
target, but worked fine when building aswift_library
one (the core library which the app depends on). When building theios_application
target,--platforms
are ignored and the build fails with symbols from mixed platforms (some built with the host target and the final linking phase with the right one).After a bit of investigating, we realized that adding the
//:command_line_options:platforms
to the transition outputs and setting it to the platforms declared in @build_bazel_apple_support//platforms fixes our issue.When using only
--platforms
with the transitionplatform_mappings
API, this works exactly as intended. A bit more logic change was involved to fixapple_xcframework
when using--platforms
which we should probably send a patch for separately.I think the patch is rather straightforward, but I have a bunch of questions before I open a PR to discuss it further:
master
branch is seeing a lot of work towards supporting exactly this, and maybe works only on Bazel 6.x? Would you still accept such contribution on thebazel/5.x
branch?--platforms=
if a target doesn't make use of them/apply transitions based on this flag. This sounds like a bug to me.cc @boxdot