OLD | NEW |
---|---|
1 # Clang | 1 # Clang |
2 | 2 |
3 [Clang](http://clang.llvm.org/) is a compiler with many desirable features | 3 [Clang](http://clang.llvm.org/) is a compiler with many desirable features |
4 (outlined on their website). | 4 (outlined on their website). |
5 | 5 |
6 Chrome can be built with Clang. It is now the default compiler on Mac and Linux | 6 Chrome can be built with Clang. It is now the default compiler on Mac and Linux |
7 for building Chrome, and it is currently useful for its warning and error | 7 for building Chrome, and it is currently useful for its warning and error |
8 messages on Android and Windows. | 8 messages on Android and Windows. |
9 | 9 |
10 See | 10 See |
11 [the open bugs](http://code.google.com/p/chromium/issues/list?q=label:clang). | 11 [the open bugs](http://code.google.com/p/chromium/issues/list?q=label:clang). |
12 | 12 |
13 [TOC] | 13 [TOC] |
14 | 14 |
15 ## Build instructions | 15 ## Build instructions |
16 | 16 |
17 Get clang (happens automatically during `gclient runhooks` on Mac and Linux): | 17 ### Ninja |
Nico
2016/04/13 00:50:14
(we can probably drop this heading too; all platfo
| |
18 | 18 |
19 tools/clang/scripts/update.py | 19 Regenerate the ninja build files with Clang enabled. On Linux or Mac, Clang is |
20 enabled by default. | |
20 | 21 |
21 (Only needs to be run once per checkout, and clang will be automatically updated | 22 If you use gyp: `GYP_DEFINES=clang=1 build/gyp_chromium` |
22 by `gclient runhooks`.) | 23 |
24 If you use gn, run `gn args` and add `is_clang = true` to your args.gn file. | |
25 | |
26 Build: `ninja -C out/Debug chrome` | |
23 | 27 |
24 ### Reverting to gcc on linux | 28 ### Reverting to gcc on linux |
25 | 29 |
26 We don't have bots that test this, but building with gcc4.8+ should still work | 30 We don't have bots that test this, but building with gcc4.8+ should still work |
27 on Linux. If your system gcc is new enough, use this to build with gcc if you | 31 on Linux. If your system gcc is new enough, use this to build with gcc if you |
28 don't want to build with clang: | 32 don't want to build with clang: |
29 | 33 |
30 GYP_DEFINES=clang=0 build/gyp_chromium | 34 GYP_DEFINES=clang=0 build/gyp_chromium |
31 | 35 |
32 ### Ninja | |
33 | |
34 Regenerate the build files (`clang=1` is on by default on Mac and Linux): | |
35 | |
36 If you use gyp: `GYP_DEFINES=clang=1 build/gyp_chromium` | |
37 | |
38 If you use gn, run `gn args` and add `is_clang = true` to your args.gn file. | |
39 | |
40 Build: `ninja -C out/Debug chrome` | |
41 | |
42 ## Mailing List | 36 ## Mailing List |
43 | 37 |
44 http://groups.google.com/a/chromium.org/group/clang/topics | 38 http://groups.google.com/a/chromium.org/group/clang/topics |
45 | 39 |
46 ## Using plugins | 40 ## Using plugins |
47 | 41 |
48 The | 42 The |
49 [chromium style plugin](http://dev.chromium.org/developers/coding-style/chromium -style-checker-errors) | 43 [chromium style plugin](http://dev.chromium.org/developers/coding-style/chromium -style-checker-errors) |
50 is used by default when clang is used. | 44 is used by default when clang is used. |
51 | 45 |
(...skipping 20 matching lines...) Expand all Loading... | |
72 | 66 |
73 * `GYP_DEFINES='clang=1 clang_load=/path/to/libFindBadConstructs.so | 67 * `GYP_DEFINES='clang=1 clang_load=/path/to/libFindBadConstructs.so |
74 clang_add_plugin=find-bad-constructs' gclient runhooks` | 68 clang_add_plugin=find-bad-constructs' gclient runhooks` |
75 | 69 |
76 ## Using the clang static analyzer | 70 ## Using the clang static analyzer |
77 | 71 |
78 See [clang_static_analyzer.md](clang_static_analyzer.md). | 72 See [clang_static_analyzer.md](clang_static_analyzer.md). |
79 | 73 |
80 ## Windows | 74 ## Windows |
81 | 75 |
82 **Experimental!** | |
83 | |
84 clang can be used as compiler on Windows. Clang uses Visual Studio's linker and | 76 clang can be used as compiler on Windows. Clang uses Visual Studio's linker and |
85 SDK, so you still need to have Visual Studio installed. | 77 SDK, so you still need to have Visual Studio installed. |
86 | 78 |
87 Things should compile, and all tests should pass. You can check these bots for | 79 Things should compile, and all tests should pass. You can check these bots for |
88 how things are currently looking: | 80 how things are currently looking: |
89 http://build.chromium.org/p/chromium.fyi/console?category=win%20clang | 81 http://build.chromium.org/p/chromium.fyi/console?category=win%20clang |
90 | 82 |
91 ``` shell | 83 ``` shell |
92 python tools\clang\scripts\update.py | 84 python tools\clang\scripts\update.py |
93 set GYP_DEFINES=clang=1 | 85 set GYP_DEFINES=clang=1 |
94 python build\gyp_chromium | 86 python build\gyp_chromium |
95 | 87 |
96 # or, if you use gn, run `gn args` and add `is_clang = true` to your args.gn | 88 # or, if you use gn, run `gn args` and add `is_clang = true` to your args.gn |
97 ninja -C out\Debug chrome | 89 ninja -C out\Debug chrome |
98 ``` | 90 ``` |
99 | 91 |
Nico
2016/04/13 00:50:14
mention somewhere here that update.py only needs t
Reid Kleckner
2016/04/13 18:11:47
What about simplifying this to `gclient runhooks`
Nico
2016/04/13 18:13:58
It's not enough in a gn build, since runhooks call
| |
100 Current brokenness: | 92 Current brokenness: |
101 | 93 |
102 * Goma doesn't work. | |
103 * Debug info is very limited. | 94 * Debug info is very limited. |
104 * To get colored diagnostics, you need to be running | 95 * To get colored diagnostics, you need to be running |
105 [ansicon](https://github.com/adoxa/ansicon/releases). | 96 [ansicon](https://github.com/adoxa/ansicon/releases). |
106 | 97 |
107 ## Using a custom clang binary | 98 ## Using a custom clang binary |
108 | 99 |
109 If you want to try building Chromium with your own clang binary that you've | 100 If you want to try building Chromium with your own clang binary that you've |
110 already built, set `make_clang_dir` to the directory containing `bin/clang` | 101 already built, set `make_clang_dir` to the directory containing `bin/clang` |
111 (i.e. the directory you ran cmake in, or your `Release+Asserts` folder if you | 102 (i.e. the directory you ran cmake in, or your `Release+Asserts` folder if you |
112 use the configure/make build). You also need to disable chromium's clang plugin | 103 use the configure/make build). You also need to disable chromium's clang plugin |
(...skipping 11 matching lines...) Expand all Loading... | |
124 | 115 |
125 You can then run `head out/Release/build.ninja` and check that the first to | 116 You can then run `head out/Release/build.ninja` and check that the first to |
126 lines set `cc` and `cxx` to your clang binary. If things look good, run `ninja | 117 lines set `cc` and `cxx` to your clang binary. If things look good, run `ninja |
127 -C out/Release` to build. | 118 -C out/Release` to build. |
128 | 119 |
129 If your clang revision is very different from the one currently used in chromium | 120 If your clang revision is very different from the one currently used in chromium |
130 | 121 |
131 * Check `tools/clang/scripts/update.py` to find chromium's clang revision | 122 * Check `tools/clang/scripts/update.py` to find chromium's clang revision |
132 * You might have to tweak warning flags. Or you could set `werror=` in the | 123 * You might have to tweak warning flags. Or you could set `werror=` in the |
133 line above to disable warnings as errors (but this only works on Linux). | 124 line above to disable warnings as errors (but this only works on Linux). |
125 | |
126 ## Using LLD | |
127 | |
128 **Experimental!** | |
129 | |
130 LLD is a relatively new linker from LLVM. The current focus is on Windows and | |
131 Linux support, where it can link Chrome approximately twice as fast as gold and | |
132 MSVC's link.exe as of this writing. LLD does not yet support generating PDB | |
133 files, which makes it hard to debug Chrome while using LLD. | |
134 | |
135 If you use gyp, you can enable it with `GYP_DEFINES=lld=1`. If you use gn, set | |
136 `use_lld = true` in args.gn. Currently this configuration is only supported on | |
137 Windows. | |
OLD | NEW |