Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 1 | # Cross-compiling Chrome/win |
| 2 | |
Nico Weber | ce96b470 | 2017-12-14 18:52:31 | [diff] [blame] | 3 | It's possible to build most parts of the codebase on a Linux or Mac host while |
| 4 | targeting Windows. This document describes how to set that up, and current |
| 5 | restrictions. |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 6 | |
| 7 | What does *not* work: |
| 8 | |
Takashi Toyoshima | 0dab2f0 | 2017-10-31 09:10:58 | [diff] [blame] | 9 | * goma. Sorry. ([internal bug](http://b/64390790)) You can use the |
Nico Weber | 495e955 | 2017-10-23 20:03:07 | [diff] [blame] | 10 | [jumbo build](jumbo.md) for faster build times. |
Nico Weber | 1f05f16 | 2018-01-22 19:06:42 | [diff] [blame^] | 11 | * renderer processes crash at startup ([bug](https://crbug.com/803591)) |
Nico Weber | ce96b470 | 2017-12-14 18:52:31 | [diff] [blame] | 12 | * on Mac hosts, building a 32-bit chrome ([bug](https://crbug.com/794838)) |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 13 | |
Nico Weber | 495e955 | 2017-10-23 20:03:07 | [diff] [blame] | 14 | All other targets build fine (including `chrome`, `browser_tests`, ...). |
| 15 | |
Lei Zhang | 4d34c1fb | 2017-10-23 22:29:37 | [diff] [blame] | 16 | Uses of `.asm` files have been stubbed out. As a result, some of Skia's |
| 17 | software rendering paths are not present in cross builds, Crashpad cannot |
Nico Weber | 495e955 | 2017-10-23 20:03:07 | [diff] [blame] | 18 | report crashes, and NaCl defaults to disabled and cannot be enabled in |
Nico Weber | a3a4b22 | 2017-10-23 20:08:45 | [diff] [blame] | 19 | cross builds ([.asm bug](https://crbug.com/762167)). |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 20 | |
| 21 | ## .gclient setup |
| 22 | |
| 23 | 1. Tell gclient that you need Windows build dependencies by adding |
| 24 | `target_os = ['win']` to the end of your `.gclient`. (If you already |
Lei Zhang | 4d34c1fb | 2017-10-23 22:29:37 | [diff] [blame] | 25 | have a `target_os` line in there, just add `'win'` to the list.) e.g. |
| 26 | |
| 27 | solutions = [ |
| 28 | { |
| 29 | ... |
| 30 | } |
| 31 | ] |
| 32 | target_os = ['android', 'win'] |
| 33 | |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 34 | 1. `gclient sync`, follow instructions on screen. |
| 35 | |
| 36 | If you're at Google, this will automatically download the Windows SDK for you. |
Tom Sepez | 3e3f0ceda | 2017-10-23 21:18:02 | [diff] [blame] | 37 | If this fails with an error: Please follow the instructions at |
| 38 | https://www.chromium.org/developers/how-tos/build-instructions-windows |
| 39 | then you may need to re-authenticate via: |
| 40 | |
| 41 | cd path/to/chrome/src |
| 42 | # Follow instructions, enter 0 as project id. |
| 43 | download_from_google_storage --config |
| 44 | |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 45 | If you are not at Google, you'll have to figure out how to get the SDK, and |
| 46 | you'll need to put a JSON file describing the SDK layout in a certain location. |
| 47 | |
Nico Weber | a001bab | 2017-10-23 20:11:10 | [diff] [blame] | 48 | ## GN setup |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 49 | |
| 50 | Add `target_os = "win"` to your args.gn. Then just build, e.g. |
| 51 | |
| 52 | ninja -C out/gnwin base_unittests.exe |
| 53 | |
Nico Weber | 1f05f16 | 2018-01-22 19:06:42 | [diff] [blame^] | 54 | ## Copying and running chrome |
| 55 | |
| 56 | A convenient way to copy chrome over to a Windows box is to build the |
| 57 | `mini_installer` target. Then, copy just `mini_installer.exe` over |
| 58 | to the Windows box and run it to install the chrome you just built. |
| 59 | |
Nico Weber | a001bab | 2017-10-23 20:11:10 | [diff] [blame] | 60 | ## Running tests on swarming |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 61 | |
| 62 | You can run the Windows binaries you built on swarming, like so: |
| 63 | |
| 64 | tools/mb/mb.py isolate //out/gnwin base_unittests |
| 65 | tools/swarming_client/isolate.py archive \ |
| 66 | -I https://isolateserver.appspot.com \ |
| 67 | -i out/gnwin/base_unittests.isolate \ |
| 68 | -s out/gnwin/base_unittests.isolated |
| 69 | tools/swarming_client/swarming.py trigger \ |
| 70 | -S https://chromium-swarm.appspot.com \ |
| 71 | -I https://isolateserver.appspot.com \ |
| 72 | -d os Windows -d pool Chrome -s <hash printed by previous command> |
Ali Tofigh | dc1376e | 2017-10-30 16:44:57 | [diff] [blame] | 73 | [ -- <flag to target process, for example --gtest_filter>... ] |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 74 | |
| 75 | Most tests that build should pass. However, the cross build uses |
| 76 | the lld linker, and a couple of tests fail when using lld. You can look at |
| 77 | https://build.chromium.org/p/chromium.clang/builders/CrWinClangLLD%20tester |
| 78 | to get an idea of which tests fail with lld. |
| 79 | |
| 80 | TODO(thakis): It'd be nice if there was a script for doing this. Maybe make |
| 81 | tools/fuchsa/run-swarmed.py work for win cross builds too, or create |
| 82 | `run_base_unittests` script targets during the build (like Android). |