summaryrefslogtreecommitdiffstats
path: root/docs/clang.md
diff options
context:
space:
mode:
authorandybons <andybons@chromium.org>2015-08-26 13:12:52 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-26 20:13:51 +0000
commit6eaa0c0d0154e824a99267abb24bd536b7bacae1 (patch)
treeea9fdb22795549c5beecd28d078cef47e477ef56 /docs/clang.md
parent00d111c262fc3bc3b0354ef747bb714c109634fa (diff)
downloadchromium_src-6eaa0c0d0154e824a99267abb24bd536b7bacae1.zip
chromium_src-6eaa0c0d0154e824a99267abb24bd536b7bacae1.tar.gz
chromium_src-6eaa0c0d0154e824a99267abb24bd536b7bacae1.tar.bz2
Markdown style fixes for:
code_coverage.md cocoa_tips_and_tricks.md closure_compilation.md clang_format.md clang_tool_refactoring.md clang.md R=nodir BUG=524256 Review URL: https://codereview.chromium.org/1306233003 Cr-Commit-Position: refs/heads/master@{#345652}
Diffstat (limited to 'docs/clang.md')
-rw-r--r--docs/clang.md106
1 files changed, 67 insertions, 39 deletions
diff --git a/docs/clang.md b/docs/clang.md
index 4840fca..72a0727 100644
--- a/docs/clang.md
+++ b/docs/clang.md
@@ -1,99 +1,127 @@
-[Clang](http://clang.llvm.org/) is a compiler with many desirable features (outlined on their website).
+# Clang
-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 messages on Android and Windows.
+[Clang](http://clang.llvm.org/) is a compiler with many desirable features
+(outlined on their website).
-See [the open bugs](http://code.google.com/p/chromium/issues/list?q=label:clang).
+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
+messages on Android and Windows.
+
+See
+[the open bugs](http://code.google.com/p/chromium/issues/list?q=label:clang).
+
+[TOC]
## Build instructions
Get clang (happens automatically during `gclient runhooks` on Mac and Linux):
-```
-tools/clang/scripts/update.sh
-```
-(Only needs to be run once per checkout, and clang will be automatically updated by `gclient runhooks`.)
+ tools/clang/scripts/update.sh
+
+(Only needs to be run once per checkout, and clang will be automatically updated
+by `gclient runhooks`.)
### Reverting to gcc on linux
-We don't have bots that test this, but building with gcc4.8+ should still work on Linux. If your system gcc is new enough, use this to build with gcc if you don't want to build with clang:
+We don't have bots that test this, but building with gcc4.8+ should still work
+on Linux. If your system gcc is new enough, use this to build with gcc if you
+don't want to build with clang:
-```
-GYP_DEFINES=clang=0 build/gyp_chromium
-```
+ GYP_DEFINES=clang=0 build/gyp_chromium
### Ninja
Regenerate the build files (`clang=1` is on by default on Mac and Linux):
-If you use gyp:
-```
-GYP_DEFINES=clang=1 build/gyp_chromium
-```
+If you use gyp: `GYP_DEFINES=clang=1 build/gyp_chromium`
If you use gn, run `gn args` and add `is_clang = true` to your args.gn file.
-Build:
-```
-ninja -C out/Debug chrome
-```
+Build: `ninja -C out/Debug chrome`
## Mailing List
+
http://groups.google.com/a/chromium.org/group/clang/topics
## Using plugins
-The [chromium style plugin](http://dev.chromium.org/developers/coding-style/chromium-style-checker-errors) is used by default when clang is used.
+The
+[chromium style plugin](http://dev.chromium.org/developers/coding-style/chromium-style-checker-errors)
+is used by default when clang is used.
If you're working on the plugin, you can build it locally like so:
- 1. Run `./tools/clang/scripts/update.sh --force-local-build --without-android` to build the plugin.
- 1. Build with clang like described above.
+1. Run `./tools/clang/scripts/update.sh --force-local-build --without-android`
+ to build the plugin.
+1. Build with clang like described above.
-To run [other plugins](WritingClangPlugins.md), add these to your `GYP_DEFINES`:
+TODO: writing_clang_plugins does not exist.
+To run [other plugins](writing_clang_plugins.md), add these to your
+`GYP_DEFINES`:
- * `clang_load`: Absolute path to a dynamic library containing your plugin
- * `clang_add_plugin`: tells clang to run a specific PluginASTAction
+* `clang_load`: Absolute path to a dynamic library containing your plugin
+* `clang_add_plugin`: tells clang to run a specific PluginASTAction
So for example, you could use the plugin in this directory with:
- * `GYP_DEFINES='clang=1 clang_load=/path/to/libFindBadConstructs.so clang_add_plugin=find-bad-constructs' gclient runhooks`
+* `GYP_DEFINES='clang=1 clang_load=/path/to/libFindBadConstructs.so
+ clang_add_plugin=find-bad-constructs' gclient runhooks`
## Using the clang static analyzer
-See ClangStaticAnalyzer.
+See [clang_static_analyser.md](clang_static_analyser.md).
## Windows
**Experimental!**
-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.
+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.
-Things should compile, and all tests should pass. You can check these bots for how things are currently looking: http://build.chromium.org/p/chromium.fyi/console?category=win%20clang
+Things should compile, and all tests should pass. You can check these bots for
+how things are currently looking:
+http://build.chromium.org/p/chromium.fyi/console?category=win%20clang
-```
+``` shell
python tools\clang\scripts\update.py
set GYP_DEFINES=clang=1
python build\gyp_chromium
+
# or, if you use gn, run `gn args` and add `is_clang = true` to your args.gn
ninja -C out\Debug chrome
```
Current brokenness:
- * Goma doesn't work.
- * Debug info is very limited.
- * To get colored diagnostics, you need to be running [ansicon](https://github.com/adoxa/ansicon/releases).
+* Goma doesn't work.
+* Debug info is very limited.
+* To get colored diagnostics, you need to be running
+ [ansicon](https://github.com/adoxa/ansicon/releases).
## Using a custom clang binary
-If you want to try building Chromium with your own clang binary that you've already built, set `make_clang_dir` to the directory containing `bin/clang` (i.e. the directory you ran cmake in, or your `Release+Asserts` folder if you use the configure/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 binary.
+If you want to try building Chromium with your own clang binary that you've
+already built, set `make_clang_dir` to the directory containing `bin/clang`
+(i.e. the directory you ran cmake in, or your `Release+Asserts` folder if you
+use the configure/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 binary.
-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):
+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):
+```shell
+GYP_DEFINES="clang=1 fastbuild=1 component=shared_library \
+clang_use_chrome_plugins=0 make_clang_dir=$HOME/src/llvm-build" \
+build/gyp_chromium
```
-GYP_DEFINES="clang=1 fastbuild=1 component=shared_library clang_use_chrome_plugins=0 make_clang_dir=$HOME/src/llvm-build" build/gyp_chromium
-```
-You can then run `head out/Release/build.ninja` and check that the first to lines set `cc` and `cxx` to your clang binary. If things look good, run `ninja -C out/Release` to build.
+You can then run `head out/Release/build.ninja` and check that the first to
+lines set `cc` and `cxx` to your clang binary. If things look good, run `ninja
+-C out/Release` to build.
+
+If your clang revision is very different from the one currently used in chromium
-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 might have to tweak warning flags. Or you could set `werror=` in the line above to disable warnings as errors (but this only works on Linux). \ No newline at end of file
+* Check `tools/clang/scripts/update.sh` to find chromium's clang revision
+* You might have to tweak warning flags. Or you could set `werror=` in the
+ line above to disable warnings as errors (but this only works on Linux).