blob: 61d24400a2897eee0ef804894792d2e6fc5b41ab [file] [log] [blame] [view]
Nico Weberbf97a6d12017-10-13 17:40:021# Cross-compiling Chrome/win
2
Darwin Huangfa70c7a2019-03-27 21:59:023As many Chromium developers are on Linux/Mac, cross-compiling Chromium for
4Windows targets facilitates development for Windows targets on non-Windows
5machines.
6
Nico Weberce96b4702017-12-14 18:52:317It's possible to build most parts of the codebase on a Linux or Mac host while
Darwin Huangfa70c7a2019-03-27 21:59:028targeting Windows. It's also possible to run the locally-built binaries on
9swarming. This document describes how to set that up, and current restrictions.
10
11## Limitations
Nico Weberbf97a6d12017-10-13 17:40:0212
13What does *not* work:
14
Nico Weber3a54e6f2019-10-02 19:58:5215* `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 Weber705836c2019-03-26 17:18:1517 ([bug](https://crbug.com/794838) has more information, but this is unlikely
18 to ever change)
Nico Weberbf97a6d12017-10-13 17:40:0219
Nico Weber495e9552017-10-23 20:03:0720All other targets build fine (including `chrome`, `browser_tests`, ...).
21
Nico Weber705836c2019-03-26 17:18:1522Uses of `.asm` files have been stubbed out. As a result, Crashpad cannot
23report crashes, and NaCl defaults to disabled and cannot be enabled in cross
24builds ([.asm bug](https://crbug.com/762167)).
Nico Weberbf97a6d12017-10-13 17:40:0225
26## .gclient setup
27
281. Tell gclient that you need Windows build dependencies by adding
29 `target_os = ['win']` to the end of your `.gclient`. (If you already
Lei Zhang4d34c1fb2017-10-23 22:29:3730 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 Weberbf97a6d12017-10-13 17:40:02391. `gclient sync`, follow instructions on screen.
40
41If you're at Google, this will automatically download the Windows SDK for you.
Hans Wennborgc6d904c2018-06-25 14:07:2942If 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 Sepez3e3f0ceda2017-10-23 21:18:0247then 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 Wennborgc6d904c2018-06-25 14:07:2953If you are not at Google, you can package your Windows SDK installation
54into a zip file by running the following on a Windows machine:
Henrique Ferreiroa5be4722018-06-25 11:49:4555
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 Wennborgc6d904c2018-06-25 14:07:2960These commands create a zip file named `<hash value>.zip`. Then, to use the
Henrique Ferreiroa5be4722018-06-25 11:49:4561generated file in a Linux or Mac host, the following environment variables
62need to be set:
63
64 export DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL=<path/to/sdk/zip/file>
Henrique Ferreiro37b2a542018-07-30 12:19:5465 export GYP_MSVS_HASH_<toolchain hash>=<hash value>
Henrique Ferreiroa5be4722018-06-25 11:49:4566
Hans Wennborg900b6ac52018-06-25 14:42:0067`<toolchain hash>` is hardcoded in `src/build/vs_toolchain.py` and can be found by
Henrique Ferreiroa5be4722018-06-25 11:49:4568setting `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 Weberbf97a6d12017-10-13 17:40:0277
Nico Webera001bab2017-10-23 20:11:1078## GN setup
Nico Weberbf97a6d12017-10-13 17:40:0279
80Add `target_os = "win"` to your args.gn. Then just build, e.g.
81
82 ninja -C out/gnwin base_unittests.exe
83
Tom Anderson497ff6232019-02-20 21:11:4184## Goma
85
86For now, one needs to use the rbe backend, not the (default) borg backend:
87
88 goma_auth.py login
Fumitoshi Ukaid3423e72019-03-22 06:53:3689 GOMA_SERVER_HOST=rbe-staging1.endpoints.cxx-compiler-service.cloud.goog goma_ctl.py ensure_start
Tom Anderson497ff6232019-02-20 21:11:4190
Nico Weber1f05f162018-01-22 19:06:4291## Copying and running chrome
92
93A 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
95to the Windows box and run it to install the chrome you just built.
96
kylechar78c9077c2019-06-06 14:49:3497Note that the `mini_installer` doesn't include PDB files. PDB files are needed
98to correctly symbolize stack traces (or if you want to attach a debugger).
99
Nico Webera001bab2017-10-23 20:11:10100## Running tests on swarming
Nico Weberbf97a6d12017-10-13 17:40:02101
102You can run the Windows binaries you built on swarming, like so:
103
Elly Fong-Jones23e2b712019-09-06 18:14:58104 tools/run-swarmed.py out/gnwin base_unittests [ --gtest_filter=... ]
Nico Weberbf97a6d12017-10-13 17:40:02105
Hans Wennborgf3adf8632018-03-26 10:27:09106See the contents of run-swarmed.py for how to do this manually.
Nico Weberbf97a6d12017-10-13 17:40:02107
Hans Wennborgc6d904c2018-06-25 14:07:29108The
Yves Gereya702f6222019-01-24 11:07:30109[linux-win_cross-rel](https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/linux-win_cross-rel/)
Hans Wennborgc6d904c2018-06-25 14:07:29110buildbot does 64-bit release cross builds, and also runs tests. You can look at
111it to get an idea of which tests pass in the cross build.