Skip to content

Commit

Permalink
mac: Add clang-format binary that can run on arm.
Browse files Browse the repository at this point in the history
Normally we prefer having a dedicated binary each for intel and arm,
but clang-format:

1. is pulled via a .sha1 file and the binary will be next to the .sha1
   file

2. the location of the binary is referenced from depot_tools

So adding a second binary would mean adding a second .sha1 file, and
then we'd have to teach depot_tools to look in both places. And
clang-format is reasonably small. So just make it a universal binary
instead.

I built clang-format at the same revision the intel-only binary
was built at (eb85e90350e), using the steps in
docs/updating_clang_format_binaries.md. The only change I made
was to also pass `'-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64'` to
cmake (need to include the quotes, else the shell uses the `;` as
statement terminator -- luckily the `../llvm` part was after it
so cmake informed me of missing this at first).

Bug: 1190868
Change-Id: I092c4b1e9d37ddd7aeb4caef7d612a8df44092f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2786107
Reviewed-by: Hans Wennborg <hans@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#866974}
  • Loading branch information
nico authored and Chromium LUCI CQ committed Mar 26, 2021
1 parent 36158a5 commit b807f29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion buildtools/mac/clang-format.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
62bde1baa7196ad9df969fc1f06b66360b1a927b
ae6765c699ed32e9dca305645456dcdf5cda0438
22 changes: 15 additions & 7 deletions docs/updating_clang_format_binaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,27 @@ mkdir build
cd build

# On Mac, do the following:
MACOSX_DEPLOYMENT_TARGET=10.9 cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
MACOSX_DEPLOYMENT_TARGET=10.9 cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS=clang \
-DLLVM_ENABLE_ASSERTIONS=NO -DLLVM_ENABLE_THREADS=NO ../llvm/
-DLLVM_ENABLE_ASSERTIONS=NO \
-DLLVM_ENABLE_THREADS=NO \
'-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64' \
../llvm/

# On Linux, do the following:
# Note the relative paths that point to your local Chromium checkout.
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS=clang \
-DLLVM_ENABLE_ASSERTIONS=NO -DLLVM_ENABLE_THREADS=NO \
-DLLVM_ENABLE_ASSERTIONS=NO \
-DLLVM_ENABLE_THREADS=NO \
-DCMAKE_C_COMPILER=$PWD/../../chromium/src/third_party/llvm-build/Release+Asserts/bin/clang \
-DCMAKE_CXX_COMPILER=$PWD/../../chromium/src/third_party/llvm-build/Release+Asserts/bin/clang++ \
-DCMAKE_ASM_COMPILER=$PWD/../../chromium/src/third_party/llvm-build/Release+Asserts/bin/clang \
-DLLVM_ENABLE_TERMINFO=OFF -DCMAKE_CXX_STANDARD_LIBRARIES="-static-libgcc -static-libstdc++" ../llvm/
-DLLVM_ENABLE_TERMINFO=OFF \
-DCMAKE_CXX_STANDARD_LIBRARIES="-static-libgcc -static-libstdc++" \
../llvm/

# Finally, build the actual clang-format binary with Ninja
ninja clang-format
Expand All @@ -95,7 +103,7 @@ Platform specific notes:

Copy the binaries into your chromium checkout (under
`src/buildtools/(win|linux64|mac)/clang-format(.exe?)`). For each binary, you'll
need to run upload_to_google_storage.py according to the instructions in
need to run `upload_to_google_storage.py` according to the instructions in
[README.txt](https://chromium.googlesource.com/chromium/src/+/master/buildtools/clang_format/README.txt).
This will upload the binary into a publicly accessible google storage bucket,
and update `.sha1` file in your Chrome checkout. You'll check in the `.sha1`
Expand All @@ -106,7 +114,7 @@ to upload, you'll need write permission to the bucket -- see the prerequisites.

There are some auxiliary scripts that ought to be kept updated in lockstep with
the clang-format binary. These get copied into
third_party/clang_format/scripts in your Chromium checkout.
`buildtools/clang_format/script` in your Chromium checkout.

The `README.chromium` file ought to be updated with version and date info.

Expand Down

0 comments on commit b807f29

Please sign in to comment.