Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: docs/clang.md

Issue 1881283002: Update Chromium docs on using clang (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 Get clang (happens automatically during `gclient runhooks` on Mac and Linux):
18 18
19 tools/clang/scripts/update.py 19 tools/clang/scripts/update.py
20 20
21 (Only needs to be run once per checkout, and clang will be automatically updated 21 Only needs to be run once per checkout, and clang will be automatically updated
22 by `gclient runhooks`.) 22 by `gclient runhooks`.
23 23
24 ### Reverting to gcc on linux 24 Regenerate the ninja build files with Clang enabled. Again, on Linux and Mac,
25 25 Clang is the default compiler.
26 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
28 don't want to build with clang:
29
30 GYP_DEFINES=clang=0 build/gyp_chromium
31
32 ### Ninja
33
34 Regenerate the build files (`clang=1` is on by default on Mac and Linux):
35 26
36 If you use gyp: `GYP_DEFINES=clang=1 build/gyp_chromium` 27 If you use gyp: `GYP_DEFINES=clang=1 build/gyp_chromium`
37 28
38 If you use gn, run `gn args` and add `is_clang = true` to your args.gn file. 29 If you use gn, run `gn args` and add `is_clang = true` to your args.gn file.
39 30
40 Build: `ninja -C out/Debug chrome` 31 Build: `ninja -C out/Debug chrome`
41 32
33 ## Reverting to gcc on linux
34
35 We don't have bots that test this, but building with gcc4.8+ should still work
36 on Linux. If your system gcc is new enough, use this to build with gcc if you
37 don't want to build with clang:
38
39 GYP_DEFINES=clang=0 build/gyp_chromium
40
42 ## Mailing List 41 ## Mailing List
43 42
44 http://groups.google.com/a/chromium.org/group/clang/topics 43 http://groups.google.com/a/chromium.org/group/clang/topics
45 44
46 ## Using plugins 45 ## Using plugins
47 46
48 The 47 The
49 [chromium style plugin](http://dev.chromium.org/developers/coding-style/chromium -style-checker-errors) 48 [chromium style plugin](http://dev.chromium.org/developers/coding-style/chromium -style-checker-errors)
50 is used by default when clang is used. 49 is used by default when clang is used.
51 50
(...skipping 20 matching lines...) Expand all
72 71
73 * `GYP_DEFINES='clang=1 clang_load=/path/to/libFindBadConstructs.so 72 * `GYP_DEFINES='clang=1 clang_load=/path/to/libFindBadConstructs.so
74 clang_add_plugin=find-bad-constructs' gclient runhooks` 73 clang_add_plugin=find-bad-constructs' gclient runhooks`
75 74
76 ## Using the clang static analyzer 75 ## Using the clang static analyzer
77 76
78 See [clang_static_analyzer.md](clang_static_analyzer.md). 77 See [clang_static_analyzer.md](clang_static_analyzer.md).
79 78
80 ## Windows 79 ## Windows
81 80
82 **Experimental!**
83
84 clang can be used as compiler on Windows. Clang uses Visual Studio's linker and 81 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. 82 SDK, so you still need to have Visual Studio installed.
86 83
87 Things should compile, and all tests should pass. You can check these bots for 84 Things should compile, and all tests should pass. You can check these bots for
88 how things are currently looking: 85 how things are currently looking:
89 http://build.chromium.org/p/chromium.fyi/console?category=win%20clang 86 http://build.chromium.org/p/chromium.fyi/console?category=win%20clang
90 87
91 ``` shell 88 ``` shell
92 python tools\clang\scripts\update.py 89 python tools\clang\scripts\update.py
93 set GYP_DEFINES=clang=1 90 set GYP_DEFINES=clang=1
94 python build\gyp_chromium 91 python build\gyp_chromium
95 92
96 # or, if you use gn, run `gn args` and add `is_clang = true` to your args.gn 93 # or, if you use gn, run `gn args` and add `is_clang = true` to your args.gn
97 ninja -C out\Debug chrome 94 ninja -C out\Debug chrome
98 ``` 95 ```
99 96
97 The `update.py` script only needs to be run once per checkout. Clang will be
98 kept up-to-date by `gclient runhooks`.
99
100 Current brokenness: 100 Current brokenness:
101 101
102 * Goma doesn't work.
103 * Debug info is very limited. 102 * Debug info is very limited.
104 * To get colored diagnostics, you need to be running 103 * To get colored diagnostics, you need to be running
105 [ansicon](https://github.com/adoxa/ansicon/releases). 104 [ansicon](https://github.com/adoxa/ansicon/releases).
106 105
107 ## Using a custom clang binary 106 ## Using a custom clang binary
108 107
109 If you want to try building Chromium with your own clang binary that you've 108 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` 109 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 110 (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 111 use the configure/make build). You also need to disable chromium's clang plugin
(...skipping 11 matching lines...) Expand all
124 123
125 You can then run `head out/Release/build.ninja` and check that the first to 124 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 125 lines set `cc` and `cxx` to your clang binary. If things look good, run `ninja
127 -C out/Release` to build. 126 -C out/Release` to build.
128 127
129 If your clang revision is very different from the one currently used in chromium 128 If your clang revision is very different from the one currently used in chromium
130 129
131 * Check `tools/clang/scripts/update.py` to find chromium's clang revision 130 * 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 131 * 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). 132 line above to disable warnings as errors (but this only works on Linux).
133
134 ## Using LLD
135
136 **Experimental!**
137
138 LLD is a relatively new linker from LLVM. The current focus is on Windows and
139 Linux support, where it can link Chrome approximately twice as fast as gold and
140 MSVC's link.exe as of this writing. LLD does not yet support generating PDB
141 files, which makes it hard to debug Chrome while using LLD.
142
143 If you use gyp, you can enable it with `GYP_DEFINES=lld=1`. If you use gn, set
144 `use_lld = true` in args.gn. Currently this configuration is only supported on
145 Windows.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698