Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

cbracken
Copy link
Member

@cbracken cbracken commented May 11, 2022

This adds support for the following builds:

  • macOS host builds on both x86_64 and arm64 Macs.
  • macOS target builds on both x86_64 and arm64 Macs.

Previously, macOS target builds for any architecture were possible only
on x86_64 Macs.

Similarly, macOS host builds were only supported on x86_64 Macs, and
only for the x86_64 architecture. arm64 host builds were not possible on
Intel Macs.

When building on arm64 macs, builds are performed under Rosetta for two
reasons:

  • The Fuchsia clang toolchain for arm64 macOS is not yet available.
  • Swiftshader (used by our engine tests) doesn't support building OpenGL
    support as an arm64 binary.

See: flutter/flutter#103386

Followup patches will move our use of Swiftshader to a "Swangle"
(Swiftshader + ANGLE) configuration, eliminating the Swiftshader issue
above.

Issue: flutter/flutter#96745
Issue: flutter/flutter#79403

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@cbracken cbracken added the Work in progress (WIP) Not ready (yet) for review! label May 11, 2022
@cbracken cbracken force-pushed the macos-x64-build-with-rosetta branch from f9b1530 to cd350f2 Compare May 11, 2022 01:43
@cbracken cbracken removed the Work in progress (WIP) Not ready (yet) for review! label May 11, 2022
@cbracken cbracken requested a review from zanderso May 11, 2022 02:50
gn_args['target_cpu'] = get_target_cpu(args)
gn_args['dart_target_arch'] = gn_args['target_cpu']
gn_args['target_cpu'] = get_target_cpu(args)
gn_args['dart_target_arch'] = gn_args['target_cpu']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting target_cpu and dart_target_arch here could be extracted out and made unconditional, but I'm not sure it makes the code any simpler to reason about. Maybe worth it with dart_target_arch...

# Rosetta on Apple Silicon Macs.
# TODO(cbracken): https://github.com/flutter/flutter/issues/103386
if 'target_os' in gn_args and gn_args['target_os'] == 'mac':
gn_args['host_cpu'] = 'x64'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three blocks (Windows, macOS host builds, macOS target builds) are broken out separately since they're likely to have separate fixes.

This adds support for the following builds:
* macOS host builds on both x86_64 and arm64 Macs.
* macOS target builds on both x86_64 and arm64 Macs.

Previously, macOS target builds for any architecture were possible only
on x86_64 Macs.

Similarly, macOS host builds were only supported on x86_64 Macs, and
only for the x86_64 architecture. arm64 host builds were not possible on
Intel Macs.

When building on arm64 macs, builds are performed under Rosetta for two
reasons:
* The Fuchsia clang toolchain for arm64 macOS is not yet available.
* Swiftshader (used by our engine tests) doesn't support building as an
  arm64 binary.

See: flutter/flutter#103386

Issue: flutter/flutter#96745
Issue: flutter/flutter#79403
@cbracken cbracken force-pushed the macos-x64-build-with-rosetta branch from cd350f2 to 500d30a Compare May 11, 2022 03:11
@cbracken cbracken merged commit 3bc1b81 into flutter:main May 11, 2022
@cbracken cbracken deleted the macos-x64-build-with-rosetta branch May 11, 2022 16:40
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 11, 2022
cbracken pushed a commit to flutter/flutter that referenced this pull request May 11, 2022
sourcegraph-bot pushed a commit to sgtest/megarepo that referenced this pull request May 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants