@@ -342,23 +342,22 @@ def to_gn_args(args):
342
342
gn_args['host_cpu'] = 'x86'
343
343
gn_args['current_cpu'] = 'x86'
344
344
345
- if is_host_build(args) and gn_args['host_os'] == 'mac':
346
- # macOS host builds (whether x64 or arm64) must currently be built under
347
- # Rosetta on Apple Silicon Macs.
348
- # TODO(cbracken): https://github.com/flutter/flutter/issues/103386
345
+ # When building binaries to run on a macOS host (like gen_snapshot), always
346
+ # use the clang_x64 toolchain, which will run under Rosetta. This is done for
347
+ # two reasons:
348
+ # 1. goma currently only supports the clang_x64 toolchain.
349
+ # 2. gen_snapshot cannot crossbuild from arm64 to x64. Its host architecture
350
+ # must be x64 to target x64.
351
+ # TODO(cbracken): https://github.com/flutter/flutter/issues/103386
352
+ if get_host_os() == 'mac' and not args.force_mac_arm64:
349
353
gn_args['host_cpu'] = 'x64'
350
354
355
+ if is_host_build(args) and gn_args['host_os'] == 'mac':
351
356
# macOS unit tests include Vulkan headers which reference Metal types
352
357
# introduced in macOS 10.14.
353
358
gn_args['mac_sdk_min'] = '10.14'
354
359
gn_args['mac_deployment_target'] = '10.14.0'
355
360
356
- # macOS target builds (whether x64 or arm64) must currently be built under
357
- # Rosetta on Apple Silicon Macs.
358
- # TODO(cbracken): https://github.com/flutter/flutter/issues/103386
359
- if 'target_os' in gn_args and gn_args['target_os'] == 'mac':
360
- gn_args['host_cpu'] = 'x64'
361
-
362
361
if gn_args['target_os'] == 'ios':
363
362
gn_args['use_ios_simulator'] = args.simulator
364
363
elif get_host_os() == 'mac':
@@ -729,6 +728,13 @@ def parse_args(args):
729
728
parser.add_argument(
730
729
'--mac-cpu', type=str, choices=['x64', 'arm64'], default='x64'
731
730
)
731
+ parser.add_argument(
732
+ '--force-mac-arm64',
733
+ action='store_true',
734
+ default=False,
735
+ help='Force use of the clang_arm64 toolchain on an arm64 mac host when '
736
+ 'building host binaries.'
737
+ )
732
738
parser.add_argument('--simulator', action='store_true', default=False)
733
739
parser.add_argument(
734
740
'--linux', dest='target_os', action='store_const', const='linux'
0 commit comments