blob: 5d79af7244d54dd31fbf097dfff845f0ae123d23 [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))
dpapad97205b3d2023-07-28 06:11:3916 Note that newer WebUI tests are not based on js2gtest
17 (see migration progress at [crbug.com/1457360](https://crbug.com/1457360)) and
18 are included in the build.
Hans Wennborg193ddf42019-10-07 14:14:3519* on Mac hosts, 32-bit builds don't work ([bug](https://crbug.com/794838) has
20 more information, and this is unlikely to ever change)
Nico Weberbf97a6d12017-10-13 17:40:0221
Nico Weber495e9552017-10-23 20:03:0722All other targets build fine (including `chrome`, `browser_tests`, ...).
23
Nico Weber705836c2019-03-26 17:18:1524Uses of `.asm` files have been stubbed out. As a result, Crashpad cannot
25report crashes, and NaCl defaults to disabled and cannot be enabled in cross
26builds ([.asm bug](https://crbug.com/762167)).
Nico Weberbf97a6d12017-10-13 17:40:0227
28## .gclient setup
29
301. Tell gclient that you need Windows build dependencies by adding
31 `target_os = ['win']` to the end of your `.gclient`. (If you already
Lei Zhang4d34c1fb2017-10-23 22:29:3732 have a `target_os` line in there, just add `'win'` to the list.) e.g.
33
34 solutions = [
35 {
36 ...
37 }
38 ]
39 target_os = ['android', 'win']
40
Nico Weberbf97a6d12017-10-13 17:40:02411. `gclient sync`, follow instructions on screen.
42
Nigel Taoc77ad1b2021-03-17 23:54:0343### If you're at Google
44
45`gclient sync` should automatically download the Windows SDK for you. If this
46fails with an error:
Hans Wennborgc6d904c2018-06-25 14:07:2947
48 Please follow the instructions at
Wan-Teh Changccad232a2020-12-07 23:35:1649 https://chromium.googlesource.com/chromium/src/+/HEAD/docs/win_cross.md
Hans Wennborgc6d904c2018-06-25 14:07:2950
Tom Sepez3e3f0ceda2017-10-23 21:18:0251then you may need to re-authenticate via:
52
53 cd path/to/chrome/src
54 # Follow instructions, enter 0 as project id.
55 download_from_google_storage --config
56
Nigel Taoc77ad1b2021-03-17 23:54:0357`gclient sync` should now succeed. Skip ahead to the [GN setup](#gn-setup)
58section.
59
60### If you're not at Google
61
Frédéric Wangee66b892021-11-24 09:22:2862After installing [Microsoft's development tools](windows_build_instructions.md#visual-studio),
63you can package your Windows SDK installation into a zip file by running the following on a Windows machine:
Henrique Ferreiroa5be4722018-06-25 11:49:4564
65 cd path/to/depot_tools/win_toolchain
Frédéric Wangb6034812021-11-24 11:29:2566 python package_from_installed.py <vs version> -w <win version>
67
68where `<vs version>` and `<win version>` correspond respectively to the
69versions of Visual Studio (e.g. 2019) and of the Windows SDK (e.g.
Henrique Ferreiro1a367a02022-02-09 12:59:227010.0.19041.0) installed on the Windows machine. Note that if you didn't
71install the ARM64 components of the SDK as noted in the link above, you
72should add `--noarm` to the parameter list.
Henrique Ferreiroa5be4722018-06-25 11:49:4573
Hans Wennborgc6d904c2018-06-25 14:07:2974These commands create a zip file named `<hash value>.zip`. Then, to use the
Henrique Ferreiroa5be4722018-06-25 11:49:4575generated file in a Linux or Mac host, the following environment variables
76need to be set:
77
Frédéric Wangb6034812021-11-24 11:29:2578 export DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL=<base url>
Henrique Ferreiro37b2a542018-07-30 12:19:5479 export GYP_MSVS_HASH_<toolchain hash>=<hash value>
Henrique Ferreiroa5be4722018-06-25 11:49:4580
Frédéric Wangb6034812021-11-24 11:29:2581`<base url>` is the path of the directory containing the zip file (note that
82specifying scheme `file://` is not required).
83
Hans Wennborg900b6ac52018-06-25 14:42:0084`<toolchain hash>` is hardcoded in `src/build/vs_toolchain.py` and can be found by
Henrique Ferreiroa5be4722018-06-25 11:49:4585setting `DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL` and running `gclient sync`:
86
87 gclient sync
88 ...
89 Running hooks: 17% (11/64) win_toolchain
90 ________ running '/usr/bin/python src/build/vs_toolchain.py update --force' in <chromium dir>
91 Windows toolchain out of date or doesn't exist, updating (Pro)...
92 current_hashes:
93 desired_hash: <toolchain hash>
Nico Weberbf97a6d12017-10-13 17:40:0294
Nico Webera001bab2017-10-23 20:11:1095## GN setup
Nico Weberbf97a6d12017-10-13 17:40:0296
Nico Webere9464b62022-03-15 11:06:5497Add
98
99 target_os = "win"
100
101to your args.gn.
102
103If you're building on an arm host (e.g. a Mac with an Apple Silicon chip),
104you very likely also want to add
105
106 target_cpu = "x64"
107
108lest you build an arm64 chrome/win binary.
109
110Then just build, e.g.
Nico Weberbf97a6d12017-10-13 17:40:02111
112 ninja -C out/gnwin base_unittests.exe
113
Tom Anderson497ff6232019-02-20 21:11:41114## Goma
115
Fumitoshi Ukai50efdea2021-03-14 23:23:47116This should be supported by the default (Goma RBE) backend.
Fumitoshi Ukaic2856df2019-11-29 03:06:42117
Nico Weber1f05f162018-01-22 19:06:42118## Copying and running chrome
119
120A convenient way to copy chrome over to a Windows box is to build the
121`mini_installer` target. Then, copy just `mini_installer.exe` over
122to the Windows box and run it to install the chrome you just built.
123
kylechar78c9077c2019-06-06 14:49:34124Note that the `mini_installer` doesn't include PDB files. PDB files are needed
125to correctly symbolize stack traces (or if you want to attach a debugger).
126
Nico Webera001bab2017-10-23 20:11:10127## Running tests on swarming
Nico Weberbf97a6d12017-10-13 17:40:02128
129You can run the Windows binaries you built on swarming, like so:
130
Henrique Nakashima14cfed592021-11-10 19:35:07131 tools/run-swarmed.py out/gnwin base_unittests -- [ --gtest_filter=... ]
Nico Weberbf97a6d12017-10-13 17:40:02132
Hans Wennborgf3adf8632018-03-26 10:27:09133See the contents of run-swarmed.py for how to do this manually.
Nico Weberbf97a6d12017-10-13 17:40:02134
Hans Wennborgc6d904c2018-06-25 14:07:29135The
Hans Wennborgcc6e2272023-06-09 12:52:30136[linux-win_cross-rel](https://ci.chromium.org/p/chromium/builders/ci/linux-win_cross-rel)
Hans Wennborgc6d904c2018-06-25 14:07:29137buildbot does 64-bit release cross builds, and also runs tests. You can look at
138it to get an idea of which tests pass in the cross build.