blob: 678d4d416081456be6ef27ebdf9d99f5bab784cf [file] [log] [blame] [view]
Nico Weberbf97a6d12017-10-13 17:40:021# Cross-compiling Chrome/win
2
3It's possible to build parts of the codebase on a Linux (and soon, Mac) host
4while targeting Windows. This document describes how to set that up, and
5current restrictions.
6
7What does *not* work:
8
9* goma. Sorry. ([internal bug](b/64390790))
10* targets depending on crashpad ([bug](https://crbug.com/762167))
11* targets using .rc files ([bug](https://crbug.com/774193))
12* linking on Mac ([bug](https://crbug.com/774209)), should change soon
13
14This disqualifies most interesting targets for now, but a few smaller ones
15(`base_unittests`, ...) do work. Over time, more things should work.
16
17## .gclient setup
18
191. Tell gclient that you need Windows build dependencies by adding
20 `target_os = ['win']` to the end of your `.gclient`. (If you already
21 have a `target_os` line in there, just add `'win'` to the list.)
221. `gclient sync`, follow instructions on screen.
23
24If you're at Google, this will automatically download the Windows SDK for you.
25If you are not at Google, you'll have to figure out how to get the SDK, and
26you'll need to put a JSON file describing the SDK layout in a certain location.
27
28# GN setup
29
30Add `target_os = "win"` to your args.gn. Then just build, e.g.
31
32 ninja -C out/gnwin base_unittests.exe
33
34# Running tests on swarming
35
36You can run the Windows binaries you built on swarming, like so:
37
38 tools/mb/mb.py isolate //out/gnwin base_unittests
39 tools/swarming_client/isolate.py archive \
40 -I https://isolateserver.appspot.com \
41 -i out/gnwin/base_unittests.isolate \
42 -s out/gnwin/base_unittests.isolated
43 tools/swarming_client/swarming.py trigger \
44 -S https://chromium-swarm.appspot.com \
45 -I https://isolateserver.appspot.com \
46 -d os Windows -d pool Chrome -s <hash printed by previous command>
47
48Most tests that build should pass. However, the cross build uses
49the lld linker, and a couple of tests fail when using lld. You can look at
50https://build.chromium.org/p/chromium.clang/builders/CrWinClangLLD%20tester
51to get an idea of which tests fail with lld.
52
53TODO(thakis): It'd be nice if there was a script for doing this. Maybe make
54tools/fuchsa/run-swarmed.py work for win cross builds too, or create
55`run_base_unittests` script targets during the build (like Android).