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)) |
Hans Wennborg | 193ddf4 | 2019-10-07 14:14:35 | [diff] [blame] | 16 | * on Mac hosts, 32-bit builds don't work ([bug](https://crbug.com/794838) has |
| 17 | more information, and this is unlikely to ever change) |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 18 | |
Nico Weber | 495e955 | 2017-10-23 20:03:07 | [diff] [blame] | 19 | All other targets build fine (including `chrome`, `browser_tests`, ...). |
| 20 | |
Nico Weber | 705836c | 2019-03-26 17:18:15 | [diff] [blame] | 21 | Uses of `.asm` files have been stubbed out. As a result, Crashpad cannot |
| 22 | report crashes, and NaCl defaults to disabled and cannot be enabled in cross |
| 23 | builds ([.asm bug](https://crbug.com/762167)). |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 24 | |
| 25 | ## .gclient setup |
| 26 | |
| 27 | 1. Tell gclient that you need Windows build dependencies by adding |
| 28 | `target_os = ['win']` to the end of your `.gclient`. (If you already |
Lei Zhang | 4d34c1fb | 2017-10-23 22:29:37 | [diff] [blame] | 29 | have a `target_os` line in there, just add `'win'` to the list.) e.g. |
| 30 | |
| 31 | solutions = [ |
| 32 | { |
| 33 | ... |
| 34 | } |
| 35 | ] |
| 36 | target_os = ['android', 'win'] |
| 37 | |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 38 | 1. `gclient sync`, follow instructions on screen. |
| 39 | |
Nigel Tao | c77ad1b | 2021-03-17 23:54:03 | [diff] [blame] | 40 | ### If you're at Google |
| 41 | |
| 42 | `gclient sync` should automatically download the Windows SDK for you. If this |
| 43 | fails with an error: |
Hans Wennborg | c6d904c | 2018-06-25 14:07:29 | [diff] [blame] | 44 | |
| 45 | Please follow the instructions at |
Wan-Teh Chang | ccad232a | 2020-12-07 23:35:16 | [diff] [blame] | 46 | https://chromium.googlesource.com/chromium/src/+/HEAD/docs/win_cross.md |
Hans Wennborg | c6d904c | 2018-06-25 14:07:29 | [diff] [blame] | 47 | |
Tom Sepez | 3e3f0ceda | 2017-10-23 21:18:02 | [diff] [blame] | 48 | then you may need to re-authenticate via: |
| 49 | |
| 50 | cd path/to/chrome/src |
| 51 | # Follow instructions, enter 0 as project id. |
| 52 | download_from_google_storage --config |
| 53 | |
Nigel Tao | c77ad1b | 2021-03-17 23:54:03 | [diff] [blame] | 54 | `gclient sync` should now succeed. Skip ahead to the [GN setup](#gn-setup) |
| 55 | section. |
| 56 | |
| 57 | ### If you're not at Google |
| 58 | |
FrΓ©dΓ©ric Wang | ee66b89 | 2021-11-24 09:22:28 | [diff] [blame] | 59 | After installing [Microsoft's development tools](windows_build_instructions.md#visual-studio), |
| 60 | you can package your Windows SDK installation into a zip file by running the following on a Windows machine: |
Henrique Ferreiro | a5be472 | 2018-06-25 11:49:45 | [diff] [blame] | 61 | |
| 62 | cd path/to/depot_tools/win_toolchain |
| 63 | # customize the Windows SDK version numbers |
| 64 | python package_from_installed.py 2017 -w 10.0.17134.0 |
| 65 | |
Hans Wennborg | c6d904c | 2018-06-25 14:07:29 | [diff] [blame] | 66 | 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] | 67 | generated file in a Linux or Mac host, the following environment variables |
| 68 | need to be set: |
| 69 | |
| 70 | export DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL=<path/to/sdk/zip/file> |
Henrique Ferreiro | 37b2a54 | 2018-07-30 12:19:54 | [diff] [blame] | 71 | export GYP_MSVS_HASH_<toolchain hash>=<hash value> |
Henrique Ferreiro | a5be472 | 2018-06-25 11:49:45 | [diff] [blame] | 72 | |
Hans Wennborg | 900b6ac5 | 2018-06-25 14:42:00 | [diff] [blame] | 73 | `<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] | 74 | setting `DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL` and running `gclient sync`: |
| 75 | |
| 76 | gclient sync |
| 77 | ... |
| 78 | Running hooks: 17% (11/64) win_toolchain |
| 79 | ________ running '/usr/bin/python src/build/vs_toolchain.py update --force' in <chromium dir> |
| 80 | Windows toolchain out of date or doesn't exist, updating (Pro)... |
| 81 | current_hashes: |
| 82 | desired_hash: <toolchain hash> |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 83 | |
Nico Weber | a001bab | 2017-10-23 20:11:10 | [diff] [blame] | 84 | ## GN setup |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 85 | |
| 86 | Add `target_os = "win"` to your args.gn. Then just build, e.g. |
| 87 | |
| 88 | ninja -C out/gnwin base_unittests.exe |
| 89 | |
Tom Anderson | 497ff623 | 2019-02-20 21:11:41 | [diff] [blame] | 90 | ## Goma |
| 91 | |
Fumitoshi Ukai | 50efdea | 2021-03-14 23:23:47 | [diff] [blame] | 92 | This should be supported by the default (Goma RBE) backend. |
Fumitoshi Ukai | c2856df | 2019-11-29 03:06:42 | [diff] [blame] | 93 | |
Nico Weber | 1f05f16 | 2018-01-22 19:06:42 | [diff] [blame] | 94 | ## Copying and running chrome |
| 95 | |
| 96 | A convenient way to copy chrome over to a Windows box is to build the |
| 97 | `mini_installer` target. Then, copy just `mini_installer.exe` over |
| 98 | to the Windows box and run it to install the chrome you just built. |
| 99 | |
kylechar | 78c9077c | 2019-06-06 14:49:34 | [diff] [blame] | 100 | Note that the `mini_installer` doesn't include PDB files. PDB files are needed |
| 101 | to correctly symbolize stack traces (or if you want to attach a debugger). |
| 102 | |
Nico Weber | a001bab | 2017-10-23 20:11:10 | [diff] [blame] | 103 | ## Running tests on swarming |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 104 | |
| 105 | You can run the Windows binaries you built on swarming, like so: |
| 106 | |
Henrique Nakashima | 14cfed59 | 2021-11-10 19:35:07 | [diff] [blame] | 107 | tools/run-swarmed.py out/gnwin base_unittests -- [ --gtest_filter=... ] |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 108 | |
Hans Wennborg | f3adf863 | 2018-03-26 10:27:09 | [diff] [blame] | 109 | See the contents of run-swarmed.py for how to do this manually. |
Nico Weber | bf97a6d1 | 2017-10-13 17:40:02 | [diff] [blame] | 110 | |
Hans Wennborg | c6d904c | 2018-06-25 14:07:29 | [diff] [blame] | 111 | The |
Yves Gerey | a702f622 | 2019-01-24 11:07:30 | [diff] [blame] | 112 | [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] | 113 | buildbot does 64-bit release cross builds, and also runs tests. You can look at |
| 114 | it to get an idea of which tests pass in the cross build. |