Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 1 | # Cross-compiling Chrome/win |
| 2 | |
Darwin Huang | fa70c7a | 2019-03-27 21:59:02 | [diff] [blame] | 3 | As many Chromium developers are on Linux/Mac, cross-compiling Chromium for |
| 4 | Windows targets facilitates development for Windows targets on non-Windows |
| 5 | machines. |
| 6 | |
Nico Weber | ce96b470 | 2017-12-14 18:52:31 | [diff] [blame] | 7 | It's possible to build most parts of the codebase on a Linux or Mac host while |
Darwin Huang | fa70c7a | 2019-03-27 21:59:02 | [diff] [blame] | 8 | targeting Windows. It's also possible to run the locally-built binaries on |
| 9 | swarming. This document describes how to set that up, and current restrictions. |
| 10 | |
| 11 | ## Limitations |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 12 | |
| 13 | What does *not* work: |
| 14 | |
Nico Weber | 3a54e6f | 2019-10-02 19:58:52 | [diff] [blame^] | 15 | * `js2gtest` tests are omitted from the build ([bug](https://crbug.com/1010561)) |
| 16 | * on Mac hosts, 32-bit builds don't use V8 snapshots |
Nico Weber | 705836c | 2019-03-26 17:18:15 | [diff] [blame] | 17 | ([bug](https://crbug.com/794838) has more information, but this is unlikely |
| 18 | to ever change) |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 19 | |
Nico Weber | 495e955 | 2017-10-23 20:03:07 | [diff] [blame] | 20 | All other targets build fine (including `chrome`, `browser_tests`, ...). |
| 21 | |
Nico Weber | 705836c | 2019-03-26 17:18:15 | [diff] [blame] | 22 | Uses of `.asm` files have been stubbed out. As a result, Crashpad cannot |
| 23 | report crashes, and NaCl defaults to disabled and cannot be enabled in cross |
| 24 | builds ([.asm bug](https://crbug.com/762167)). |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 25 | |
| 26 | ## .gclient setup |
| 27 | |
| 28 | 1. Tell gclient that you need Windows build dependencies by adding |
| 29 | `target_os = ['win']` to the end of your `.gclient`. (If you already |
Lei Zhang | 4d34c1fb | 2017-10-23 22:29:37 | [diff] [blame] | 30 | have a `target_os` line in there, just add `'win'` to the list.) e.g. |
| 31 | |
| 32 | solutions = [ |
| 33 | { |
| 34 | ... |
| 35 | } |
| 36 | ] |
| 37 | target_os = ['android', 'win'] |
| 38 | |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 39 | 1. `gclient sync`, follow instructions on screen. |
| 40 | |
| 41 | If you're at Google, this will automatically download the Windows SDK for you. |
Hans Wennborg | c6d904c | 2018-06-25 14:07:29 | [diff] [blame] | 42 | If this fails with an error: |
| 43 | |
| 44 | Please follow the instructions at |
| 45 | https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md |
| 46 | |
Tom Sepez | 3e3f0ceda | 2017-10-23 21:18:02 | [diff] [blame] | 47 | then you may need to re-authenticate via: |
| 48 | |
| 49 | cd path/to/chrome/src |
| 50 | # Follow instructions, enter 0 as project id. |
| 51 | download_from_google_storage --config |
| 52 | |
Hans Wennborg | c6d904c | 2018-06-25 14:07:29 | [diff] [blame] | 53 | If you are not at Google, you can package your Windows SDK installation |
| 54 | into a zip file by running the following on a Windows machine: |
Henrique Ferreiro | a5be472 | 2018-06-25 11:49:45 | [diff] [blame] | 55 | |
| 56 | cd path/to/depot_tools/win_toolchain |
| 57 | # customize the Windows SDK version numbers |
| 58 | python package_from_installed.py 2017 -w 10.0.17134.0 |
| 59 | |
Hans Wennborg | c6d904c | 2018-06-25 14:07:29 | [diff] [blame] | 60 | These commands create a zip file named `<hash value>.zip`. Then, to use the |
Henrique Ferreiro | a5be472 | 2018-06-25 11:49:45 | [diff] [blame] | 61 | generated file in a Linux or Mac host, the following environment variables |
| 62 | need to be set: |
| 63 | |
| 64 | export DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL=<path/to/sdk/zip/file> |
Henrique Ferreiro | 37b2a54 | 2018-07-30 12:19:54 | [diff] [blame] | 65 | export GYP_MSVS_HASH_<toolchain hash>=<hash value> |
Henrique Ferreiro | a5be472 | 2018-06-25 11:49:45 | [diff] [blame] | 66 | |
Hans Wennborg | 900b6ac5 | 2018-06-25 14:42:00 | [diff] [blame] | 67 | `<toolchain hash>` is hardcoded in `src/build/vs_toolchain.py` and can be found by |
Henrique Ferreiro | a5be472 | 2018-06-25 11:49:45 | [diff] [blame] | 68 | setting `DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL` and running `gclient sync`: |
| 69 | |
| 70 | gclient sync |
| 71 | ... |
| 72 | Running hooks: 17% (11/64) win_toolchain |
| 73 | ________ running '/usr/bin/python src/build/vs_toolchain.py update --force' in <chromium dir> |
| 74 | Windows toolchain out of date or doesn't exist, updating (Pro)... |
| 75 | current_hashes: |
| 76 | desired_hash: <toolchain hash> |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 77 | |
Nico Weber | a001bab | 2017-10-23 20:11:10 | [diff] [blame] | 78 | ## GN setup |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 79 | |
| 80 | Add `target_os = "win"` to your args.gn. Then just build, e.g. |
| 81 | |
| 82 | ninja -C out/gnwin base_unittests.exe |
| 83 | |
Tom Anderson | 497ff623 | 2019-02-20 21:11:41 | [diff] [blame] | 84 | ## Goma |
| 85 | |
| 86 | For now, one needs to use the rbe backend, not the (default) borg backend: |
| 87 | |
| 88 | goma_auth.py login |
Fumitoshi Ukai | d3423e7 | 2019-03-22 06:53:36 | [diff] [blame] | 89 | GOMA_SERVER_HOST=rbe-staging1.endpoints.cxx-compiler-service.cloud.goog goma_ctl.py ensure_start |
Tom Anderson | 497ff623 | 2019-02-20 21:11:41 | [diff] [blame] | 90 | |
Nico Weber | 1f05f16 | 2018-01-22 19:06:42 | [diff] [blame] | 91 | ## Copying and running chrome |
| 92 | |
| 93 | A convenient way to copy chrome over to a Windows box is to build the |
| 94 | `mini_installer` target. Then, copy just `mini_installer.exe` over |
| 95 | to the Windows box and run it to install the chrome you just built. |
| 96 | |
kylechar | 78c9077c | 2019-06-06 14:49:34 | [diff] [blame] | 97 | Note that the `mini_installer` doesn't include PDB files. PDB files are needed |
| 98 | to correctly symbolize stack traces (or if you want to attach a debugger). |
| 99 | |
Nico Weber | a001bab | 2017-10-23 20:11:10 | [diff] [blame] | 100 | ## Running tests on swarming |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 101 | |
| 102 | You can run the Windows binaries you built on swarming, like so: |
| 103 | |
Elly Fong-Jones | 23e2b71 | 2019-09-06 18:14:58 | [diff] [blame] | 104 | tools/run-swarmed.py out/gnwin base_unittests [ --gtest_filter=... ] |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 105 | |
Hans Wennborg | f3adf863 | 2018-03-26 10:27:09 | [diff] [blame] | 106 | See the contents of run-swarmed.py for how to do this manually. |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 107 | |
Hans Wennborg | c6d904c | 2018-06-25 14:07:29 | [diff] [blame] | 108 | The |
Yves Gerey | a702f622 | 2019-01-24 11:07:30 | [diff] [blame] | 109 | [linux-win_cross-rel](https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/linux-win_cross-rel/) |
Hans Wennborg | c6d904c | 2018-06-25 14:07:29 | [diff] [blame] | 110 | buildbot does 64-bit release cross builds, and also runs tests. You can look at |
| 111 | it to get an idea of which tests pass in the cross build. |