Apple toolchain env values don't get mixed into actions unless --cpu=darwin
#16 784 ouverte le 17 nov. 2022
Métriques du dépôt
- Stars
- (25 384 stars)
- Métriques de merge PR
- (Merge moyen 22j 20h) (77 PRs mergées en 30 j)
Description
Description of the bug:
When building a cc_binary (or other CcToolchain-depending target), Bazel sets up some environment variables for the actions, based mostly on flags passed to bazel, to drive the clang wrapper in particular ways, e.g. the APPLE_SDK_PLATFORM and APPLE_SDK_VERSION_OVERRIDE environment variables based on e.g. the --macos_sdk_version flag.
Ideally, this would all be configured based on platforms - the --platforms flag, or transitions within the build graph.
Without this, it's harder to perform cross-compiling builds (e.g. triggering remote macOS builds from a Linux host), or to do multi-platform builds (e.g. building some things for Linux and others for Mac).
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Write a cc_binary, and try to compile it remotely on macOS from a Linux host, without setting --cpu=darwin.
(In particular, when building with --incompatible_enable_cc_toolchain_resolution, which 🤞 we can actually flip the default of soon).
Which operating system are you running Bazel on?
Ubuntu 20.04
What is the output of bazel info release?
release 5.3.1
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
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
Some relevant code traces:
This code only sets up an ApplePlatform and fetches config values from it if the --cpu flag has a darwin-like value.
This code does the ApplePlatform loading itself.
This code conditionally reads from the --macos_sdk_version flag based on that platform.
This code actually sets up the env vars based on the variables which don't end up getting set if --cpu isn't darwin-like (or rather, they get set to empty values, because the variables they depend on aren't set).