Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /chromium /src /refs/heads/main /. /docs /clang.md
blob: 1f3a9761b3f91f626c554b0a10f15e6b84bf9572 [file] [log] [blame] [view]
andybons6eaa0c0d2015-08-26 20:12:52[diff] [blame]1# Clang
andybons3322f762015-08-24 21:37:09[diff] [blame]2
Nico Weberb1617012019-09-06 18:20:32[diff] [blame]3Chromium ships a prebuilt[clang](http://clang.llvm.org) binary.
4It's just upstream clang built at a known-good revision that we
5bump every two weeks or so.
andybons3322f762015-08-24 21:37:09[diff] [blame]6
Nico Weberb1617012019-09-06 18:20:32[diff] [blame]7This is the only supported compiler for building Chromium.
andybons6eaa0c0d2015-08-26 20:12:52[diff] [blame]8
9[TOC]
andybons3322f762015-08-24 21:37:09[diff] [blame]10
Nico Weberb1617012019-09-06 18:20:32[diff] [blame]11## Using gcc on Linux
andybons3322f762015-08-24 21:37:09[diff] [blame]12
Nico Weberb1617012019-09-06 18:20:32[diff] [blame]13`is_clang = false` will make the build use system gcc on Linux. There are no
14bots that test this and there is no guarantee it will work, but we accept
15patches for this configuration.
rnkc052ba32016-04-13 21:13:00[diff] [blame]16
andybons3322f762015-08-24 21:37:09[diff] [blame]17## Mailing List
andybons6eaa0c0d2015-08-26 20:12:52[diff] [blame]18
xiaoyin.l1003c0b2016-12-06 02:51:17[diff] [blame]19https://groups.google.com/a/chromium.org/group/clang/topics
andybons3322f762015-08-24 21:37:09[diff] [blame]20
21## Using plugins
22
andybons6eaa0c0d2015-08-26 20:12:52[diff] [blame]23The
xiaoyin.l1003c0b2016-12-06 02:51:17[diff] [blame]24[chromium style plugin](https://dev.chromium.org/developers/coding-style/chromium-style-checker-errors)
andybons6eaa0c0d2015-08-26 20:12:52[diff] [blame]25is used by default when clang is used.
andybons3322f762015-08-24 21:37:09[diff] [blame]26
27If you're working on the plugin, you can build it locally like so:
28
Will Cassellaee180272021-12-03 18:16:21[diff] [blame]291.Run`./tools/clang/scripts/build.py --without-android --without-fuchsia`
andybons6eaa0c0d2015-08-26 20:12:52[diff] [blame]30 to build the plugin.
Tom Sepez7b8dfca2025-02-19 19:36:38[diff] [blame]311.Run`ninja -C third_party/llvm-build/Release+Asserts/` to build
32 incrementally after making changes.
331.Run`(cd tools/clang/plugins/tests && ./test.py ../../../../third_party/llvm-build/Release+Asserts/bin/clang)`
34 to test the plugin after making changes.
351.BuildChromiumwith clangas usual, but,if youuse reclient, disable it.
jyasskin37110bc2015-12-04 03:40:24[diff] [blame]36
Tom Sepez07b77e62025-05-05 17:41:52[diff] [blame]37Thelocal plugin willthen be usedforlocal buildsuntil thenext
38`gclient sync` restores thedefault toolchain.
39
Daniel Cheng7174602d2018-03-29 20:49:14[diff] [blame]40Since the pluginis rolledwith clang changes, behavior changes to the plugin
Tom Sepez07b77e62025-05-05 17:41:52[diff] [blame]41should be guardedby flags to make it easy to roll clang without introducing
42unexpected breakage. A general outline:
431.Implementnew plugin behavior behind a flag, disabledbydefault.
Daniel Cheng7174602d2018-03-29 20:49:14[diff] [blame]441.Waitfor a compiler roll to bringin the flag.
451.Start passing thenew flagin`GN`and verify thenew behavior.
461.Enable thenew plugin behavior unconditionallyand update the plugin to
47 ignore the flag.
481.Waitfor another compiler roll.
491.Stop passing the flagfrom`GN`.
501.Remove the flag completely.
51
andybons3322f762015-08-24 21:37:09[diff] [blame]52## Using the clang static analyzer
53
kirillbobyreveed2584d2015-11-02 14:38:29[diff] [blame]54See[clang_static_analyzer.md](clang_static_analyzer.md).
andybons3322f762015-08-24 21:37:09[diff] [blame]55
56## Windows
57
Nico Weberb1617012019-09-06 18:20:32[diff] [blame]58clangis thedefault compiler onWindows.It uses MSVC's SDK, so you still need
59to have Visual Studio with C++ support installed.
andybons3322f762015-08-24 21:37:09[diff] [blame]60
61## Using a custom clang binary
62
thakis2a46c2d12016-11-29 22:41:38[diff] [blame]63Set `clang_base_path` in your args.gn to the llvm build directory containing
Nico Weber8699c0562019-09-06 19:05:56[diff] [blame]64`bin/clang` (i.e. the directory you ran cmake). This must be an absolute
thakis2a46c2d12016-11-29 22:41:38[diff] [blame]65path. You also need to disable chromium's clang plugin.
andybons3322f762015-08-24 21:37:09[diff] [blame]66
andybons6eaa0c0d2015-08-26 20:12:52[diff] [blame]67Here's an example that also disables debug info and enables the component build
68(both not strictly necessary, but they will speed up your build):
andybons3322f762015-08-24 21:37:09[diff] [blame]69
thakis2a46c2d12016-11-29 22:41:38[diff] [blame]70```
71clang_base_path = getenv("HOME") + "/src/llvm-build"
72clang_use_chrome_plugins = false
73is_debug = false
74symbol_level = 1
75is_component_build = true
andybons3322f762015-08-24 21:37:09[diff] [blame]76```
77
Nico Weberd9b4f452019-10-09 17:58:16[diff] [blame]78On Windows, for `clang_base_path` use something like this instead:
79
80```
81clang_base_path = "c:/src/llvm-build"
82```
83
Lei Zhang4906c17c2021-05-12 11:31:01[diff] [blame]84You can then look in `out/gn/toolchain.ninja` and check that the `rule cc` and
85`rule cxx` commands run your clang binary. If things look good, run `ninja
thakis2a46c2d12016-11-29 22:41:38[diff] [blame]86-C out/gn` to build.
andybons3322f762015-08-24 21:37:09[diff] [blame]87
Nico Weber14735122019-08-12 13:39:05[diff] [blame]88Chromium tries to be buildable with its currently pinned clang, and with clang
89trunk. Set `llvm_force_head_revision = true` in your args.gn if the clang you're
90trying to buildwithis closer to clang trunk than toChromium's pinned clang
91(which `tools/clang/scripts/update.py --print-revision` prints).
Nico Weber46a1d77a2020-12-07 14:39:13[diff] [blame]92
93## Related documents
94
95* [Toolchain support](toolchain_support.md) gives an overview of clang
96 rolls, and documents when to revert clang rolls and how to file good
97 toolchain bugs.
98
99* [Updating clang](updating_clang.md) documents the mechanics of updating clang,
100 and which files are included in the default clang package.
101
102* [Clang Sheriffing](clang_sheriffing.md) contains instructions for how to debug
103 compiler bugs, for clang sheriffs.
Nico Weber6a992f32021-11-30 17:48:26[diff] [blame]104
105* [Clang Tool Refactoring](clang_tool_refactoring.md) has notes on how to build
106 and run refactoring tools based on clang's libraries.
Hans Wennborg4eeedf792025-01-17 14:00:23[diff] [blame]107
108*[UpdatingClang format binaries](updating_clang_format_binaries.md) has notes
109 on how to update clang-format.

[8]ページ先頭

©2009-2025 Movatter.jp