Chromium ships a prebuilt clang binary. It's just upstream clang built at a known-good revision that we bump every two weeks or so.
This is the only supported compiler for building Chromium.
is_clang = false
will make the build use system gcc on Linux. There are no bots that test this and there is no guarantee it will work, but we accept patches for this configuration.
https://groups.google.com/a/chromium.org/group/clang/topics
The chromium style plugin is used by default when clang is used.
If you're working on the plugin, you can build it locally like so:
./tools/clang/scripts/build.py --without-android
to build the plugin.ninja -C third_party/llvm-build/Release+Asserts/
to build incrementally.To test the FindBadConstructs plugin, run:
(cd tools/clang/plugins/tests && \ ./test.py ../../../../third_party/llvm-build/Release+Asserts/bin/clang \ ../../../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so)
Since the plugin is rolled with clang changes, behavior changes to the plugin should be guarded by flags to make it easy to roll clang. A general outline:
GN
and verify the new behavior.GN
.clang is the default compiler on Windows. It uses MSVC's SDK, so you still need to have Visual Studio with C++ support installed.
Set clang_base_path
in your args.gn to the llvm build directory containing bin/clang
(i.e. the directory you ran cmake). This must be an absolute path. You also need to disable chromium's clang plugin.
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):
clang_base_path = getenv("HOME") + "/src/llvm-build" clang_use_chrome_plugins = false is_debug = false symbol_level = 1 is_component_build = true
On Windows, for clang_base_path
use something like this instead:
clang_base_path = "c:/src/llvm-build"
You can then run head out/gn/toolchain.ninja
and check that the first to lines set cc
and cxx
to your clang binary. If things look good, run ninja -C out/gn
to build.
Chromium tries to be buildable with its currently pinned clang, and with clang trunk. Set llvm_force_head_revision = true
in your args.gn if the clang you‘re trying to build with is closer to clang trunk than to Chromium’s pinned clang (which tools/clang/scripts/update.py --print-revision
prints).