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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 If you use gyp: `GYP_DEFINES=clang=1 build/gyp_chromium` | 27 If you use gyp: `GYP_DEFINES=clang=1 build/gyp_chromium` |
28 | 28 |
29 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. |
30 | 30 |
31 Build: `ninja -C out/Debug chrome` | 31 Build: `ninja -C out/Debug chrome` |
32 | 32 |
33 ## Reverting to gcc on linux | 33 ## Reverting to gcc on linux |
34 | 34 |
35 We don't have bots that test this, but building with gcc4.8+ should still work | 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 | 36 on Linux. If your system gcc is new enough, run `gn args` and add `is_clang = |
37 don't want to build with clang: | 37 false`. |
38 | |
39 GYP_DEFINES=clang=0 build/gyp_chromium | |
40 | 38 |
41 ## Mailing List | 39 ## Mailing List |
42 | 40 |
43 http://groups.google.com/a/chromium.org/group/clang/topics | 41 http://groups.google.com/a/chromium.org/group/clang/topics |
44 | 42 |
45 ## Using plugins | 43 ## Using plugins |
46 | 44 |
47 The | 45 The |
48 [chromium style plugin](http://dev.chromium.org/developers/coding-style/chromium
-style-checker-errors) | 46 [chromium style plugin](http://dev.chromium.org/developers/coding-style/chromium
-style-checker-errors) |
49 is used by default when clang is used. | 47 is used by default when clang is used. |
50 | 48 |
51 If you're working on the plugin, you can build it locally like so: | 49 If you're working on the plugin, you can build it locally like so: |
52 | 50 |
53 1. Run `./tools/clang/scripts/update.py --force-local-build --without-android` | 51 1. Run `./tools/clang/scripts/update.py --force-local-build --without-android` |
54 to build the plugin. | 52 to build the plugin. |
55 1. Run `ninja -C third_party/llvm-build/Release+Asserts/` to build incrementall
y. | 53 1. Run `ninja -C third_party/llvm-build/Release+Asserts/` to build incrementall
y. |
56 1. Build with clang like described above, but, if you use goma, disable it. | 54 1. Build with clang like described above, but, if you use goma, disable it. |
57 | 55 |
58 To test the FindBadConstructs plugin, run: | 56 To test the FindBadConstructs plugin, run: |
59 | 57 |
60 (cd tools/clang/plugins/tests && \ | 58 (cd tools/clang/plugins/tests && \ |
61 ./test.py ../../../../third_party/llvm-build/Release+Asserts/bin/clang \ | 59 ./test.py ../../../../third_party/llvm-build/Release+Asserts/bin/clang \ |
62 ../../../../third_party/llvm-build/Release+Asserts/lib/libFindBad
Constructs.so) | 60 ../../../../third_party/llvm-build/Release+Asserts/lib/libFindBad
Constructs.so) |
63 | 61 |
64 To run [other plugins](writing_clang_plugins.md), add these to your | 62 To run [other plugins](writing_clang_plugins.md), add these to your |
65 `GYP_DEFINES`: | 63 `GYP_DEFINES` (this is not currently set up in GN): |
66 | 64 |
67 * `clang_load`: Absolute path to a dynamic library containing your plugin | 65 * `clang_load`: Absolute path to a dynamic library containing your plugin |
68 * `clang_add_plugin`: tells clang to run a specific PluginASTAction | 66 * `clang_add_plugin`: tells clang to run a specific PluginASTAction |
69 | 67 |
70 So for example, you could use the plugin in this directory with: | 68 So for example, you could use the plugin in this directory with: |
71 | 69 |
72 * `GYP_DEFINES='clang=1 clang_load=/path/to/libFindBadConstructs.so | 70 * `GYP_DEFINES='clang=1 clang_load=/path/to/libFindBadConstructs.so |
73 clang_add_plugin=find-bad-constructs' gclient runhooks` | 71 clang_add_plugin=find-bad-constructs' gclient runhooks` |
74 | 72 |
75 ## Using the clang static analyzer | 73 ## Using the clang static analyzer |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 **Experimental!** | 134 **Experimental!** |
137 | 135 |
138 LLD is a relatively new linker from LLVM. The current focus is on Windows and | 136 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 | 137 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 | 138 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. | 139 files, which makes it hard to debug Chrome while using LLD. |
142 | 140 |
143 If you use gyp, you can enable it with `GYP_DEFINES=lld=1`. If you use gn, set | 141 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 | 142 `use_lld = true` in args.gn. Currently this configuration is only supported on |
145 Windows. | 143 Windows. |
OLD | NEW |