Avi Drissman | ab7729b | 2021-06-10 19:17:15 | [diff] [blame] | 1 | # Chromium for Arm Macs |
Nico Weber | a4ea04f6 | 2020-07-08 17:20:45 | [diff] [blame] | 2 | |
Nico Weber | f169d96 | 2021-05-16 13:21:26 | [diff] [blame] | 3 | This document describes the state of Chromium on Apple Silicon Macs. |
Nico Weber | d7c855c16 | 2022-04-08 15:28:40 | [diff] [blame] | 4 | The short summary is that almost everything works, without needing Rosetta. |
Nico Weber | a4ea04f6 | 2020-07-08 17:20:45 | [diff] [blame] | 5 | |
Nico Weber | 8014088 | 2022-01-05 19:24:55 | [diff] [blame] | 6 | There's a [main waterfall |
| 7 | bot](https://ci.chromium.org/p/chromium/builders/ci/mac-arm64-rel) |
Bruce Dawson | c266172 | 2024-06-12 19:44:29 | [diff] [blame] | 8 | that builds for Arm. It cross-builds on an x86-64 machine. |
Nico Weber | 6a0eef62c | 2020-09-19 00:33:07 | [diff] [blame] | 9 | |
Nico Weber | 8014088 | 2022-01-05 19:24:55 | [diff] [blame] | 10 | There's a [main waterfall |
| 11 | bot](https://ci.chromium.org/p/chromium/builders/ci/mac-arm64-on-arm64-rel) |
Nico Weber | d7c855c16 | 2022-04-08 15:28:40 | [diff] [blame] | 12 | that builds for Arm on an Arm bot as well. This bot does not have Rosetta |
| 13 | installed. |
Nico Weber | 8014088 | 2022-01-05 19:24:55 | [diff] [blame] | 14 | |
Nico Weber | 6a0eef62c | 2020-09-19 00:33:07 | [diff] [blame] | 15 | There's also a [tester |
Zhaoyang Li | 5d3713d | 2022-06-13 18:01:17 | [diff] [blame] | 16 | bot](https://ci.chromium.org/p/chromium/builders/ci/mac12-arm64-rel-tests) |
Nico Weber | d7c855c16 | 2022-04-08 15:28:40 | [diff] [blame] | 17 | that continuously runs tests. Most tests pass. The tester bots don't |
| 18 | have Rosetta installed. |
| 19 | |
| 20 | ASan builds do not yet work ([tracking bug](https://crbug.com/1271140)) |
Nico Weber | 6a0eef62c | 2020-09-19 00:33:07 | [diff] [blame] | 21 | |
Avi Drissman | ab7729b | 2021-06-10 19:17:15 | [diff] [blame] | 22 | ## Building _for_ Arm Macs |
Nico Weber | a4ea04f6 | 2020-07-08 17:20:45 | [diff] [blame] | 23 | |
Avi Drissman | ab7729b | 2021-06-10 19:17:15 | [diff] [blame] | 24 | If you are on an Intel Mac, all that's required to build Chromium for arm64 |
| 25 | is to add a `target_cpu = "arm64"` line to your `args.gn`. Then build normally. |
| 26 | If you are on an Arm Mac, your build will by default be an Arm build, though |
| 27 | please see the section below about building _on_ Arm Macs for specific things |
| 28 | to keep in mind. |
Nico Weber | a4ea04f6 | 2020-07-08 17:20:45 | [diff] [blame] | 29 | |
Avi Drissman | ab7729b | 2021-06-10 19:17:15 | [diff] [blame] | 30 | A note about copying a Chromium build to your Arm Mac. If you don't do a |
| 31 | component build (e.g. a regular `is_debug=false` build), you can just copy |
| 32 | over Chromium.app from your build directory. If you copy it using |
Nico Weber | 6a0eef62c | 2020-09-19 00:33:07 | [diff] [blame] | 33 | macOS's "Shared Folder" feature and Finder, Chromium.app should be directly |
| 34 | runnable. If you zip, upload Chromium.app to some web service and download |
Avi Drissman | ab7729b | 2021-06-10 19:17:15 | [diff] [blame] | 35 | it to an Arm Mac, browsers will set the `com.apple.quarantine` bit, which will |
| 36 | cause the Finder to say `"Chromium" is damanged and can't be opened. You should |
Nico Weber | 6a0eef62c | 2020-09-19 00:33:07 | [diff] [blame] | 37 | move it to the Trash."`. In Console.app, the kernel will log |
| 38 | `kernel: Security policy would not allow process: 2204, |
| 39 | /Users/you/Downloads/Chromium.app/Contents/MacOS/Chromium` and amfid will log |
| 40 | `amfid: /Users/you/Downloads/Chromium.app/Contents/MacOS/Chromium signature not |
| 41 | valid: -67050`. To fix this, open a terminal and run |
| 42 | |
| 43 | % cd ~/Downloads && xattr -rc Chromium.app |
| 44 | |
| 45 | After that, it should start fine. |
| 46 | |
| 47 | As an alternative to building locally, changes can be submitted to the opt-in |
Zhaoyang Li | 5d3713d | 2022-06-13 18:01:17 | [diff] [blame] | 48 | [mac12-arm64-rel |
| 49 | trybot](https://ci.chromium.org/p/chromium/builders/try/mac12-arm64-rel). A small |
Nico Weber | 6a0eef62c | 2020-09-19 00:33:07 | [diff] [blame] | 50 | number of [swarming bots](https://goto.corp.google.com/run-on-dtk) are also |
| 51 | available for Googlers to run tests on. |
| 52 | |
Avi Drissman | ab7729b | 2021-06-10 19:17:15 | [diff] [blame] | 53 | Arm Mac-specific bugs are tagged with the |
| 54 | [Mac-ARM64 label](https://crbug.com/?q=label%3Amac-arm64). |
Nico Weber | 6a0eef62c | 2020-09-19 00:33:07 | [diff] [blame] | 55 | |
Mark Mentovai | 33fa9d7 | 2020-11-12 16:13:24 | [diff] [blame] | 56 | ### Universal Builds |
| 57 | |
Nico Weber | a1acc7d | 2021-04-06 23:55:41 | [diff] [blame] | 58 | A “universal” (or “fat”) `.app` can be created from distinct x86\_64 and arm64 |
Mark Mentovai | 33fa9d7 | 2020-11-12 16:13:24 | [diff] [blame] | 59 | builds produced from the same source version. Chromium has a `universalizer.py` |
| 60 | tool that can then be used to merge the two builds into a single universal |
| 61 | `.app`. |
| 62 | |
| 63 | % ninja -C out/release_x86_64 chrome |
| 64 | % ninja -C out/release_arm64 chrome |
| 65 | % mkdir out/release_universal |
| 66 | % chrome/installer/mac/universalizer.py \ |
| 67 | out/release_x86_64/Chromium.app \ |
| 68 | out/release_arm64/Chromium.app \ |
| 69 | out/release_universal/Chromium.app |
| 70 | |
| 71 | The universal build is produced in this way rather than having a single |
| 72 | all-encompassing `gn` configuration because: |
| 73 | |
| 74 | - Chromium builds tend to take a long time, even maximizing the parallelism |
| 75 | capabilities of a single machine. This split allows an additional dimension |
Nico Weber | a1acc7d | 2021-04-06 23:55:41 | [diff] [blame] | 76 | of parallelism by delegating the x86\_64 and arm64 build tasks to different |
Mark Mentovai | 33fa9d7 | 2020-11-12 16:13:24 | [diff] [blame] | 77 | machines. |
Nico Weber | a1acc7d | 2021-04-06 23:55:41 | [diff] [blame] | 78 | - During the mac-arm64 bring-up, the x86\_64 and arm64 versions were built |
| 79 | using different SDK and toolchain versions. When using the hermetic SDK and |
Mark Mentovai | 33fa9d7 | 2020-11-12 16:13:24 | [diff] [blame] | 80 | toolchain, a single version of this package must be shared by an entire |
| 81 | source tree, because it’s managed by `gclient`, not `gn`. However, as of |
| 82 | November 2020, Chromium builds for the two architectures converged and are |
| 83 | expected to remain on the same version indefinitely, so this is now more of a |
| 84 | historical artifact. |
| 85 | |
| 86 | ## Building _on_ arm Macs |
Nico Weber | a4ea04f6 | 2020-07-08 17:20:45 | [diff] [blame] | 87 | |
Nico Weber | 8014088 | 2022-01-05 19:24:55 | [diff] [blame] | 88 | It's possible to build _on_ an arm Mac, without Rosetta. This |
| 89 | configuration is covered by a [main waterfall |
| 90 | bot](https://ci.chromium.org/p/chromium/builders/ci/mac-arm64-on-arm64-rel). |
Nico Weber | a4ea04f6 | 2020-07-08 17:20:45 | [diff] [blame] | 91 | |
Takuto Ikuta | 7478af72 | 2024-05-27 07:23:19 | [diff] [blame] | 92 | Checking out and building (with reclient too) should just work. |
Nico Weber | f169d96 | 2021-05-16 13:21:26 | [diff] [blame] | 93 | You should be able to run `fetch chromium` normally, and then build, using |
| 94 | `gn`, `ninja` etc like normal. |
Nico Weber | a1acc7d | 2021-04-06 23:55:41 | [diff] [blame] | 95 | |
Nico Weber | 8014088 | 2022-01-05 19:24:55 | [diff] [blame] | 96 | Building Chrome/Mac/Intel on an arm Mac currently needs a small local tweak |
| 97 | to work, see [tracking bug](https://crbug.com/1280968). |
| 98 | |
Nico Weber | d7c855c16 | 2022-04-08 15:28:40 | [diff] [blame] | 99 | All tests should build, run, and mostly pass. |