blob: 5fcaa96208b105c1ab0877cf3083bb590f1d4e40 [file] [log] [blame] [view]
nodir06cbaa02015-08-25 17:15:241# Updating Clang format binaries
andybons3322f762015-08-24 21:37:092
nodir06cbaa02015-08-25 17:15:243Instructions on how to update the [clang-format binaries](clang_format.md) that
4come with a checkout of Chromium.
andybons3322f762015-08-24 21:37:095
nodir06cbaa02015-08-25 17:15:246## Prerequisites
andybons3322f762015-08-24 21:37:097
nodir06cbaa02015-08-25 17:15:248You'll need a Windows machine, a Linux machine, and a Mac; all capable of
9building clang-format. You'll also need permissions to upload to the appropriate
10google storage bucket. Chromium infrastructure team members have this, and
11others can be granted the permission based on need. Talk to ncarter or hinoka
12about getting access.
andybons3322f762015-08-24 21:37:0913
nodir06cbaa02015-08-25 17:15:2414## Pick a head svn revision
andybons3322f762015-08-24 21:37:0915
nodir06cbaa02015-08-25 17:15:2416Consult http://llvm.org/svn/llvm-project/ for the current head revision. This
17will be the CLANG_REV you'll use later to check out each platform to a
18consistent state.
andybons3322f762015-08-24 21:37:0919
nodir06cbaa02015-08-25 17:15:2420## Build a release-mode clang-format on each platform
21
qyearsleyc0dc6f42016-12-02 22:13:3922Follow the official instructions here:
nodir06cbaa02015-08-25 17:15:2423http://clang.llvm.org/get_started.html.
andybons3322f762015-08-24 21:37:0924
25Windows step-by-step:
nodir06cbaa02015-08-25 17:15:2426
27```shell
28# [double check you have the tools you need]
andybons3322f762015-08-24 21:37:0929where cmake.exe # You need to install this.
andybons3322f762015-08-24 21:37:0930
Hans Wennborg045f4cd2020-03-03 13:15:1831# In chromium/src
32tools\win\setenv amd64_x86
33set CLANG_REV=56ac9d30d35632969baa39829ebc8465ed5937ef # You must change this value (see above)
34rmdir /S /Q llvm-project
35git clone https://github.com/llvm/llvm-project
36cd llvm-project
37git checkout %CLANG_REV%
38mkdir build
39cd build
40set CC=..\..\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe
41set CXX=..\..\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe
42set CFLAGS=-m32
43set CXXLAGS=-m32
dbeamb71beb82017-01-26 05:52:4044cmake -G Ninja ..\llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=MT ^
45 -DLLVM_ENABLE_ASSERTIONS=NO -DLLVM_ENABLE_THREADS=NO ^
Hans Wennborg045f4cd2020-03-03 13:15:1846 -DLLVM_ENABLE_PROJECTS=clang
andybons3322f762015-08-24 21:37:0947ninja clang-format
48bin\clang-format.exe --version
49```
50
51Mac & Linux step-by-step:
nodir06cbaa02015-08-25 17:15:2452
53```shell
andybons3322f762015-08-24 21:37:0954# Check out.
Tim van der Lippe3f8a49842020-03-03 12:31:2455export CLANG_REV=56ac9d30d35632969baa39829ebc8465ed5937ef # You must change this value (see above)
56git clone https://github.com/llvm/llvm-project
57cd llvm-project
58git checkout $CLANG_REV
59mkdir build
60cd build
andybons3322f762015-08-24 21:37:0961
Sam Maier9b5c0a72018-12-06 17:35:4662# On Mac, do the following:
dbeamb71beb82017-01-26 05:52:4063MACOSX_DEPLOYMENT_TARGET=10.9 cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
Tim van der Lippecd5f8b22020-03-03 13:12:4964 -DLLVM_ENABLE_PROJECTS=clang \
nodir06cbaa02015-08-25 17:15:2465 -DLLVM_ENABLE_ASSERTIONS=NO -DLLVM_ENABLE_THREADS=NO ../llvm/
andybons3322f762015-08-24 21:37:0966
Tim van der Lippe3f8a49842020-03-03 12:31:2467# On Linux, do the following:
68# Note the relative paths that point to your local Chromium checkout.
Sam Maier9b5c0a72018-12-06 17:35:4669cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
Tim van der Lippe3f8a49842020-03-03 12:31:2470 -DLLVM_ENABLE_PROJECTS=clang \
Sam Maier9b5c0a72018-12-06 17:35:4671 -DLLVM_ENABLE_ASSERTIONS=NO -DLLVM_ENABLE_THREADS=NO \
Tim van der Lippe3f8a49842020-03-03 12:31:2472 -DCMAKE_C_COMPILER=$PWD/../../chromium/src/third_party/llvm-build/Release+Asserts/bin/clang \
73 -DCMAKE_CXX_COMPILER=$PWD/../../chromium/src/third_party/llvm-build/Release+Asserts/bin/clang++ \
74 -DCMAKE_ASM_COMPILER=$PWD/../../chromium/src/third_party/llvm-build/Release+Asserts/bin/clang \
Sam Maier9b5c0a72018-12-06 17:35:4675 -DLLVM_ENABLE_TERMINFO=OFF -DCMAKE_CXX_STANDARD_LIBRARIES="-static-libgcc -static-libstdc++" ../llvm/
Tim van der Lippecd5f8b22020-03-03 13:12:4976
77# Finally, build the actual clang-format binary with Ninja
Sam Maier9b5c0a72018-12-06 17:35:4678ninja clang-format
79strip bin/clang-format
80
81
andybons3322f762015-08-24 21:37:0982```
nodir06cbaa02015-08-25 17:15:2483
andybons3322f762015-08-24 21:37:0984Platform specific notes:
andybons3322f762015-08-24 21:37:0985
nodir06cbaa02015-08-25 17:15:2486* Windows: Visual Studio 2013 only.
87* Linux: so far (as of January 2014) we've just included a 64-bit binary. It's
88 important to disable threading, else clang-format will depend on
89 libatomic.so.1 which doesn't exist on Precise.
90* Mac: Remember to set `MACOSX_DEPLOYMENT_TARGET` when building! If you get
91 configure warnings, you may need to install XCode 5 and avoid a goma
92 environment.
andybons3322f762015-08-24 21:37:0993
nodir06cbaa02015-08-25 17:15:2494## Upload each binary to google storage
andybons3322f762015-08-24 21:37:0995
nodir06cbaa02015-08-25 17:15:2496Copy the binaries into your chromium checkout (under
97`src/buildtools/(win|linux64|mac)/clang-format(.exe?)`). For each binary, you'll
98need to run upload_to_google_storage.py according to the instructions in
Glen Robertson6170fab2019-09-26 01:41:3899[README.txt](https://chromium.googlesource.com/chromium/src/+/master/buildtools/clang_format/README.txt).
thakisb4016a52017-02-28 00:06:07100This will upload the binary into a publicly accessible google storage bucket,
101and update `.sha1` file in your Chrome checkout. You'll check in the `.sha1`
102file (but NOT the clang-format binary) into source control. In order to be able
103to upload, you'll need write permission to the bucket -- see the prerequisites.
andybons3322f762015-08-24 21:37:09104
nodir06cbaa02015-08-25 17:15:24105## Copy the helper scripts and update README.chromium
106
107There are some auxiliary scripts that ought to be kept updated in lockstep with
108the clang-format binary. These get copied into
109third_party/clang_format/scripts in your Chromium checkout.
andybons3322f762015-08-24 21:37:09110
111The `README.chromium` file ought to be updated with version and date info.
112
nodir06cbaa02015-08-25 17:15:24113## Upload a CL according to the following template
andybons3322f762015-08-24 21:37:09114
nodir06cbaa02015-08-25 17:15:24115 Update clang-format binaries and scripts for all platforms.
andybons3322f762015-08-24 21:37:09116
nodir06cbaa02015-08-25 17:15:24117 I followed these instructions:
118 https://chromium.googlesource.com/chromium/src/+/master/docs/updating_clang_format_binaries.md
andybons3322f762015-08-24 21:37:09119
nodir06cbaa02015-08-25 17:15:24120 The binaries were built at clang revision ####### on ####DATETIME####.
andybons3322f762015-08-24 21:37:09121
Henrique Ferreiro804beaf2020-03-06 20:56:59122 Bug:
andybons3322f762015-08-24 21:37:09123
nodir06cbaa02015-08-25 17:15:24124The change should **always** include new `.sha1` files for each platform (we
125want to keep these in lockstep), should **never** include `clang-format`
126binaries directly. The change should **always** update `README.chromium`
andybons3322f762015-08-24 21:37:09127
nodir06cbaa02015-08-25 17:15:24128clang-format binaries should weigh in at 1.5MB or less. Watch out for size
129regressions.