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

Side by Side Diff: docs/clang.md

Issue 1309473002: WIP: Migrate Wiki content over to src/docs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « docs/chromoting_build_instructions.md ('k') | docs/clang_format.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 [Clang](http://clang.llvm.org/) is a compiler with many desirable features (outl ined on their website).
2
3 Chrome can be built with Clang. It is now the default compiler on Mac and Linux for building Chrome, and it is currently useful for its warning and error messa ges on Android and Windows.
4
5 See [the open bugs](http://code.google.com/p/chromium/issues/list?q=label:clang) .
6
7 ## Build instructions
8
9 Get clang (happens automatically during `gclient runhooks` on Mac and Linux):
10 ```
11 tools/clang/scripts/update.sh
12 ```
13
14 (Only needs to be run once per checkout, and clang will be automatically updated by `gclient runhooks`.)
15
16 ### Reverting to gcc on linux
17
18 We don't have bots that test this, but building with gcc4.8+ should still work o n Linux. If your system gcc is new enough, use this to build with gcc if you don 't want to build with clang:
19
20 ```
21 GYP_DEFINES=clang=0 build/gyp_chromium
22 ```
23
24 ### Ninja
25
26 Regenerate the build files (`clang=1` is on by default on Mac and Linux):
27
28 If you use gyp:
29 ```
30 GYP_DEFINES=clang=1 build/gyp_chromium
31 ```
32
33 If you use gn, run `gn args` and add `is_clang = true` to your args.gn file.
34
35 Build:
36 ```
37 ninja -C out/Debug chrome
38 ```
39
40 ## Mailing List
41 http://groups.google.com/a/chromium.org/group/clang/topics
42
43 ## Using plugins
44
45 The [chromium style plugin](http://dev.chromium.org/developers/coding-style/chro mium-style-checker-errors) is used by default when clang is used.
46
47 If you're working on the plugin, you can build it locally like so:
48
49 1. Run `./tools/clang/scripts/update.sh --force-local-build --without-android` to build the plugin.
50 1. Build with clang like described above.
51
52 To run [other plugins](WritingClangPlugins.md), add these to your `GYP_DEFINES`:
53
54 * `clang_load`: Absolute path to a dynamic library containing your plugin
55 * `clang_add_plugin`: tells clang to run a specific PluginASTAction
56
57 So for example, you could use the plugin in this directory with:
58
59 * `GYP_DEFINES='clang=1 clang_load=/path/to/libFindBadConstructs.so clang_add_ plugin=find-bad-constructs' gclient runhooks`
60
61 ## Using the clang static analyzer
62
63 See ClangStaticAnalyzer.
64
65 ## Windows
66
67 **Experimental!**
68
69 clang can be used as compiler on Windows. Clang uses Visual Studio's linker and SDK, so you still need to have Visual Studio installed.
70
71 Things should compile, and all tests should pass. You can check these bots for h ow things are currently looking: http://build.chromium.org/p/chromium.fyi/consol e?category=win%20clang
72
73 ```
74 python tools\clang\scripts\update.py
75 set GYP_DEFINES=clang=1
76 python build\gyp_chromium
77 # or, if you use gn, run `gn args` and add `is_clang = true` to your args.gn
78 ninja -C out\Debug chrome
79 ```
80
81 Current brokenness:
82
83 * Goma doesn't work.
84 * Debug info is very limited.
85 * To get colored diagnostics, you need to be running [ansicon](https://github. com/adoxa/ansicon/releases).
86
87 ## Using a custom clang binary
88
89 If you want to try building Chromium with your own clang binary that you've alre ady built, set `make_clang_dir` to the directory containing `bin/clang` (i.e. th e directory you ran cmake in, or your `Release+Asserts` folder if you use the co nfigure/make build). You also need to disable chromium's clang plugin by setting `clang_use_chrome_plugins=0`, as it likely won't load in your custom clang bina ry.
90
91 Here's an example that also disables debug info and enables the component build (both not strictly necessary, but they will speed up your build):
92
93 ```
94 GYP_DEFINES="clang=1 fastbuild=1 component=shared_library clang_use_chrome_plugi ns=0 make_clang_dir=$HOME/src/llvm-build" build/gyp_chromium
95 ```
96
97 You can then run `head out/Release/build.ninja` and check that the first to line s set `cc` and `cxx` to your clang binary. If things look good, run `ninja -C ou t/Release` to build.
98
99 If your clang revision is very different from the one currently used in chromium – check tools/clang/scripts/update.sh to find chromium's clang revision – you m ight have to tweak warning flags. Or you could set `werror=` in the line above t o disable warnings as errors (but this only works on Linux).
OLDNEW
« no previous file with comments | « docs/chromoting_build_instructions.md ('k') | docs/clang_format.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698