Skip to content

Commit

Permalink
Add --host_macos_cpus flag
Browse files Browse the repository at this point in the history
When your macOS build has tools that build with the Apple rules, such as
`macos_command_line_application`, you likely want to share caches
between Apple Silicon and Intel machines. Today your tool would build
for the host architecture (ideally, see bazelbuild#13440)
which means the tools would differ between the different architectures,
leading to split caches. This flag allows you to pass
`--host_macos_cpus=arm64,x86_64` in order to produce a fat binary for
host tools. This has the downside of increasing binary size for your
tools, but likely that trade-offs is worth it for almost everyone versus
having split caches.
  • Loading branch information
keith committed May 10, 2021
1 parent f6cce24 commit 9384545
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ public class AppleCommandLineOptions extends FragmentOptions {
help = "Comma-separated list of architectures for which to build Apple macOS binaries.")
public List<String> macosCpus;

@Option(
name = "host_macos_cpus",
allowMultiple = true,
converter = CommaSeparatedOptionListConverter.class,
defaultValue = "null",
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {OptionEffectTag.LOSES_INCREMENTAL_STATE, OptionEffectTag.LOADING_AND_ANALYSIS, OptionEffectTag.AFFECTS_OUTPUTS},
help = "Comma-separated list of architectures for which to build host Apple macOS binaries.")
public List<String> hostMacosCpus;

@Option(
name = "catalyst_cpus",
allowMultiple = true,
Expand Down Expand Up @@ -483,6 +493,7 @@ public FragmentOptions getHost() {
// Preseve Xcode selection preferences so that the same Xcode version is used throughout the
// build.
host.preferMutualXcode = preferMutualXcode;
host.macosCpus = hostMacosCpus;

return host;
}
Expand Down

0 comments on commit 9384545

Please sign in to comment.