blob: a83d493212f6bb37c65b3ab1c7514e34bf5494f8 [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))
Hans Wennborg193ddf42019-10-07 14:14:3516* 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 Weberbf97a6d12017-10-13 17:40:0218
Nico Weber495e9552017-10-23 20:03:0719All other targets build fine (including `chrome`, `browser_tests`, ...).
20
Nico Weber705836c2019-03-26 17:18:1521Uses of `.asm` files have been stubbed out. As a result, Crashpad cannot
22report crashes, and NaCl defaults to disabled and cannot be enabled in cross
23builds ([.asm bug](https://crbug.com/762167)).
Nico Weberbf97a6d12017-10-13 17:40:0224
25## .gclient setup
26
271. Tell gclient that you need Windows build dependencies by adding
28 `target_os = ['win']` to the end of your `.gclient`. (If you already
Lei Zhang4d34c1fb2017-10-23 22:29:3729 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 Weberbf97a6d12017-10-13 17:40:02381. `gclient sync`, follow instructions on screen.
39
Nigel Taoc77ad1b2021-03-17 23:54:0340### If you're at Google
41
42`gclient sync` should automatically download the Windows SDK for you. If this
43fails with an error:
Hans Wennborgc6d904c2018-06-25 14:07:2944
45 Please follow the instructions at
Wan-Teh Changccad232a2020-12-07 23:35:1646 https://chromium.googlesource.com/chromium/src/+/HEAD/docs/win_cross.md
Hans Wennborgc6d904c2018-06-25 14:07:2947
Tom Sepez3e3f0ceda2017-10-23 21:18:0248then 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 Taoc77ad1b2021-03-17 23:54:0354`gclient sync` should now succeed. Skip ahead to the [GN setup](#gn-setup)
55section.
56
57### If you're not at Google
58
FrΓ©dΓ©ric Wangee66b892021-11-24 09:22:2859After installing [Microsoft's development tools](windows_build_instructions.md#visual-studio),
60you can package your Windows SDK installation into a zip file by running the following on a Windows machine:
Henrique Ferreiroa5be4722018-06-25 11:49:4561
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 Wennborgc6d904c2018-06-25 14:07:2966These commands create a zip file named `<hash value>.zip`. Then, to use the
Henrique Ferreiroa5be4722018-06-25 11:49:4567generated file in a Linux or Mac host, the following environment variables
68need to be set:
69
70 export DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL=<path/to/sdk/zip/file>
Henrique Ferreiro37b2a542018-07-30 12:19:5471 export GYP_MSVS_HASH_<toolchain hash>=<hash value>
Henrique Ferreiroa5be4722018-06-25 11:49:4572
Hans Wennborg900b6ac52018-06-25 14:42:0073`<toolchain hash>` is hardcoded in `src/build/vs_toolchain.py` and can be found by
Henrique Ferreiroa5be4722018-06-25 11:49:4574setting `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 Weberbf97a6d12017-10-13 17:40:0283
Nico Webera001bab2017-10-23 20:11:1084## GN setup
Nico Weberbf97a6d12017-10-13 17:40:0285
86Add `target_os = "win"` to your args.gn. Then just build, e.g.
87
88 ninja -C out/gnwin base_unittests.exe
89
Tom Anderson497ff6232019-02-20 21:11:4190## Goma
91
Fumitoshi Ukai50efdea2021-03-14 23:23:4792This should be supported by the default (Goma RBE) backend.
Fumitoshi Ukaic2856df2019-11-29 03:06:4293
Nico Weber1f05f162018-01-22 19:06:4294## Copying and running chrome
95
96A 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
98to the Windows box and run it to install the chrome you just built.
99
kylechar78c9077c2019-06-06 14:49:34100Note that the `mini_installer` doesn't include PDB files. PDB files are needed
101to correctly symbolize stack traces (or if you want to attach a debugger).
102
Nico Webera001bab2017-10-23 20:11:10103## Running tests on swarming
Nico Weberbf97a6d12017-10-13 17:40:02104
105You can run the Windows binaries you built on swarming, like so:
106
Henrique Nakashima14cfed592021-11-10 19:35:07107 tools/run-swarmed.py out/gnwin base_unittests -- [ --gtest_filter=... ]
Nico Weberbf97a6d12017-10-13 17:40:02108
Hans Wennborgf3adf8632018-03-26 10:27:09109See the contents of run-swarmed.py for how to do this manually.
Nico Weberbf97a6d12017-10-13 17:40:02110
Hans Wennborgc6d904c2018-06-25 14:07:29111The
Yves Gereya702f6222019-01-24 11:07:30112[linux-win_cross-rel](https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/linux-win_cross-rel/)
Hans Wennborgc6d904c2018-06-25 14:07:29113buildbot does 64-bit release cross builds, and also runs tests. You can look at
114it to get an idea of which tests pass in the cross build.