bazelbuild / bazelbuild/rules_apple
transition_support.bzl selects wrong platform in mixed-backend RBE environments
- Dominant language
- Starlark
- Stars
- 593
- Forks
- 334
- Avg merge
- 16h 48m
- Merged PRs (30d)
- 9
Description
transition_support.bzl ignores the target platform when transitioning platform-specific rules like ios_unit_test.
In my case, the default fallthrough in this code block transitions the processor architecture for the target to x86_64, whereas all my executors are amd64, causing the build to fail.
```
if platform_type == "ios":
if environment_arch:
return "ios_{}".format(environment_arch)
ios_cpus = settings["//command_line_option:ios_multi_cpus"]
if ios_cpus:
return "ios_{}".format(ios_cpus[0])
cpu_value = settings["//command_line_option:cpu"]
if cpu_value.startswith("ios_"):
return cpu_value
if cpu_value == "darwin_arm64":
return "ios_sim_arm64"
return "ios_x86_64"
```
In my case, I was able to just patch the fall-through to `ios_arm64` and get a working build.
It is unclear to me if this is adequate to resolve the issue. I suspect that `x86_64` was selected as a default here because people have intel macs that are using the `x86_64` transition value to select an xcode toolchain that is configured based on the executor's CPU architecture and not the simulator architecture (which is AFAIK always some variant of arm64 these days).
I think the right thing here is to come up with a design that separates the concerns of bundle compilation (which will always be, at least for iOS, an ARM target - although it may be a simulator or not) and toolchain selection, which I suspect is a fairly large change to the rule architecture.
Contributor guide
Research direction
Start in transition_support.bzl, especially the platform_type == "ios" branch and its default fall-through, and reproduce the mixed-backend RBE case described. Compare target-platform selection with executor and toolchain selection; done means an agreed design that avoids selecting the wrong architecture and a verified working build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100